agjan 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/docs/guide.md +39 -2
  2. package/kit/domains/btp/domain.json +4 -4
  3. package/kit/skills/agjan-build/SKILL.md +10 -6
  4. package/kit/skills/agjan-design/SKILL.md +36 -4
  5. package/kit/skills/agjan-fix/SKILL.md +11 -4
  6. package/kit/skills/agjan-map/SKILL.md +11 -4
  7. package/kit/skills/agjan-spec/SKILL.md +11 -4
  8. package/kit/skills/agjan-verify/SKILL.md +26 -6
  9. package/kit/skills/cap-developer/SKILL.md +10 -2
  10. package/kit/skills/cap-developer/references/handlers.md +11 -9
  11. package/kit/skills/cap-developer/references/project-setup.md +21 -8
  12. package/kit/skills/cap-developer/references/testing.md +38 -14
  13. package/kit/skills/cap-developer/references/typescript.md +143 -0
  14. package/kit/skills/cap-developer/references/validation-security.md +26 -8
  15. package/kit/skills/fiori-developer/SKILL.md +20 -5
  16. package/kit/skills/fiori-developer/references/app-setup.md +91 -16
  17. package/kit/skills/fiori-developer/references/elements.md +19 -5
  18. package/kit/skills/fiori-developer/references/freestyle-ts.md +5 -1
  19. package/kit/skills/fiori-developer/references/testing.md +109 -15
  20. package/kit/templates/agents-block.md +4 -0
  21. package/package.json +1 -1
  22. package/src/browser.mjs +49 -0
  23. package/src/cli.mjs +14 -4
  24. package/src/commands/branch.mjs +50 -15
  25. package/src/commands/check.mjs +17 -6
  26. package/src/commands/gates.mjs +12 -9
  27. package/src/commands/review.mjs +69 -4
  28. package/src/commands/setup.mjs +12 -2
  29. package/src/commands/status.mjs +13 -11
  30. package/src/commands/ui-test.mjs +38 -0
  31. package/src/review.mjs +9 -6
@@ -6,47 +6,71 @@ and the reference apps `capire/bookshop` and `capire/incidents-app` (Apache-2.0)
6
6
  examples were checked with `@sap/cds` 10.1 on 2026-10-18. Rules restated; check details
7
7
  with `search_docs`.
8
8
 
9
- ## Shape of a test file (ESM, `node --test`, checked with @sap/cds 10.1)
9
+ ## Shape of a test file (TypeScript, `node --test`, checked with @sap/cds 10.1)
10
10
 
11
- <!-- checked: test/leaves.test.js -->
12
- ```js
11
+ <!-- checked: test/leaves.test.ts -->
12
+ ```ts
13
13
  import cds from '@sap/cds'
14
14
  import { describe, it } from 'node:test'
15
15
  import assert from 'node:assert/strict'
16
16
 
17
17
  const { GET, POST, axios } = cds.test(import.meta.dirname + '/..')
18
18
  axios.defaults.validateStatus = () => true // assert on status codes, not exceptions
19
- const as = (user) => ({ auth: { username: user, password: user } })
19
+ const as = (user: string) => ({ auth: { username: user, password: user } })
20
20
  const ID = '7a1e0c1a-0001-4c2b-9a5f-000000000001' // a row from db/data, status New
21
+ const requests = '/odata/v4/leave/LeaveRequests'
22
+
23
+ // Draft-enabled: a new request is a draft first; the checks run when it is activated.
24
+ async function create(data: object, user: string) {
25
+ const draft = await POST(requests, data, as(user))
26
+ if (draft.status !== 201) return draft
27
+ return POST(`${requests}(ID=${draft.data.ID},IsActiveEntity=false)/LeaveService.draftActivate`, {}, as(user))
28
+ }
21
29
 
22
30
  describe('LeaveService', () => {
23
31
  it('TLR-AC1: employees see only their own requests', async () => {
24
- const { status, data } = await GET('/odata/v4/leave/LeaveRequests', as('employee'))
32
+ const { status, data } = await GET(`${requests}?$filter=IsActiveEntity eq true`, as('employee'))
25
33
  assert.equal(status, 200)
26
- assert.deepEqual(data.value.map((r) => r.employee_userId), ['employee'])
34
+ assert.deepEqual(data.value.map((r: { employee_userId: string }) => r.employee_userId), ['employee'])
27
35
  })
28
36
  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)
37
+ assert.equal((await GET(requests, as('nobody'))).status, 403)
38
+ assert.equal((await GET(requests)).status, 401)
39
+ assert.equal((await GET('/odata/v4/leave/LeaveTypes')).status, 401) // the service-level @requires
31
40
  })
32
41
  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'))
42
+ const { status, data } = await create({ startDate: '2026-11-10', endDate: '2026-11-01', type_code: 'vacation' }, 'employee')
35
43
  assert.equal(status, 400)
36
44
  assert.equal(data.error.code, 'ASSERT_END_BEFORE_START')
37
45
  })
38
46
  it('TLR-AC6: only a manager approves, and only once', async () => {
39
- const url = `/odata/v4/leave/LeaveRequests(${ID})/LeaveService.approve`
47
+ const url = `${requests}(ID=${ID},IsActiveEntity=true)/LeaveService.approve`
40
48
  assert.equal((await POST(url, {}, as('employee'))).status, 403)
41
49
  assert.equal((await POST(url, {}, as('manager'))).status, 204)
42
50
  assert.equal((await POST(url, {}, as('manager'))).status, 409)
43
51
  })
52
+ it('TLR-AC7: a manager of another team can neither approve nor reject', async () => {
53
+ const other = `${requests}(ID=7a1e0c1a-0001-4c2b-9a5f-000000000002,IsActiveEntity=true)/LeaveService`
54
+ assert.equal((await POST(`${other}.approve`, {}, as('manager2'))).status, 403)
55
+ assert.equal((await POST(`${other}.reject`, { reason: 'no' }, as('manager2'))).status, 403)
56
+ })
44
57
  })
45
58
  ```
46
59
 
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).
60
+ - A draft-enabled entity (the Fiori create flow, elements.md) is created in two steps:
61
+ `POST` makes a draft (201, no checks yet), `…(ID=…,IsActiveEntity=false)/<Service>.draftActivate`
62
+ saves it, and that is where `@assert`, `@mandatory` and `before CREATE` handlers answer
63
+ 400. Test the activation, not only the first `POST`. Active rows have the key
64
+ `(ID=…,IsActiveEntity=true)`; a list read returns drafts too unless you filter
65
+ `IsActiveEntity eq true`.
66
+ - Every `where` of an `@restrict` gets a test with a user of the role whom the condition
67
+ excludes (here `manager2`, a manager of another team), for every operation it guards,
68
+ including bound actions.
69
+ - TypeScript tests need TypeScript mode and the generated types before they run (the
70
+ `pretest` script and the preloaded `test/typescript.ts`; typescript.md). In a JavaScript
71
+ project the file is `.js` without the type annotations, run with `node --test`.
72
+ - Bound actions: `/<Entity>(<key>)/<Service>.<action>` (the incidents app's tests show
73
+ the whole draft choreography, including editing an active row).
50
74
  - `cds.test` keeps the console quiet during tests; write diagnostics to a file if needed.
51
75
 
52
76
  ## Rules
@@ -0,0 +1,143 @@
1
+ # TypeScript (CAP Node.js)
2
+
3
+ Distilled from the CAP documentation (capire: "Using TypeScript", "CDS Typer", Apache-2.0),
4
+ retrieved through the CAP MCP server on 2026-10-19, and checked on the example project
5
+ with `@sap/cds` 10.1.1, `@sap/cds-dk` 10.1.0, `@cap-js/cds-typer` 0.41, `@cap-js/cds-types`
6
+ 0.20 and TypeScript 7.0 on Node 24. Rules restated.
7
+
8
+ ## When
9
+
10
+ - **TypeScript is the default** for new projects and new code: the service handlers,
11
+ the tests, and the Fiori apps (fiori-developer).
12
+ - JavaScript only when the user or the spec asks for it explicitly, or when the existing
13
+ application is JavaScript (handlers in `srv/*.js`, no `tsconfig.json`): then stay in
14
+ JavaScript. Never convert an existing JavaScript application on your own; propose it
15
+ as a design decision instead.
16
+
17
+ ## Set it up
18
+
19
+ ```sh
20
+ cds init <name> --nodejs # or in the existing folder
21
+ cds add typescript # tsconfig.json, tsx, typescript, cds-types, cds-typer, .gitignore
22
+ npm install
23
+ ```
24
+
25
+ `cds add typescript` (cds-dk 10.1) is the start, but fix two things it writes:
26
+
27
+ 1. **Types for `@sap/cds`:** it maps `@sap/cds` in `paths` to the `@cap-js/cds-types`
28
+ folder. In an ESM project (`"type": "module"`) `tsc` cannot resolve that folder, and a
29
+ mapping to the `.d.ts` file breaks `cds watch` (tsx follows `paths` at run time). The
30
+ package declares the module itself, so remove the `@sap/cds` entry from `paths` and
31
+ load it as a type package instead: `"types": ["node", "@cap-js/cds-types"]`.
32
+ 2. **Excludes:** Fiori apps under `app/` have their own `tsconfig.json`; exclude them from
33
+ the root one, and keep `gen/` out.
34
+
35
+ Also raise `@cap-js/cds-types` to the current version (the facet writes `^0.18`).
36
+
37
+ <!-- checked: tsconfig.json -->
38
+ ```json
39
+ {
40
+ "compilerOptions": {
41
+ "target": "ESNext",
42
+ "module": "NodeNext",
43
+ "moduleResolution": "NodeNext",
44
+ "esModuleInterop": true,
45
+ "forceConsistentCasingInFileNames": true,
46
+ "strict": true,
47
+ "skipLibCheck": true,
48
+ "sourceMap": true,
49
+ "allowJs": true,
50
+ "types": ["node", "@cap-js/cds-types"],
51
+ "paths": {
52
+ "#cds-models/*": ["./@cds-models/*"]
53
+ }
54
+ },
55
+ "exclude": ["node_modules", "gen", "app"]
56
+ }
57
+ ```
58
+
59
+ `package.json` keeps the `imports` entry the facet adds (`"#cds-models/*":
60
+ "./@cds-models/*/index.js"`): the handlers import the generated classes at run time.
61
+
62
+ ## Generated types (cds-typer)
63
+
64
+ - `cds-typer` writes classes for every entity, type and action of the model into
65
+ `@cds-models/` (ignored by git, never edited, never committed). It runs before
66
+ `cds watch` and in `cds build`; for tests and type checks run it first:
67
+ `"pretest": "cds-typer \"*\""`.
68
+ - Import from `#cds-models/<Service>`: the singular class (`LeaveRequest`) is one row
69
+ and carries the bound actions, the plural (`LeaveRequests`) is the entity set for
70
+ handlers and queries.
71
+ - After a change to the CDS model, run `cds-typer "*"` (or keep `cds watch` running)
72
+ before type-checking.
73
+
74
+ ## A handler file
75
+
76
+ <!-- checked: srv/leave-service.ts -->
77
+ ```ts
78
+ import cds from '@sap/cds'
79
+ import { LeaveRequest, LeaveRequests } from '#cds-models/LeaveService'
80
+
81
+ export class LeaveService extends cds.ApplicationService { override init() {
82
+
83
+ this.before('CREATE', LeaveRequests, async req => {
84
+ const { startDate, endDate } = req.data // typed as LeaveRequest
85
+ req.data.employee_userId = req.user.id
86
+ …
87
+ })
88
+
89
+ this.on(LeaveRequest.actions.approve, async req => {
90
+ const [{ ID }] = req.params as { ID: string }[]
91
+ const n = await UPDATE(LeaveRequests, ID).where({ status_code: 'N' }).with({ status_code: 'A' })
92
+ if (!n) return req.reject(409, 'ONLY_NEW_REQUESTS')
93
+ })
94
+
95
+ return super.init()
96
+ }}
97
+ ```
98
+
99
+ - Pass the generated classes, not strings, to `before`/`on`/`after` and to `SELECT`,
100
+ `UPDATE`, …: then `req.data`, the action parameters (`req.data.reason`) and the results
101
+ are typed. Bound actions: `this.on(<Singular>.actions.<name>, …)`.
102
+ - Write handlers as arrow functions inside `init()`; a named function needs its type
103
+ (`req: cds.TypedRequest<LeaveRequest>`).
104
+ - `strict` stays on. No `any`, no `@ts-ignore`; `req.params` is untyped, so cast it to the
105
+ key shape.
106
+
107
+ ## Run, test, build
108
+
109
+ - `cds watch` detects `tsconfig.json` and runs the `.ts` files with tsx. Development only.
110
+ - Production: `cds build` compiles TypeScript with the `typescript` build task into
111
+ `gen/srv` (`.js` next to the CSN). Keep tests out of it with `tsconfig.cdsbuild.json`:
112
+
113
+ <!-- checked: tsconfig.cdsbuild.json -->
114
+ ```json
115
+ {
116
+ "extends": "./tsconfig.json",
117
+ "compilerOptions": { "outDir": "./gen/srv" },
118
+ "exclude": ["node_modules", "gen", "app", "test"]
119
+ }
120
+ ```
121
+
122
+ - Tests are `.ts` too, run by Node itself (type stripping, Node 22.18 or later). CAP
123
+ loads `.ts` service implementations only in TypeScript mode (`CDS_TYPESCRIPT`), which
124
+ must be set before `@sap/cds` loads: preload a setup file, and name the test files so
125
+ the runner does not take the setup for a test:
126
+
127
+ <!-- checked: test/typescript.ts -->
128
+ ```ts
129
+ process.env.CDS_TYPESCRIPT ??= 'true'
130
+ ```
131
+
132
+ <!-- checked: package.json -->
133
+ ```json
134
+ "scripts": {
135
+ "watch": "cds watch",
136
+ "pretest": "cds-typer \"*\"",
137
+ "test": "node --import ./test/typescript.ts --test \"test/**/*.test.ts\"",
138
+ "typecheck": "cds-typer \"*\" && tsc --noEmit && npm run typecheck --workspaces --if-present"
139
+ },
140
+ ```
141
+
142
+ - Run `npm run typecheck` with the tests: `tsc` finds what the tests do not reach. A test
143
+ that passes while `tsc` fails is not done.
@@ -77,6 +77,14 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
77
77
  user, anonymous requests included (CAP does not restrict services by default). Every
78
78
  entity and operation the spec's roles cover needs one, and tests for a user without
79
79
  the role (403) and an anonymous request (401).
80
+ - **Start every service with a service-level `@requires`** (the spec's roles, or
81
+ `'authenticated-user'`). Without it, every entity you did not restrict is open: code
82
+ lists, helper projections, and the entities CAP exposes on its own (composition
83
+ targets, entities marked `@cds.autoexpose`, the `.texts` of localized code lists).
84
+ Checked with `@sap/cds` 10.1: the example's `LeaveTypes` answered an anonymous `GET`
85
+ with 200 until the service had `@requires`. List what a service really exposes with
86
+ `cds compile srv --to csn` (auto-exposed entities carry `@cds.autoexposed`) and give
87
+ each a rule.
80
88
  - `@requires: 'Role'` (or a list, meaning any of them) on a service, entity or
81
89
  operation. Pseudo roles: `authenticated-user`, `system-user`, `any`. A service with
82
90
  `@requires` also protects its `$metadata` and service root.
@@ -89,9 +97,14 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
89
97
  - `$user.<attribute>` is a list of values: a condition is true if any value matches; an
90
98
  empty or missing attribute grants **nothing**.
91
99
  - `where` conditions are enforced against stored data: pushed into the query for `READ`,
92
- checked before `UPDATE`/`DELETE`. For `CREATE`, unbound operations and operations on
93
- collections, only simple comparisons of user attributes with literals
94
- (`$user.level >= 2`) can be checked.
100
+ checked before `UPDATE`/`DELETE` and before bound actions on one instance (checked with
101
+ `@sap/cds` 10.1: a manager of another team gets 403 for `approve` and `reject`). For
102
+ `CREATE`, unbound operations and operations on collections, only simple comparisons of
103
+ user attributes with literals (`$user.level >= 2`) can be checked.
104
+ - **Prove every `where` with a test**: a user who has the role but whom the condition
105
+ excludes (a manager of another team), for each operation the rule grants, bound actions
106
+ included. If that test fails for a condition the runtime cannot check, check it in the
107
+ handler (`req.reject(403)`) and keep the test.
95
108
  - `$metadata` does not apply `@restrict`; do not rely on hiding entities there.
96
109
  - Responses: no or wrong login 401; logged in without a matching role 403; a `where`
97
110
  condition that excludes a row makes it invisible (404 for a single read).
@@ -100,11 +113,16 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
100
113
 
101
114
  <!-- checked: srv/leave-service.cds -->
102
115
  ```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 { … };
116
+ @requires: ['employee', 'manager'] // the baseline: nothing in the service is open
117
+ service LeaveService {
118
+ @restrict: [
119
+ { grant: ['READ', 'CREATE'], to: 'employee', where: 'employee_userId = $user' },
120
+ { grant: ['READ', 'approve', 'reject'], to: 'manager', where: 'employee.team.manager = $user' }
121
+ ]
122
+ @odata.draft.enabled // Fiori elements creates and edits through drafts
123
+ entity LeaveRequests as projection on my.LeaveRequests { … };
124
+ …
125
+ }
108
126
  ```
109
127
 
110
128
  - Project configuration goes into the `cds` section of `package.json`, where `cds init`
@@ -44,6 +44,18 @@ Decide `app_type` in `design.md` with reason and alternative:
44
44
  - `freestyle` (TypeScript): the UX cannot be expressed with Fiori elements floorplans,
45
45
  building blocks and extensions (custom interaction, unusual flows). More code to own.
46
46
 
47
+ **Language: TypeScript by default**, for both types: a new app is generated in TypeScript
48
+ (`enableTypeScript: true` for `generate_fiori_app_cap`, `typescript: true` for
49
+ `create_ui5_app`; the choice cannot be changed after generation). JavaScript only when the
50
+ user or the spec asks for it explicitly, or when the app you change is JavaScript
51
+ (`Component.js`, no `tsconfig.json`): then stay in JavaScript and never convert it on your
52
+ own.
53
+
54
+ **Create or edit means draft.** An elements app whose ACs create or change records needs
55
+ a draft-enabled entity (`@odata.draft.enabled`); without it the list report offers no
56
+ Create. Decide "no draft" only for read-only apps or apps that change data only through
57
+ actions (`references/elements.md`, Drafts).
58
+
47
59
  Existing applications are never re-decided: `sap.fe.templates` in `manifest.json` means
48
60
  elements. Extend an elements app with annotations first, then `manifest.json` settings,
49
61
  then building blocks or custom sections and columns, and controller extensions last.
@@ -53,17 +65,20 @@ then building blocks or custom sections and columns, and controller extensions l
53
65
  | The task touches | Read |
54
66
  |---|---|
55
67
  | any UI5 code, views, i18n, `index.html`, CAP integration | `references/ui5-basics.md` |
56
- | a new elements app: its files, `manifest.json`, `index.html`, serving and checking it | `references/app-setup.md` |
68
+ | a new elements app: its files, TypeScript setup, `manifest.json`, `index.html`, serving and checking it | `references/app-setup.md` |
57
69
  | an elements app (annotations, pages, value help, actions, side effects) | `references/elements.md` |
58
70
  | a freestyle TypeScript app | `references/freestyle-ts.md` |
59
- | UI tests | `references/testing.md` |
71
+ | UI tests (Playwright, optional; OPA5 in apps that have it) | `references/testing.md` |
60
72
 
61
73
  ## Both types
62
74
 
63
75
  - The service comes first: the UI is built against the finished CAP service, and most ACs
64
- are tested in the service.
76
+ are tested in the service. What a user does on a page (create, choose an action) gets a
77
+ UI test too (`references/testing.md`).
65
78
  - Authorization lives in the service, never in the UI; the UI only hides what the service
66
79
  already forbids.
67
80
  - Texts in i18n files, in every locale the app has.
68
- - After a change: `npx agjan lint`, `run_manifest_validation` (if `manifest.json` changed
69
- and the Fiori MCP server is available), the tests, then `npx agjan check`.
81
+ - After a change: `npx agjan lint`, `npm run typecheck` in a TypeScript app,
82
+ `run_manifest_validation` (if `manifest.json` changed and the Fiori MCP server is
83
+ available), the tests, `npx agjan ui-test` (skipped, with the reason, where no browser
84
+ can start), then `npx agjan check`.
@@ -1,9 +1,12 @@
1
1
  # A Fiori elements app inside a CAP project
2
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.
3
+ Distilled from the reference apps `capire/incidents-app` and `capire/bookshop` (Apache-2.0),
4
+ the UI5 MCP server's guidelines (Apache-2.0), and the TypeScript app the Fiori MCP server's
5
+ generator (`generate_fiori_app_cap` with `enableTypeScript: true`, generator-fiori 1.33)
6
+ writes. The files below were checked on 2026-10-18 (`run_manifest_validation` valid,
7
+ `run_ui5_linter` without findings, the app used in a browser) and in TypeScript on
8
+ 2026-10-19 (`tsc` clean, UI5 linter without findings, served and transpiled by
9
+ `cds watch`). Rules restated.
7
10
 
8
11
  To create an app, the Fiori MCP server's generator (or SAP Fiori tools) can produce it;
9
12
  these are the files it must end up with, and the minimum to write by hand.
@@ -11,20 +14,77 @@ these are the files it must end up with, and the minimum to write by hand.
11
14
  ## Files
12
15
 
13
16
  ```text
17
+ package.json devDependency cds-plugin-ui5, "workspaces": ["app/*"]
14
18
  app/
15
19
  services.cds using from './requests/annotations';
16
20
  requests/
17
21
  annotations.cds UI annotations (references/elements.md)
18
- ui5.yaml specVersion "4.0", name leaves.requests, type application
22
+ package.json the app's TypeScript and UI5 tooling dev dependencies
23
+ tsconfig.json
24
+ ui5.yaml name leaves.requests, the transpile middleware and task
19
25
  webapp/
20
26
  manifest.json
21
- Component.js
27
+ Component.ts
22
28
  index.html
23
29
  i18n/i18n.properties appTitle=Leave requests
24
30
  ```
25
31
 
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).
32
+ `cds watch` serves it through `cds-plugin-ui5` at
33
+ `http://localhost:4004/leaves.requests/index.html` (the app id from `ui5.yaml`; there is
34
+ no default file), and transpiles the TypeScript on the fly. A JavaScript app without the
35
+ plugin is served as static files at `/requests/webapp/index.html`.
36
+
37
+ ## TypeScript setup
38
+
39
+ The generator writes this setup; the minimum by hand is:
40
+
41
+ - Root `package.json`: `cds-plugin-ui5` as a dev dependency (it runs each app's UI5
42
+ tooling, including the transpiler, inside `cds watch`) and `"workspaces": ["app/*"]`.
43
+ - The app's `package.json`, with `@sapui5/types` in the version of the app's
44
+ `minUI5Version`:
45
+
46
+ <!-- checked: app/requests/package.json -->
47
+ ```json
48
+ "devDependencies": {
49
+ "@sapui5/types": "~1.136.0",
50
+ "@ui5/cli": "^4",
51
+ "typescript": "^5.9.3",
52
+ "ui5-tooling-transpile": "^3"
53
+ },
54
+ "scripts": {
55
+ "typecheck": "tsc --noEmit"
56
+ }
57
+ ```
58
+
59
+ - `tsconfig.json` of the app: `strict`, `rootDir` `./webapp`, `paths` mapping the app id
60
+ as a path (`"leaves/requests/*": ["./webapp/*"]`), and `typeRoots` with
61
+ `@sapui5/types` in the app's and the root's `node_modules`. The app keeps the
62
+ TypeScript version the generator chose (its `tsconfig.json` uses options that
63
+ TypeScript 7 removed); the root project has its own.
64
+ - `ui5.yaml`: the transpile middleware (for `cds watch`) and task (for `ui5 build`):
65
+
66
+ <!-- checked: app/requests/ui5.yaml -->
67
+ ```yaml
68
+ server:
69
+ customMiddleware:
70
+ - name: ui5-tooling-transpile-middleware
71
+ afterMiddleware: compression
72
+ configuration:
73
+ transformModulesToUI5:
74
+ overridesToOverride: true
75
+ builder:
76
+ customTasks:
77
+ - name: ui5-tooling-transpile-task
78
+ afterTask: replaceVersion
79
+ configuration:
80
+ transformModulesToUI5:
81
+ overridesToOverride: true
82
+ ```
83
+
84
+ - The generator also adds Fiori tools middlewares (proxy, preview, reload), eslint and
85
+ generated OPA journeys under `webapp/test/`: keep them when it wrote them, do not add
86
+ them by hand for the app to run. It writes `manifest.json` with `_version` 1.86: raise
87
+ it to 2.0.0 as below, or the linter fails.
28
88
 
29
89
  ## manifest.json (Manifest Version 2)
30
90
 
@@ -77,15 +137,27 @@ name under `app/`, then `webapp/index.html`; there is no default file).
77
137
  - `dataSources.mainService.uri` is the service's path (`/odata/v4/<service path>/`).
78
138
  - `contextPath` names the entity set; the object page route's pattern uses its name.
79
139
 
80
- ## Component.js
140
+ ## Component.ts
81
141
 
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
- }));
142
+ <!-- checked: app/requests/webapp/Component.ts -->
143
+ ```ts
144
+ import AppComponent from "sap/fe/core/AppComponent";
145
+
146
+ /**
147
+ * @namespace leaves.requests
148
+ */
149
+ export default class Component extends AppComponent {
150
+ public static metadata = {
151
+ manifest: "json"
152
+ };
153
+ }
87
154
  ```
88
155
 
156
+ - The `@namespace` comment (the app id) is required: the transpiler registers the class
157
+ under it. In a JavaScript app the file is `Component.js`:
158
+ `sap.ui.define(['sap/fe/core/AppComponent'], (AppComponent) =>
159
+ AppComponent.extend('leaves.requests.Component', { metadata: { manifest: 'json' } }))`.
160
+
89
161
  ## index.html
90
162
 
91
163
  <!-- checked: app/requests/webapp/index.html -->
@@ -123,5 +195,8 @@ sap.ui.define(['sap/fe/core/AppComponent'], (AppComponent) => AppComponent.exten
123
195
 
124
196
  1. `npx agjan lint` (the UI5 linter on the app's changed files) and, with the Fiori MCP
125
197
  server, `run_manifest_validation` on `webapp/manifest.json`: 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.
198
+ 2. `npm run typecheck` (in a TypeScript app): no errors.
199
+ 3. `npx agjan ui-test`: the UI tests try what the ACs describe as each role
200
+ (`testing.md`). Where it skips them (no browser here), open the app with
201
+ `npx cds watch` as each role of the spec (a private window per user) and try it,
202
+ including buttons and messages, or tell the user it was not tried.
@@ -175,8 +175,22 @@ annotate service.LeaveRequests actions {
175
175
  The labels (`{i18n>…}`) are in the project's `_i18n/i18n.properties`, not in the app's
176
176
  `webapp/i18n`, which holds only the app's own texts (its title).
177
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).
178
+ ## Drafts: required to create or edit
179
+
180
+ **An elements app in which users create or edit records needs a draft-enabled entity.**
181
+ The draft is how Fiori elements on OData V4 creates and edits with CAP: without it the
182
+ list report offers no Create, and `creationMode` settings do not bring it back (seen in a
183
+ trial). Never decide "no draft" for an app whose ACs create or change records through the
184
+ UI; "simpler" or "editing is out of scope" are not reasons when creating is in scope.
185
+ Without a draft remain only read-only apps, and apps that change data only through
186
+ actions (approve, reject).
187
+
188
+ - Enable it in the service, on the entity the app creates, as the example does
189
+ (`@odata.draft.enabled` on `LeaveRequests` in `srv/leave-service.cds`), or in the app's
190
+ annotations file (`annotate service.Incidents with @odata.draft.enabled;`, as the
191
+ incidents app does).
192
+ - What changes: keys include `IsActiveEntity`; `POST` creates a draft and
193
+ `draftActivate` saves it, which is when `@assert`, `@mandatory` and `before CREATE`
194
+ handlers run. `@restrict` grants (`CREATE`, `UPDATE`) apply to the draft events too.
195
+ Tests follow the draft flow (`cap-developer`, testing).
196
+ - Side effects (above) need a draft as well.
@@ -17,7 +17,11 @@ Distilled from the UI5 MCP server's guidelines (`get_guidelines`,
17
17
  existing `builder`/`server` sections; never duplicate them.
18
18
  - A `"ts-typecheck": "tsc --noEmit"` script; run it after changes.
19
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.
20
+ CAP service URL (or the Fiori MCP server's `generate_fiori_app_cap` with floorplan
21
+ `FF_SIMPLE` and `enableTypeScript: true`) produces this setup; use it for a task whose
22
+ paths cover the new app.
23
+ - Inside a CAP project, `cds watch` serves and transpiles the app through `cds-plugin-ui5`
24
+ (app-setup.md, TypeScript setup).
21
25
 
22
26
  ## Code
23
27