@cap-js/cds-typer 0.2.5-beta.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,11 +4,20 @@ All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
6
6
 
7
+ ## Version 0.3.1 - TBD
8
+
9
+ ## Version 0.3.0 - 2023-06-26
10
+ ### Added
11
+ - Support `function` definitions (apart from `action`s)
12
+ ### Changed
13
+ - Bump version to next minor
14
+
15
+ ### Fixed
16
+ - Properly import CDS `type` definitions when they are referenced elsewhere
7
17
 
8
18
  ## Version 0.2.5-beta.1 - 2023-06-13
9
19
 
10
20
  ### Changed
11
-
12
21
  - Bump version
13
22
 
14
23
  ## Version 0.2.4 - 2023-06-12
package/README.md CHANGED
@@ -6,16 +6,12 @@ Generates `.ts` files for a CDS model to receive code completion in VS Code.
6
6
 
7
7
 
8
8
  ## Requirements and Setup
9
-
10
-
11
- ### Building the Project Yourself
12
- Clone the repository and install the dependencies running `npm i` from the project's root directory.
13
-
9
+ This project is [available as `@cds-js/cds-typer`](https://www.npmjs.com/package/@cap-js/cds-typer) as NPM package.
14
10
 
15
11
  ### Usage
16
- The type generator is currently meant as a standalone tool and can be installed and used independently of other CDS environments (sans its dependency to the cds compiler).
12
+ The type generator can either be used as a standalone tool, or as part of of the [CDS VSCode-Extension](https://www.npmjs.com/package/@sap/vscode-cds).
17
13
 
18
- #### Quickstart
14
+ #### Standalone CLI
19
15
  Assuming you have the following CDS project structure:
20
16
 
21
17
  ```
@@ -30,38 +26,29 @@ Assuming you have the following CDS project structure:
30
26
  a typical workflow to generate types for your CDS project could look something like this:
31
27
 
32
28
  ```sh
33
- git clone https://this/repo cds-js-type-generator
34
- cd cds-js-type-generator
35
- npm i
36
- node ./index.js \
37
- --rootDir /home/mybookshop/@types \
38
- --jsConfigPath /home/mybookshop \
39
- /home/mybookshop/srv/schema.cds
29
+ npx @cap-js/cds-typer /home/mybookshop/db/schema.cds --outputDirectory /home/mybookshop/@types
40
30
  ```
41
31
 
42
- You would then end up with a `jsconfig.json` file in the project's root and a directory `@types`, which contains your entities and their accompanying types in a directory structure. The directory structure directly reflects the namespaces you have defined your entities in. They have to be imported in any JavaScript-based service handlers you want to have type support in and can replace calls to `cds.entities(...)`:
32
+ You would then end up with a directory `@types`, which contains your entities and their accompanying types in a directory structure. The directory structure directly reflects the namespaces you have defined your entities in. They have to be imported in any JavaScript-based service handlers you want to have type support in and can replace calls to `cds.entities(...)`:
43
33
 
44
34
  ```js
45
35
  // srv/service.js
46
36
  const { Books } = require('my.bookshop')
47
-
48
37
  ```
49
38
 
50
39
  becomes
51
40
 
52
41
  ```js
53
42
  // srv/service.js
54
-
55
43
  const { Books } = require('../@types/mybookshop')
56
44
  ```
57
45
 
58
46
  From that point on you should receive code completion from the type system for `Books`.
59
47
 
60
- #### CLI
61
48
  _cds-typer_ comes with rudimentary CLI support and a few command line options:
62
49
 
63
50
  - `--help`: prints all available parameters.
64
- - `--rootDir`: specifies the root directory where all generated files should be put. Defaults to the CWD.
51
+ - `--outputDirectory`: specifies the root directory where all generated files should be put. Defaults to the CWD.
65
52
  - `--jsConfigPath`: specifies the path to the `jsconfig.json` file to generate. Usually your project's root directory. If specified, a config file is created that restricts the usage of types even further:
66
53
 
67
54
  ```js
@@ -93,11 +80,13 @@ NONE
93
80
  The utility expects (at least) one path to a `.cds` file as positional parameter which serves as entry point to the model in question, e.g.:
94
81
 
95
82
  ```sh
96
- cds-typer ./path/to/my/model/model.cds --rootDir /tmp/
83
+ npx @cap-js/cds-typer ./path/to/my/model/model.cds --outputDirectory /tmp/
97
84
  ```
98
85
 
99
86
  Note that you can also pass multiple paths or `"*"` as glob pattern (with quotes to circumvent expansion by the shell). This passes the pattern on to the compiler where the [regular resolve strategy](https://cap.cloud.sap/docs/node.js/cds-compile?q=compiler#cds-resolve) is used.
100
87
 
88
+ #### From VSCode
89
+ Installing the [CDS VSCode Extension](https://www.npmjs.com/package/@sap/vscode-cds) also adds support for generating types for your model from within VSCode. Adding the appropriate facet to your project via `cds add typer` (and installing the added dependencies thereafter) allows you to simply hit save on any `.cds` file that is part of your model to trigger the generation process.
101
90
  #### Programmatically
102
91
  The main API for using _cds-typer_ within another project is contained in [`compile.js`](https://github.tools.sap/cap/cds-typer/blob/master/lib/compile.js), specifically:
103
92
 
@@ -181,7 +170,7 @@ _cds-typer_ tries to keep its dependency footprint as small as possible. Librari
181
170
 
182
171
  ## Support, Feedback, Contributing
183
172
 
184
- This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/SAP/cds-dts-generator/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
173
+ This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/cds-typer/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
185
174
 
186
175
  ## Code of Conduct
187
176