agjan 0.0.0-stage → 0.0.2
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/LICENSE +201 -0
- package/NOTICE +11 -0
- package/README.md +105 -2
- package/bin/agjan.mjs +12 -0
- package/docs/brand/agjan-icon.svg +14 -0
- package/docs/brand/agjan-logo-dark.svg +17 -0
- package/docs/brand/agjan-logo-light.svg +17 -0
- package/docs/guide.md +232 -0
- package/kit/domains/btp/domain.json +27 -0
- package/kit/hooks/guard.mjs +61 -0
- package/kit/mcp/servers.json +5 -0
- package/kit/skills/agjan-build/SKILL.md +61 -0
- package/kit/skills/agjan-design/SKILL.md +95 -0
- package/kit/skills/agjan-fix/SKILL.md +55 -0
- package/kit/skills/agjan-map/SKILL.md +51 -0
- package/kit/skills/agjan-spec/SKILL.md +111 -0
- package/kit/skills/agjan-verify/SKILL.md +60 -0
- package/kit/skills/btp-architect/SKILL.md +51 -0
- package/kit/skills/btp-architect/references/deployment.md +72 -0
- package/kit/skills/btp-architect/references/security.md +54 -0
- package/kit/skills/cap-developer/SKILL.md +49 -0
- package/kit/skills/cap-developer/references/handlers.md +47 -0
- package/kit/skills/cap-developer/references/modeling.md +52 -0
- package/kit/skills/cap-developer/references/services.md +53 -0
- package/kit/skills/cap-developer/references/testing.md +39 -0
- package/kit/skills/cap-developer/references/validation-security.md +49 -0
- package/kit/skills/fiori-developer/SKILL.md +64 -0
- package/kit/skills/fiori-developer/references/elements.md +77 -0
- package/kit/skills/fiori-developer/references/freestyle-ts.md +45 -0
- package/kit/skills/fiori-developer/references/testing.md +32 -0
- package/kit/skills/fiori-developer/references/ui5-basics.md +52 -0
- package/kit/skills/solution-reviewer/SKILL.md +51 -0
- package/kit/templates/agents-block.md +20 -0
- package/kit/templates/agjan-ci.yml +40 -0
- package/kit/templates/design.md +17 -0
- package/kit/templates/project.md +28 -0
- package/kit/templates/spec.md +33 -0
- package/kit/templates/tasks.md +13 -0
- package/package.json +50 -4
- package/schemas/approvals.schema.json +93 -0
- package/schemas/config.schema.json +79 -0
- package/schemas/log.schema.json +30 -0
- package/schemas/reviews.schema.json +68 -0
- package/schemas/tasks.schema.json +26 -0
- package/src/adapters/claude-code.mjs +115 -0
- package/src/adapters/copilot.mjs +88 -0
- package/src/baseline.mjs +66 -0
- package/src/cli.mjs +133 -0
- package/src/commands/check.mjs +363 -0
- package/src/commands/fix.mjs +116 -0
- package/src/commands/gates.mjs +264 -0
- package/src/commands/log.mjs +53 -0
- package/src/commands/map.mjs +47 -0
- package/src/commands/new.mjs +53 -0
- package/src/commands/pr-summary.mjs +134 -0
- package/src/commands/report.mjs +110 -0
- package/src/commands/review.mjs +49 -0
- package/src/commands/setup.mjs +269 -0
- package/src/commands/status.mjs +176 -0
- package/src/config.mjs +98 -0
- package/src/context.mjs +58 -0
- package/src/documents.mjs +188 -0
- package/src/errors.mjs +16 -0
- package/src/feature.mjs +214 -0
- package/src/fix.mjs +108 -0
- package/src/git.mjs +66 -0
- package/src/hash.mjs +33 -0
- package/src/hook.mjs +48 -0
- package/src/json-file.mjs +24 -0
- package/src/log.mjs +37 -0
- package/src/managed.mjs +178 -0
- package/src/mcp-config.mjs +83 -0
- package/src/mcp.mjs +142 -0
- package/src/plan.mjs +41 -0
- package/src/progress.mjs +85 -0
- package/src/review-policy.mjs +49 -0
- package/src/review.mjs +336 -0
- package/src/scope.mjs +30 -0
- package/src/terminal.mjs +98 -0
- package/src/test-results.mjs +111 -0
- package/src/tests-map.mjs +29 -0
- package/src/ui.mjs +110 -0
- package/src/usage.mjs +118 -0
- package/src/validate.mjs +41 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Security on BTP (XSUAA, app router, destinations, secrets)
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP MCP
|
|
4
|
+
server, and from the SAP BTP documentation (`SAP-docs/btp-cloud-platform`, CC-BY-4.0),
|
|
5
|
+
on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
6
|
+
|
|
7
|
+
## Authentication and the security descriptor
|
|
8
|
+
|
|
9
|
+
- `cds add xsuaa` configures XSUAA authentication (`"auth": "xsuaa"`, with `@sap/xssec`)
|
|
10
|
+
and generates `xs-security.json` from the model:
|
|
11
|
+
- one **scope** per CAP role in `@requires` / `@restrict` (`$XSAPPNAME.<role>`, with
|
|
12
|
+
exactly the role's name);
|
|
13
|
+
- one **attribute** per `$user.<attribute>` used in `where` conditions;
|
|
14
|
+
- one **role template** per scope.
|
|
15
|
+
- After a change to roles or attributes in the model, regenerate it:
|
|
16
|
+
`cds compile srv --to xsuaa > xs-security.json`, then re-add any manual parts. If you
|
|
17
|
+
edit it by hand, scope names must stay exactly equal to the CAP role names; they are
|
|
18
|
+
checked at runtime (the `$XSAPPNAME.` prefix is removed).
|
|
19
|
+
- **Role names must fit XSUAA**, because CAP turns each role into a scope and a role
|
|
20
|
+
template of the same name: use only letters, digits, `-` and `_`, at most 64
|
|
21
|
+
characters. (Scopes also allow `/`, `\` and `:`, role templates also `.`; only the
|
|
22
|
+
common subset works for both.) Attributes used as `$user.<attribute>`: letters, digits
|
|
23
|
+
and `_`, at most 64 characters. Role collection names: at most 64 characters.
|
|
24
|
+
- Role collections, which group role templates and are assigned to users, are normally
|
|
25
|
+
created by administrators in the BTP cockpit. Predefine them in `xs-security.json`
|
|
26
|
+
(`role-collections`) only for templates without attributes. The design names who
|
|
27
|
+
assigns which collection.
|
|
28
|
+
|
|
29
|
+
## App router
|
|
30
|
+
|
|
31
|
+
- `cds add approuter` adds the SAP application router, which serves the UIs, runs the
|
|
32
|
+
interactive login against XSUAA and forwards requests with the user's token. Routes
|
|
33
|
+
live in `xs-app.json`. It is only needed for deployment; keep it out of the app folders
|
|
34
|
+
(for example in `.deploy/app-router`).
|
|
35
|
+
- Locally, test the full login with `cds bind --exec -- npm start --prefix <router folder>`
|
|
36
|
+
and `cds watch --profile hybrid`. `"authenticationMethod": "none"` in `xs-app.json` is
|
|
37
|
+
for local UI tests only; never commit it for production.
|
|
38
|
+
|
|
39
|
+
## Remote systems
|
|
40
|
+
|
|
41
|
+
- Reach remote APIs through CAP remote services with a BTP **destination**
|
|
42
|
+
(`cds.requires.<service>.credentials.destination`); on-premise systems additionally
|
|
43
|
+
through the connectivity service (Cloud Connector). CAP handles the connection,
|
|
44
|
+
authentication and user propagation.
|
|
45
|
+
|
|
46
|
+
## Secrets
|
|
47
|
+
|
|
48
|
+
- Credentials come from service bindings (`VCAP_SERVICES` on Cloud Foundry, secrets on
|
|
49
|
+
Kyma), filled into `cds.requires.<service>.credentials` at process start.
|
|
50
|
+
- **Never** put secrets or passwords into `package.json`, `.cdsrc.json`, `mta.yaml` or any
|
|
51
|
+
committed file. Local credentials go into `.env` or `.cdsrc-private.json`, both
|
|
52
|
+
git-ignored; check that they are.
|
|
53
|
+
- Never share or log service keys and tokens; never paste them into documents in
|
|
54
|
+
`docs/agjan/`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap-developer
|
|
3
|
+
description: Role knowledge for the cap area of agjan (SAP CAP Node.js backend - CDS models, services, handlers, tests). Loaded by agjan-design and agjan-build when the cap area is in scope.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cap-developer
|
|
7
|
+
|
|
8
|
+
Rules for designing and building CAP Node.js backends in agjan. Project conventions
|
|
9
|
+
(the baseline `docs/agjan/project.md`, the code that exists) win over these defaults.
|
|
10
|
+
|
|
11
|
+
## Knowledge: this skill first, the MCP server as reference
|
|
12
|
+
|
|
13
|
+
1. Use this skill and its references first; they work offline.
|
|
14
|
+
2. Consult the documentation tools configured for the `cap` area (by default the CAP MCP
|
|
15
|
+
server) when the skill does not cover the topic, for exact syntax and APIs,
|
|
16
|
+
version-specific behavior, or when in doubt: `search_docs`, one concept per query.
|
|
17
|
+
3. Use `search_model` whenever it is available to read this project's CDS model
|
|
18
|
+
(definitions, annotations, endpoints); no skill can know it.
|
|
19
|
+
4. Offline or without the tools: follow the skill and the patterns already in the
|
|
20
|
+
project, and say in your output which question could not be checked.
|
|
21
|
+
|
|
22
|
+
## Read the reference for what the task touches
|
|
23
|
+
|
|
24
|
+
| The task touches | Read |
|
|
25
|
+
|---|---|
|
|
26
|
+
| entities, types, associations, compositions, localized texts | `references/modeling.md` |
|
|
27
|
+
| services, projections, actions, functions, drafts, remote services | `references/services.md` |
|
|
28
|
+
| input validation, `@mandatory`, `@assert…`, authorization, error messages | `references/validation-security.md` |
|
|
29
|
+
| handler code, queries, errors, transactions | `references/handlers.md` |
|
|
30
|
+
| tests | `references/testing.md` |
|
|
31
|
+
|
|
32
|
+
## Decide in this order
|
|
33
|
+
|
|
34
|
+
1. **Declarative before code.** What an annotation can express (validation, read-only,
|
|
35
|
+
authorization, defaults) is never written as handler code.
|
|
36
|
+
2. **Extend before adding.** A new service, entity or BTP-relevant dependency is a
|
|
37
|
+
design decision with reason and alternative; prefer extending what exists.
|
|
38
|
+
3. **The domain model stays clean; services are facades.** Persistence in `db/`;
|
|
39
|
+
use-case services with projections in `srv/`.
|
|
40
|
+
4. **Authorization is part of the design**, named after the spec's business roles, and a
|
|
41
|
+
risk whenever it changes.
|
|
42
|
+
5. **Compatibility.** Removing or renaming an element of an exposed entity breaks
|
|
43
|
+
clients (UIs, other services); call it out under Risks.
|
|
44
|
+
|
|
45
|
+
## Building
|
|
46
|
+
|
|
47
|
+
- Follow the project's style (ESM or CommonJS, file names `<name>-service.cds/.js`).
|
|
48
|
+
- Write a test for each AC of the task, named with the AC id, through the service API.
|
|
49
|
+
- Run the area's test command, then `npx agjan check`, before you commit the task.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Handlers, queries, errors, transactions (Node.js)
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
+
MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
5
|
+
|
|
6
|
+
## Where handlers go
|
|
7
|
+
|
|
8
|
+
- One class per service, extending `cds.ApplicationService`, in the `.js` file next to
|
|
9
|
+
the service's `.cds` file. Register handlers in `init()` and call `super.init()`
|
|
10
|
+
(after your registrations, so yours run first). Take entities from `this.entities`.
|
|
11
|
+
- `before` validates and enriches input, `on` replaces the default implementation (call
|
|
12
|
+
`next()` to delegate), `after` post-processes results. Prefer `before`/`after`; an `on`
|
|
13
|
+
handler that skips `next()` takes over completely.
|
|
14
|
+
- Generic handlers (`'*'` for events or entities) exist, but keep handlers specific.
|
|
15
|
+
- Handlers registered in `cds.on('served')` must be registered synchronously; no `await`
|
|
16
|
+
before registering.
|
|
17
|
+
|
|
18
|
+
## Errors
|
|
19
|
+
|
|
20
|
+
- `req.reject(status, code_or_message, target)` throws now; `req.error(…)` collects and
|
|
21
|
+
lets the runtime reject after the current phase (`before`, `on`, `after`). Use
|
|
22
|
+
`req.error` to report several invalid fields at once.
|
|
23
|
+
- Give a `target` (the element name) so Fiori shows the message at the field, and a
|
|
24
|
+
`code` that is also the i18n key of the message.
|
|
25
|
+
- 5xx errors reach the client as generic messages in production; never put internal
|
|
26
|
+
details into them, and do not turn sanitizing off.
|
|
27
|
+
- If an annotation can do the check, do not write it (see validation-security.md).
|
|
28
|
+
|
|
29
|
+
## Queries
|
|
30
|
+
|
|
31
|
+
- Use `cds.ql`: `SELECT.from(Orders).where({ status: 'New' })`, or tagged templates
|
|
32
|
+
``SELECT.from(Orders).where`ID = ${id}` ``. Values become bound parameters.
|
|
33
|
+
- **Never** concatenate input into a query string (`.where('ID=' + id)`), and never put a
|
|
34
|
+
tagged template in parentheses (`.where(`ID=${id}`)` is plain concatenation).
|
|
35
|
+
- `INSERT.into`, `UPDATE(Entity, key).with(…)`, `DELETE.from` work the same way; on a
|
|
36
|
+
service, `srv.run(query)` or the CRUD helpers `srv.read/create/update`.
|
|
37
|
+
|
|
38
|
+
## Transactions
|
|
39
|
+
|
|
40
|
+
- A request handler already runs in a transaction; do not wrap it in `cds.tx(req)`
|
|
41
|
+
(outdated).
|
|
42
|
+
- For work outside a request (jobs, startup), use `cds.tx(async () => { … })`: the
|
|
43
|
+
function and everything it calls run in one new transaction, committed or rolled back
|
|
44
|
+
as a whole. A manual `srv.tx()` without a function must be committed or rolled back by
|
|
45
|
+
you, and nested calls to other services do not join it.
|
|
46
|
+
- Lock what you read before changing it in the same transaction:
|
|
47
|
+
`SELECT(1).from(Orders, id).forUpdate()`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Domain modeling (CDS)
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
+
MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
5
|
+
|
|
6
|
+
## Keep it simple
|
|
7
|
+
|
|
8
|
+
- The model serves its consumers: concise and readable beats systematic and abstract.
|
|
9
|
+
Do not abstract away a relational database that nearly all consumers use anyway.
|
|
10
|
+
- Prefer flat entities. Use structured types only when every consumer handles them;
|
|
11
|
+
flat structures are easier to read and to consume.
|
|
12
|
+
|
|
13
|
+
## Names
|
|
14
|
+
|
|
15
|
+
- Entities and types start with a capital letter; elements with a lowercase letter.
|
|
16
|
+
- Entities are plural (`Orders`, `Authors`), types singular (`Genre`).
|
|
17
|
+
- Do not repeat the context (`Authors.name`, not `Authors.authorName`); prefer one-word
|
|
18
|
+
names (`address`, not `addressInformation`).
|
|
19
|
+
- The technical primary key is called `ID`.
|
|
20
|
+
|
|
21
|
+
## Keys and reuse
|
|
22
|
+
|
|
23
|
+
- Use the aspect `cuid` from `@sap/cds/common` (a `UUID` key named `ID`) for entity keys,
|
|
24
|
+
so all entities are addressed the same way.
|
|
25
|
+
- Use `managed` for `createdAt`, `createdBy`, `modifiedAt`, `modifiedBy`; the runtime
|
|
26
|
+
fills them.
|
|
27
|
+
- Use the common reuse types `Country`, `Currency`, `Language` (with their value lists)
|
|
28
|
+
instead of plain strings; `temporal` for validity periods.
|
|
29
|
+
- Combine aspects (`entity Orders : cuid, managed { … }`) rather than building a base
|
|
30
|
+
entity hierarchy.
|
|
31
|
+
|
|
32
|
+
## Compositions or associations
|
|
33
|
+
|
|
34
|
+
Composition when parent and children share a life cycle, there is a clear parent-child
|
|
35
|
+
hierarchy, a child is never exposed on its own, its parent never changes, and they are
|
|
36
|
+
changed together in one transaction. Association when entities have their own life
|
|
37
|
+
cycles, are exposed on their own, or the relationship can change. ("Your arm is
|
|
38
|
+
composed to your body; your phone is associated with you.")
|
|
39
|
+
|
|
40
|
+
- A document with thousands of children is copied entirely into a draft on every edit.
|
|
41
|
+
For such documents, decouple the children with associations.
|
|
42
|
+
- Avoid compositions of one: put the fields into the parent instead (limited draft and
|
|
43
|
+
Fiori support, foreign keys by hand).
|
|
44
|
+
- A child of a composition has a back association to its parent
|
|
45
|
+
(`Items : Composition of many OrderItems on Items.parent = $self`).
|
|
46
|
+
|
|
47
|
+
## Localized data
|
|
48
|
+
|
|
49
|
+
- Mark translatable texts with `localized` (`title : localized String`); CAP generates
|
|
50
|
+
the `.texts` entity and serves the user's language with fallback.
|
|
51
|
+
- An entity with `localized` elements must not have associations as keys; `localized`
|
|
52
|
+
inside structured elements is ignored.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Services, operations, drafts
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
+
MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
5
|
+
|
|
6
|
+
## Services as facades
|
|
7
|
+
|
|
8
|
+
- A service is the interface of the application for one use case and one group of users
|
|
9
|
+
(for example an admin service for maintaining data and a catalog service for
|
|
10
|
+
browsing). It exposes projections on the domain model, not the model itself.
|
|
11
|
+
- Tailor projections to the use case: flatten what the consumer needs
|
|
12
|
+
(`author.name as author`), leave out what it must not see
|
|
13
|
+
(`excluding { createdBy, modifiedBy }`).
|
|
14
|
+
- Mark read-only use cases `@readonly`, create-only ones `@insertonly`. These restrict
|
|
15
|
+
the operations for all users; they are shortcuts for `@restrict`.
|
|
16
|
+
- Prefer `@readonly`, `@mandatory` and similar CDS annotations over the equivalent OData
|
|
17
|
+
`@Capabilities` annotations: shorter, and they mean the same.
|
|
18
|
+
|
|
19
|
+
## Actions and functions
|
|
20
|
+
|
|
21
|
+
- Actions change data; functions only read. Unbound ones belong to the service; bound
|
|
22
|
+
ones receive the entity instance's key (or, bound to a collection, no instance).
|
|
23
|
+
- Implement them like CRUD handlers: `this.on('approve', Orders, req => …)` for bound,
|
|
24
|
+
`this.on('submitOrder', req => …)` for unbound. Keys of a bound instance are in
|
|
25
|
+
`req.params`, the arguments in `req.data`.
|
|
26
|
+
- Over OData, bound operations are called with the service prefix
|
|
27
|
+
(`/Orders(ID)/OrdersService.approve`) and functions always with `()`.
|
|
28
|
+
- Authorize them like entities: `@restrict` grants accept operation names.
|
|
29
|
+
|
|
30
|
+
## Drafts (Fiori editing)
|
|
31
|
+
|
|
32
|
+
- `@odata.draft.enabled` on the entity is all it takes; CAP adds a `.drafts` shadow
|
|
33
|
+
entity and the draft events.
|
|
34
|
+
- While a user edits, the draft events run: `NEW`, `PATCH` (an alias of `UPDATE` on the
|
|
35
|
+
draft), `DISCARD` on `Entity.drafts`, `EDIT` on the active entity. Use them for
|
|
36
|
+
feedback during editing.
|
|
37
|
+
- Saving activates the draft as **one** `CREATE` or `UPDATE` of the active entity, deep
|
|
38
|
+
with its compositions, in one transaction (stated for CAP Java; confirm for Node.js and
|
|
39
|
+
the project's `@sap/cds` version with `search_docs`). Validation that must hold for
|
|
40
|
+
saved data therefore belongs in `before CREATE/UPDATE` handlers of the active entity, or
|
|
41
|
+
better in annotations; `SAVE` on `Entity.drafts` runs before the activation.
|
|
42
|
+
- `SELECT.from(Entity)` reads active data, `SELECT.from(Entity.drafts)` draft data. Do
|
|
43
|
+
not filter on draft properties by hand.
|
|
44
|
+
- Introducing drafts changes how handlers run; it is a design decision.
|
|
45
|
+
|
|
46
|
+
## Remote services
|
|
47
|
+
|
|
48
|
+
- Consume external APIs as CAP remote services: a `cds.requires` entry with the
|
|
49
|
+
imported model and a BTP destination, then `cds.connect.to(…)`. Prefer this over
|
|
50
|
+
calling the Cloud SDK directly; CAP handles connections, authentication and user
|
|
51
|
+
propagation.
|
|
52
|
+
- Query remote and local services with `cds.ql` and `srv.run(…)`: protocol-independent.
|
|
53
|
+
`srv.send` with OData query options ties the code to one protocol.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Testing with cds.test (Node.js)
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
+
MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
5
|
+
|
|
6
|
+
## Shape of a test file
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
const cds = require('@sap/cds');
|
|
10
|
+
const { GET, POST, expect, defaults } = cds.test(__dirname + '/..');
|
|
11
|
+
defaults.path = '/odata/v4/orders';
|
|
12
|
+
defaults.auth = { username: 'alice' };
|
|
13
|
+
|
|
14
|
+
describe('OrdersService', () => {
|
|
15
|
+
it('ORDF-AC1: lists only orders of the chosen status', async () => {
|
|
16
|
+
const { data } = await GET`Orders?$filter=status eq 'New'`;
|
|
17
|
+
expect(data.value.every((o) => o.status === 'New')).to.be.true;
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Rules
|
|
23
|
+
|
|
24
|
+
- Call `cds.test(…)` **first** in the file, before touching `cds.env` or other `cds`
|
|
25
|
+
modules, and **once** per file: it starts one server for the whole file on a free port
|
|
26
|
+
and stops it after the tests.
|
|
27
|
+
- Point it at the project folder (`cds.test(folder)` or `.in(folder)`); never use
|
|
28
|
+
`process.chdir()`.
|
|
29
|
+
- 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.
|
|
31
|
+
- Mock as little as possible; the more is mocked, the less is tested. Mocking module
|
|
32
|
+
caches or timers can break the CAP server.
|
|
33
|
+
- Use the project's runner (`node:test`, jest, mocha, vitest); `cds.test` works with all
|
|
34
|
+
of them.
|
|
35
|
+
- agjan: every AC of a task gets at least one test whose name starts with its id, and
|
|
36
|
+
every validation gets a test of its failure case.
|
|
37
|
+
- If the project configures test results (`verify.cap.results`), the test command must
|
|
38
|
+
write them (for example `node --test --test-reporter=junit
|
|
39
|
+
--test-reporter-destination=reports/junit.xml`), so `agjan check` sees them pass.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Input validation and authorization
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
+
MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
5
|
+
|
|
6
|
+
## Validation with annotations
|
|
7
|
+
|
|
8
|
+
Put constraints on the elements of the entities that accept input; the runtime checks
|
|
9
|
+
them and answers with a 400 and a translated message. Never re-implement them in
|
|
10
|
+
handlers.
|
|
11
|
+
|
|
12
|
+
- `@mandatory`: rejects missing **and empty** input, and tells Fiori the field is
|
|
13
|
+
required. Prefer it to a database `not null`, which only fails late and without a
|
|
14
|
+
useful message.
|
|
15
|
+
- `@assert.range: [min, max]`: numbers and dates, closed interval by default. Wrap a
|
|
16
|
+
bound in parentheses to exclude it (`[(0), 100]`: above 0), use `_` for no bound
|
|
17
|
+
(`[(0), _]`: positive). On an `enum` element, `@assert.range` alone restricts input to
|
|
18
|
+
the enum values. (Open intervals and `_` need `@sap/cds` 8.5 or later.)
|
|
19
|
+
- `@assert.format: '<regex>'`: strings matching a pattern.
|
|
20
|
+
- `@assert.target`: on a managed to-one association, checks that the referenced instance
|
|
21
|
+
exists (create and update). It validates user input; referential integrity is
|
|
22
|
+
`@assert.integrity`. A target created in the same deep insert is not found.
|
|
23
|
+
- `@readonly` on an element: the client cannot set it (and Fiori shows it read-only).
|
|
24
|
+
|
|
25
|
+
Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`,
|
|
26
|
+
`ASSERT_FORMAT`, `ASSERT_TARGET`. Project-specific texts go into
|
|
27
|
+
`_i18n/messages_<locale>.properties` under the same keys.
|
|
28
|
+
|
|
29
|
+
## Authorization
|
|
30
|
+
|
|
31
|
+
- `@requires: 'Role'` (or a list, meaning any of them) on a service, entity or
|
|
32
|
+
operation. Pseudo roles: `authenticated-user`, `system-user`, `any`. A service with
|
|
33
|
+
`@requires` also protects its `$metadata` and service root.
|
|
34
|
+
- `@restrict: [{ grant, to, where }]` for finer control:
|
|
35
|
+
- `grant`: `READ`, `CREATE`, `UPDATE`, `DELETE`, operation names, `WRITE` (all
|
|
36
|
+
changing events) or `*`;
|
|
37
|
+
- `to`: roles (default `any`);
|
|
38
|
+
- `where`: a CQL condition on the instance, for example `createdBy = $user` or
|
|
39
|
+
`$user.country = countryCode`.
|
|
40
|
+
- `$user.<attribute>` is a list of values: a condition is true if any value matches; an
|
|
41
|
+
empty or missing attribute grants **nothing**.
|
|
42
|
+
- `where` conditions are enforced against stored data: pushed into the query for `READ`,
|
|
43
|
+
checked before `UPDATE`/`DELETE`. For `CREATE`, unbound operations and operations on
|
|
44
|
+
collections, only simple comparisons of user attributes with literals
|
|
45
|
+
(`$user.level >= 2`) can be checked.
|
|
46
|
+
- `$metadata` does not apply `@restrict`; do not rely on hiding entities there.
|
|
47
|
+
- Name roles after the spec's business roles; the same roles go into
|
|
48
|
+
`xs-security.json` (btp area). Every authorization change is a risk in the design and
|
|
49
|
+
gets its own review.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fiori-developer
|
|
3
|
+
description: Role knowledge for the fiori area of agjan (SAP Fiori elements and freestyle UI5 in TypeScript, app type decision, UI annotations, UI tests). Loaded by agjan-design and agjan-build when the fiori area is in scope.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# fiori-developer
|
|
7
|
+
|
|
8
|
+
Rules for designing and building SAP Fiori UIs on CAP in agjan. Project conventions (the
|
|
9
|
+
baseline `docs/agjan/project.md`, the apps that exist) win over these defaults.
|
|
10
|
+
|
|
11
|
+
## Knowledge: this skill first, the MCP servers as reference
|
|
12
|
+
|
|
13
|
+
1. Use this skill and its references first; they work offline. (`ui5-basics.md` already
|
|
14
|
+
contains the UI5 guidelines, so `get_guidelines` is not needed for every task.)
|
|
15
|
+
2. Consult the documentation tools configured for the `fiori` area when the skill does
|
|
16
|
+
not cover the topic, for exact syntax and APIs, version-specific behavior, or when in
|
|
17
|
+
doubt:
|
|
18
|
+
- UI5 MCP server: `get_api_reference` (for the project's UI5 version),
|
|
19
|
+
`get_version_info`, `get_guidelines`;
|
|
20
|
+
- Fiori MCP server: `search_docs` for Fiori elements, annotations and Fiori tools;
|
|
21
|
+
`list_functionality` and `get_functionality_details` to see how an existing app can
|
|
22
|
+
be changed.
|
|
23
|
+
3. Use the checks whenever they are available: `run_ui5_linter` after a change,
|
|
24
|
+
`run_manifest_validation` after a change to `manifest.json`.
|
|
25
|
+
4. Offline or without the tools: follow the skill and the patterns already in the app,
|
|
26
|
+
and say in your output which question could not be checked and that the linter did
|
|
27
|
+
not run.
|
|
28
|
+
|
|
29
|
+
Generator and modification tools (`create_ui5_app`, `generate_fiori_app_*`,
|
|
30
|
+
`execute_functionality`) change files: use them only for a task whose approved `paths`
|
|
31
|
+
cover what they create or change.
|
|
32
|
+
|
|
33
|
+
## App type (new applications only)
|
|
34
|
+
|
|
35
|
+
Decide `app_type` in `design.md` with reason and alternative:
|
|
36
|
+
|
|
37
|
+
- `elements` (default): list report, object page, worklist and analytical pages over an
|
|
38
|
+
OData V4 service, where annotations express the UI. Less code, consistent UX, upgrades
|
|
39
|
+
with UI5.
|
|
40
|
+
- `freestyle` (TypeScript): the UX cannot be expressed with Fiori elements floorplans,
|
|
41
|
+
building blocks and extensions (custom interaction, unusual flows). More code to own.
|
|
42
|
+
|
|
43
|
+
Existing applications are never re-decided: `sap.fe.templates` in `manifest.json` means
|
|
44
|
+
elements. Extend an elements app with annotations first, then `manifest.json` settings,
|
|
45
|
+
then building blocks or custom sections and columns, and controller extensions last.
|
|
46
|
+
|
|
47
|
+
## Read the references for the task
|
|
48
|
+
|
|
49
|
+
| The task touches | Read |
|
|
50
|
+
|---|---|
|
|
51
|
+
| any UI5 code, views, i18n, `index.html`, CAP integration | `references/ui5-basics.md` |
|
|
52
|
+
| an elements app (annotations, pages, value help, actions, side effects) | `references/elements.md` |
|
|
53
|
+
| a freestyle TypeScript app | `references/freestyle-ts.md` |
|
|
54
|
+
| UI tests | `references/testing.md` |
|
|
55
|
+
|
|
56
|
+
## Both types
|
|
57
|
+
|
|
58
|
+
- The service comes first: the UI is built against the finished CAP service, and most ACs
|
|
59
|
+
are tested in the service.
|
|
60
|
+
- Authorization lives in the service, never in the UI; the UI only hides what the service
|
|
61
|
+
already forbids.
|
|
62
|
+
- Texts in i18n files, in every locale the app has.
|
|
63
|
+
- After a change: `run_ui5_linter`, `run_manifest_validation` (if `manifest.json` changed),
|
|
64
|
+
the tests, then `npx agjan check`.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# SAP Fiori elements (OData V4) with CAP
|
|
2
|
+
|
|
3
|
+
Distilled from the SAPUI5 and SAP Fiori tools documentation (`SAP-docs/sapui5`,
|
|
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. Rules restated; check details and
|
|
6
|
+
current syntax with `search_docs`.
|
|
7
|
+
|
|
8
|
+
## Where things go
|
|
9
|
+
|
|
10
|
+
- UI annotations in the app's `annotations.cds` (`app/<app>/annotations.cds`), pulled in by
|
|
11
|
+
`app/services.cds`, annotating the **service** entities, not the domain model. Field
|
|
12
|
+
labels can live on the domain model with `@title` (`'{i18n>OrderNo}'`), so every
|
|
13
|
+
service and app shares them.
|
|
14
|
+
- Order of preference: annotations, then `manifest.json` settings, then the flexible
|
|
15
|
+
programming model (building blocks, custom sections and columns), then controller
|
|
16
|
+
extensions. Extensions only when nothing before them can do it.
|
|
17
|
+
|
|
18
|
+
## List report
|
|
19
|
+
|
|
20
|
+
- `UI.SelectionFields`: the filter fields. `UI.LineItem`: the columns, in order;
|
|
21
|
+
`![@UI.Importance] : #High` for columns that stay on small screens.
|
|
22
|
+
- Several values in one column: a `UI.FieldGroup #Qualifier` referenced from the line
|
|
23
|
+
item with `UI.DataFieldForAnnotation`.
|
|
24
|
+
- Default sort and grouping: `UI.PresentationVariant` (or a
|
|
25
|
+
`UI.SelectionPresentationVariant` pointing to it). Every referenced variant must exist;
|
|
26
|
+
a dangling reference stops the app from loading.
|
|
27
|
+
- Table type and similar options: `manifest.json`, under the list report target's
|
|
28
|
+
`controlConfiguration` for `@com.sap.vocabularies.UI.v1.LineItem`.
|
|
29
|
+
|
|
30
|
+
## Object page
|
|
31
|
+
|
|
32
|
+
- `UI.HeaderInfo` for title and description. `UI.Facets` for sections:
|
|
33
|
+
`UI.ReferenceFacet` pointing to a `UI.FieldGroup #Qualifier` (or a `UI.LineItem` of a
|
|
34
|
+
composition for a table), `UI.CollectionFacet` for a section with subsections.
|
|
35
|
+
- Two levels at most; a collection with only one reference facet renders badly, so use the
|
|
36
|
+
reference facet directly. Give facets stable, camelCase `ID`s.
|
|
37
|
+
|
|
38
|
+
## Fields
|
|
39
|
+
|
|
40
|
+
- An ID with a readable text, on the ID element:
|
|
41
|
+
`@Common.Text: customer.name` and `@Common.Text.@UI.TextArrangement: #TextOnly` (or
|
|
42
|
+
`#TextFirst`, `#TextLast`, `#TextSeparate`). The older form with `$value` is deprecated
|
|
43
|
+
in CAP.
|
|
44
|
+
- Value help: `@Common.ValueList` on the property, with `CollectionPath` (the value help
|
|
45
|
+
entity of the same service) and `Parameters` (`Common.ValueListParameterInOut` for the
|
|
46
|
+
key, `…DisplayOnly` for extra columns). For a short fixed list (dropdown), add
|
|
47
|
+
`@Common.ValueListWithFixedValues: true` to the same property.
|
|
48
|
+
- Status colors: `Criticality` on the `UI.DataField` (or a `UI.DataPoint`), pointing to an
|
|
49
|
+
integer property with 0 neutral, 1 negative, 2 critical, 3 positive.
|
|
50
|
+
- Read-only, mandatory and hidden: `@readonly` and `@mandatory` in CDS first; the
|
|
51
|
+
`Common.FieldControl` and `UI.Hidden` annotations for conditions
|
|
52
|
+
(`@Common.FieldControl: #Mandatory`, or path-based to a property).
|
|
53
|
+
|
|
54
|
+
## Actions
|
|
55
|
+
|
|
56
|
+
- A bound action as a button: `{ $Type: 'UI.DataFieldForAction', Action: 'OrdersService.approve', Label: '{i18n>Approve}' }`
|
|
57
|
+
in `UI.LineItem` (toolbar, or `Inline: true` in the row) or in `UI.Identification` (object
|
|
58
|
+
page header). The action's authorization is the service's `@restrict`.
|
|
59
|
+
- Do not use determining actions (`Determining: true`) for new designs; they are
|
|
60
|
+
deprecated.
|
|
61
|
+
|
|
62
|
+
## Side effects (draft apps)
|
|
63
|
+
|
|
64
|
+
- When a change to one field changes others on the server, declare
|
|
65
|
+
`@Common.SideEffects #name: { SourceProperties: [quantity], TargetProperties: ['amount'] }`
|
|
66
|
+
on the entity. Name the targets narrowly (`TargetProperties`, or a specific
|
|
67
|
+
`TargetEntities` path); a whole-entity refresh is slower, and 1:n target entities on
|
|
68
|
+
paged tables have paging effects. Side effects need a draft-enabled entity.
|
|
69
|
+
|
|
70
|
+
## Extensions
|
|
71
|
+
|
|
72
|
+
- In controller extensions and custom code, use only the documented `extensionAPI` and
|
|
73
|
+
building block APIs. Never access or change controls, models or other objects the
|
|
74
|
+
framework creates internally: they change between versions.
|
|
75
|
+
- Do not override the framework's keyboard shortcuts.
|
|
76
|
+
- Prefer an annotation over a custom column wherever an annotation can show the value (for
|
|
77
|
+
performance and for personalization).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Freestyle UI5 in TypeScript
|
|
2
|
+
|
|
3
|
+
Distilled from the UI5 MCP server's guidelines (`get_guidelines`,
|
|
4
|
+
`get_typescript_conversion_guidelines`, `@ui5/mcp-server` 0.3.2, Apache-2.0), retrieved on
|
|
5
|
+
2026-10-17. Rules restated. Read `ui5-basics.md` first.
|
|
6
|
+
|
|
7
|
+
## Project setup
|
|
8
|
+
|
|
9
|
+
- Dev dependencies: `@ui5/cli`, `typescript`, `ui5-tooling-transpile` (and
|
|
10
|
+
`ui5-middleware-livereload`), plus `@sapui5/types` (or `@openui5/types`) **in the version
|
|
11
|
+
of the project's UI5**; `typescript-eslint` only if the project uses eslint. Do not raise
|
|
12
|
+
the major version of a dependency that is already there.
|
|
13
|
+
- `tsconfig.json` with `strict`, `module` ES2022, `types: ["@sapui5/types", "@types/qunit"]`,
|
|
14
|
+
and `paths` mapping the app namespace (`"my/app/*": ["./webapp/*"]`) and the test
|
|
15
|
+
folders.
|
|
16
|
+
- `ui5.yaml`: the `ui5-tooling-transpile-task` (builder) and `-middleware` (server). Add to
|
|
17
|
+
existing `builder`/`server` sections; never duplicate them.
|
|
18
|
+
- A `"ts-typecheck": "tsc --noEmit"` script; run it after changes.
|
|
19
|
+
- To create a new app, the UI5 MCP tool `create_ui5_app` with `typescript: true` and the
|
|
20
|
+
CAP service URL produces this setup; use it for a task whose paths cover the new app.
|
|
21
|
+
|
|
22
|
+
## Code
|
|
23
|
+
|
|
24
|
+
- Standard ES classes with `export default class Main extends Controller`, and a JSDoc
|
|
25
|
+
`/** @namespace my.app.controller */` directly above each class: the build needs it to
|
|
26
|
+
register the UI5 class.
|
|
27
|
+
- ES `import` for every module, also for types (`import Button from "sap/m/Button"`); never
|
|
28
|
+
global names like `sap.m.Button` in type annotations. A dynamic load is `import(…)`.
|
|
29
|
+
- Event handlers use the control's event type: `onPress(event: Button$PressEvent)` from
|
|
30
|
+
`sap/m/Button`, `Route$PatternMatchedEvent` for routing (UI5 1.115 and later; before that
|
|
31
|
+
`sap/ui/base/Event`).
|
|
32
|
+
- Generic getters return base types: cast to the concrete type you know from the view or
|
|
33
|
+
manifest (`this.byId("form") as Form`, `this.getOwnerComponent() as AppComponent`,
|
|
34
|
+
`getModel() as ODataModel`). Never cast through `unknown`, never use `any`; if the type is
|
|
35
|
+
unclear, find it rather than guess.
|
|
36
|
+
- Shared type definitions go into one place (for example `webapp/types/`).
|
|
37
|
+
- Data comes through the OData V4 model declared in `manifest.json`, never through `fetch`
|
|
38
|
+
to the service. Navigation through the router and routes in `manifest.json`.
|
|
39
|
+
|
|
40
|
+
## Tests
|
|
41
|
+
|
|
42
|
+
- QUnit for logic and OPA5 for user journeys an AC needs, in TypeScript:
|
|
43
|
+
`import QUnit from "sap/ui/thirdparty/qunit-2"`; OPA page objects are classes extending
|
|
44
|
+
`Opa5` (no `createPageObjects`), instantiated before the tests, with arrangements, actions
|
|
45
|
+
and assertions as methods of the page (no `Given`/`When`/`Then` parameters).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Testing Fiori apps
|
|
2
|
+
|
|
3
|
+
Distilled from the SAPUI5 documentation (`SAP-docs/sapui5`, CC-BY-4.0) through the Fiori
|
|
4
|
+
MCP server and from the UI5 MCP server's guidelines (Apache-2.0), retrieved on
|
|
5
|
+
2026-10-17. Rules restated.
|
|
6
|
+
|
|
7
|
+
## What to test where
|
|
8
|
+
|
|
9
|
+
- Most ACs of a Fiori feature are about data and rules: test them in the **service**
|
|
10
|
+
(`cap-developer`, `cds.test`), which is faster and stable. That includes annotations whose
|
|
11
|
+
effect shows in `$metadata` or in the data (a filter, a value list, a computed field).
|
|
12
|
+
- Use a UI test only for behavior that exists only in the UI (navigation, a button that
|
|
13
|
+
appears in a state, a dialog). Name it with the AC id like any test.
|
|
14
|
+
- An AC that cannot be tested automatically in a reasonable way is `Verification: manual`
|
|
15
|
+
in the spec, decided at Spec time, not skipped in Build.
|
|
16
|
+
|
|
17
|
+
## Fiori elements (OData V4)
|
|
18
|
+
|
|
19
|
+
- OPA5 journeys with the `sap.fe.test` library: its page objects for list report and
|
|
20
|
+
object page (`JourneyRunner`, `onTheMainPage`, ...). The OData V2 library
|
|
21
|
+
(`sap/suite/ui/generic/template/integration/testLibrary`) is a different one; never mix
|
|
22
|
+
them.
|
|
23
|
+
- The Fiori MCP server's `search_docs` has a detailed guide for these journeys (query
|
|
24
|
+
"OPA5 integration tests for SAP Fiori elements"): read it before writing one.
|
|
25
|
+
|
|
26
|
+
## Freestyle (TypeScript)
|
|
27
|
+
|
|
28
|
+
- QUnit and OPA5 as in `freestyle-ts.md`: page objects as classes extending `Opa5`.
|
|
29
|
+
|
|
30
|
+
## After every UI change
|
|
31
|
+
|
|
32
|
+
- `run_ui5_linter` and `run_manifest_validation` (UI5 MCP server), then the tests.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# UI5 basics (Elements and freestyle)
|
|
2
|
+
|
|
3
|
+
Distilled from the UI5 MCP server's development guidelines (`get_guidelines`,
|
|
4
|
+
`@ui5/mcp-server` 0.3.2, Apache-2.0), retrieved on 2026-10-17. Rules restated.
|
|
5
|
+
|
|
6
|
+
## Modules and globals
|
|
7
|
+
|
|
8
|
+
- Never reach framework objects through globals (`sap.m.Button`, `sap.ui.getCore()`).
|
|
9
|
+
Declare every dependency so it loads asynchronously first: ES `import` in TypeScript,
|
|
10
|
+
`sap.ui.define` / `sap.ui.require` in JavaScript.
|
|
11
|
+
- In XML views, controls load from their tags; formatters and types used in bindings are
|
|
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
|
+
and `data-sap-ui-async="true"`. No inline `<script>` code: it breaks the content
|
|
15
|
+
security policy.
|
|
16
|
+
- Give the component container full height in `index.html`
|
|
17
|
+
(`html, body, body > div, #container, #container-uiarea { height: 100%; }`): a Fiori
|
|
18
|
+
elements app fills its parent and stays invisible in a container of height 0.
|
|
19
|
+
|
|
20
|
+
## Data and texts
|
|
21
|
+
|
|
22
|
+
- Bind controls to data and to the i18n model in the view; do not set texts or values
|
|
23
|
+
from code.
|
|
24
|
+
- Format with types and format options, not with custom formatters: prefer the OData
|
|
25
|
+
types (`sap.ui.model.odata.type.Decimal`, `.String`, `.DateTime`, ...), which work with
|
|
26
|
+
every model; use `sap.ui.model.type.*` only where no OData type exists. A formatter is
|
|
27
|
+
for business logic no type covers.
|
|
28
|
+
- A new or changed key in `i18n.properties` goes into **every** locale file of the app
|
|
29
|
+
(`i18n_de.properties`, ...).
|
|
30
|
+
|
|
31
|
+
## Forms
|
|
32
|
+
|
|
33
|
+
- Use `sap.ui.layout.form.Form` with a `ColumnLayout`, not `SimpleForm` (unless asked).
|
|
34
|
+
Default columns: 2 for M, 3 for L, 4 for XL screens.
|
|
35
|
+
|
|
36
|
+
## Inside a CAP project
|
|
37
|
+
|
|
38
|
+
- UI5 apps live in the CAP project's `app/` folder.
|
|
39
|
+
- Get services, entities and endpoints from the CDS tools (`search_model`), or from
|
|
40
|
+
`cds compile '*' --to serviceinfo` without them. Point the app at the absolute OData V4
|
|
41
|
+
service URL and its entity set.
|
|
42
|
+
- Serve everything with `cds watch` from the project root (with `cds-plugin-ui5` as a dev
|
|
43
|
+
dependency of the CAP project). Do not run `ui5 serve` in the app folder, and do not
|
|
44
|
+
configure a proxy middleware to the local CAP service: same origin, no proxy needed.
|
|
45
|
+
|
|
46
|
+
## Tools
|
|
47
|
+
|
|
48
|
+
- `get_api_reference` for any control or API, for the UI5 version of the project.
|
|
49
|
+
- `run_ui5_linter` after every change (deprecated APIs, accessibility, bugs); use its
|
|
50
|
+
`fix` option only after asking the user, then run it again.
|
|
51
|
+
- `run_manifest_validation` after every change to `manifest.json`.
|
|
52
|
+
- The UI5 tooling server serves no default file: open `…/index.html`, not `…/`.
|