All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning. The format is based on Keep a Changelog.
cds build
no longer fails on Windows with anEINVAL
error.cds build
also supports custom model paths intsconfig.json
that do not end with/index.ts
. This is the case for projects running withtsx
.
- Schema definition for
cds.typer
options inpackage.json
and.cdsrc-*.json
files - Added a static
elements
property to all entities, which allows access to theLinkedDefinitions
instance of an entity's elements - Schema definition for
typescript
cds build task. .drafts
property of any entityE
is now of typeDraftOf<E>
, orDraftsOf<E>
for plurals, respectively. This type exposes dditional properties that are available on drafts during runtime.
- Entity elements of named structured types are flattened when using the option
--inlineDeclarations flat
override
modifier on.kind
property is now only generated if the property is actually inherited, satisfying stricttsconfig.json
s- Properly support mandatory (
not null
) action parameters witharray of
types - Static property
.drafts
is only create for entity classes that are actually draft enabled
- Any configuration variable (via CLI or
cds.env
) can now be passed in snake_case in addition to camelCase - Action parameters are now generated as optional by default, which is how the runtime treats them. Mandatory parameters have to be marked as
not null
in CDS/CDL, ornotNull
in CSN.
- Fix build task for projects with spaces
- Fix a bug where cds-typer would produce redundant type declarations when the model contains an associations to another entity's property
- Reintroduce default value
'.'
for--outputDirectory
- Added a static
.keys
property in all entities. That property is dictionary which holds all properties as keys that are marked askey
in CDS - Added a CLI option
--useEntitiesProxy
. When set totrue
, all entities are wrapped intoProxy
objects during runtime, allowing top level imports of entity types. - Added a static
.kind
property for entities and types, which contains'entity'
or'type'
respectively - Apps need to provide
@sap/cds
version8.2
or higher. - Apps need to provide
@cap-js/cds-types
version0.6.4
or higher. - Typed methods are now generated for calls of unbound actions. Named and positional call styles are supported, e.g.
service.action({one, two})
andservice.action(one, two)
. - Action parameters can be optional in the named call style (
service.action({one:1, ...})
). - Actions for ABAP RFC modules cannot be called with positional parameters, but only with named ones. They have 'parameter categories' (import/export/changing/tables) that cannot be called in a flat order.
- Services now have their own export (named like the service itself). The current default export is not usable in some scenarios from CommonJS modules.
- Enums and operation parameters can have doc comments
- Declaring a type alias on an enum in cds now also exports it on value level in the resulting type
- Classes representing views and projections will no longer carry ancestry to avoid clashes thereof with aliases fields
- All properties are now preceeded with the
declare
modifier to pass strict tsconfigs usinguseDefineForClassFields
ornoImplicitOverride
- The static
actions
property of generated classes now includes the types from all inherited classes to also suggest actions defined in a base entity/aspect/type.
- Suppressed an error that would incorrectly point out naming clashes when an entity was named in singular inflection in the model
- CDS aspects now also generate a aspect-function in singular inflection, similar to how entities do
- Aspects generate named classes again so that tooltips will show more meaningful provenance for properties
- The TypeScript task for
cds build
no longer looks for tsconfig.json to determine if the project has TS nature and instead checks the dependencies in the project's package.json for an occurrence oftypescript
- Plurals no longer have
is_singular
attached in the resulting .js files - Properties are properly propagated beyond just one level of inheritance
- Fixed a bug where keys would sometimes inconsistently become nullable
- Logging now internally uses
cds.log
and pipes output into thecds-typer
logger, which can be configured viacds.env
in addition to explicitly passing a--logLevel
parameter to CLI. Users now have to use the levels defined incds.log.levels
. The formerly valid levelsWARNING
,CRITICAL
, andNONE
are now deprecated and automatically mapped to valid levels for now.
- The typescript build task will no longer attempt to run unless at least cds 8 is installed
- Added missing cds-plugin.js to exported files to properly enable calling
cds build --for typescript
- Added
IEEE754Compatible
flag which, when set totrue
, generates decimal fields as(number | string)
instead ofnumber
. This flag will be removed in the long run - Added plugin to
cds build
TypeScript projects. Can be explicitly called usingcds build --for typescript
- Types representing CDS events are now only
declare
d to avoid having to make their properties optional - Singular forms in generated index.js files now contain a
.is_singular
property as marker for distinguished handling of singular and plural in the runtime - Parameters passed to the CLI now take precedence over configuration contained in the
typer
section ofcds.env
- Entities ending with an "s" are no longer incorrectly truncated within
extends
-clauses - Entity names prefixed with their own namespace (e.g.
Name.Name
,Name.NameAttachments
) are not stripped of their name prefix
- Referring to a property's type in a function/ action parameter no longer refers to the enclosing entity
- Void actions no longer crash the type generation process
- Types for actions and functions now expose a
.kind
property which holds the string'function'
or'action'
respectively - Added the
CdsDate
,CdsDateTime
,CdsTime
,CdsTimestamp
types, which are each represented as astring
. - Plural types can now also contain an optional numeric
$count
property
- Empty
.actions
properties and operations without parameters are now typed asRecord<never, never>
to make it clear they contain nothing and also to satisfy overzealous linters
- Composition of aspects now properly resolve implicit
typeof
references in their properties - Importing an enum into a service will now generate an alias to the original enum, instead of incorrectly duplicating the definition
- Returning entities from actions/ functions and using them as parameters will now properly use the singular inflection instead of returning an array thereof
- Aspects are now consistently named and called in their singular form
- Only detect inflection clash if singular and plural share the same namespace. This also no longer reports
sap.common
as erroneous during type creation
- Support for
cds.Vector
, which will be represented asstring
- Resolving
@sap/cds
will now look in the CWD first to ensure a consistent use the same CDS version across different setups - Types of function parameters starting with
cds.
are not automatically considered builtin anymore and receive a more thorough check against an allow-list
- Remove faulty plural for CDS
type
definitions from the generated index.js files
- Improved support for projections, including projections on inline definitions, and on views, as well as support for explicit exclusion and selection of properties
- [breaking] CDS
type
definitions will not be inflected. Whatever inflection you define them in will be assumed treated as a singular form and will not receive a plural form anymore
- Fixed a bug where refering to an externally defined enum via the
typeof
syntax would crash the type generation
- Changed default log level from
NONE
toERROR
. See the doc to manually pass in another log level for cds-typer runs - Name collisions between automatically generated foreign key fields (
.…_ID
,.…_code
, etc.) with explicitly named fields will now raise an error - Generate CDS types that are actually structured types as if they were entities. This allows the correct representation of mixing aspects and types in CDS inheritance, and also fixes issues with inline enums in such types
- Externally defined enums can now be used as parameter types in actions
- Support for scoped entities
- Support for delimited identifiers
- Inline enums are now available during runtime as well
- Inline enums can now be used as action parameter types as well. These enums will not have a runtime representation, but will only assert type safety!
- Arrays of inline enum values can now be used as action parameters too. But they will only be represented by their enclosing type for now, i.e.
string
,number
, etc. - Foreign keys of projection entities are now propagated as well
- Entities that are database views now also receive typings
- Enums are now generated ecplicitly in the respective index.js files and don't have to extract their values from the model at runtime anymore
- The
excluding
clause in projections now actually excludes the specified properties in the generated types
- Generate
cds.LargeBinary
as string, buffer, or readable in the case of media content
- Added support for the
not null
modifier
- Now using names of enum values in generated index.js files if no explicit value is present
- Fixed how service names are exported as default export
- Autoexposed entities in services are now also generated
- Each generated class now contains their original fully qualified name in a static
.name
property - Inline enums that are defined as literal type of properties are now supported as well (note: this feature is experimental. The location to which enums are generated might change in the future!)
- Fixed an error when an entity uses
type of
on a property they have inherited from another entity - Fixed an error during draftability propagation when defining compositions on types that are declared inline
compileFromCSN
is no longer part of the package's API
- Actions and functions are now attached to a static
.actions
property of each generated class. This reflects the runtime behaviour better than the former way of generating instance methods
- Support for drafts via
@odata.draft.enabled
annotation
- Foreign keys are now propagated more than one level (think:
x_ID_ID_ID
)
- Foreign keys that are inherited via aspects are now also generated in addition to the resolved property (see 0.7.0)
- Explicitly annotated
@singular
and@plural
names are now properly used in generated index.js files
- Support for
[many] $self
syntax in bound action parameters - Foreign keys are now present in the generated types in addition to the resolved property
- Removed a warning about circular imports
- Support for
event
syntax
- Initialise bound actions with stubs to support
"strict":true
in tsconfig.json - Add leading underscore to appease
noUnusedParameters
in strict tsconfigs - No longer inflect
type
definitions when they are referenced within entities or other type definitions
- Facilitate strict property checks. Note:
checkJs: true
must be present in the project's jsconfig.json or tsconfig.json respectively for this feature to become effective
- Support for
array of
syntax
- Generate
string
type for date-related types in CDS definitions - Generate
Buffer | string
type for the CDS typeLargeBinary
- Support for enums when they are defined separately (not inline in the property type of an entity)
- Support
function
definitions (apart fromaction
s)
- Bump version to next minor
- Properly import CDS
type
definitions when they are referenced elsewhere
- Bump version
- Enable use of annotated singular/ plural names in associations/ compositions
- Rename package from
@sap/cds-dts-generator
to@cap-js/cds-typer
- Add missing library files
- Make class hierarchy flatter
- Add missing files
- use native Typescript AST in unit tests
- add
propertiesOptional
flag - support flat, as well as nested inline declarations
- support
typeof
syntax - read rudimentary configuration from cds.env
- export bound and unbound actions
- allow inline type definitions within compositions
- enable use of additional type libraries (HANA types available as first library)
- provide proper JSDoc for all modules
- export entity types for singular variants alongside plural types
- add TL;DR section to README
- allow multiple positional arguments
- initial code base