All notable changes to this project will be documented in this file.
- properly handle
.textsproperties in combination withcompat_texts_entities=false(default in cds10) during runtime.
- emit
kindproperty on events as static member to be properly consumed bycds-types. - do not cut off leading namespaces from top-level events, but only leading service names from events nested therein.
- Events with dotted names (e.g.
service S { event X.Y : {...} }) now generate a properly namespaced classnamespace X { class Y }instead of producing duplicate top-level identifiers. - Event names now use the service-relative name (e.g.
'X.Y'without preceedingS), matching the name the CDS runtime uses when registering and emitting such events. - Entity elements of named struct types used within CDS aspects are now correctly flattened when using
--inlineDeclarations flat.
output_d_ts_filesnow defaults totrueand emits proper ambient.d.tsdeclaration files instead of merely renaming.tsoutput files. Plain.tsfiles are treated as source by TypeScript and other build tools, which caused them to be compiled and their.jsoutput to silently overwrite the runtime module exports generated by cds-typer. Projects with stricttsconfig.jsonsettings will benefit from this change, as.d.tsfiles do not require special handling incds buildor development scripts. Set tofalseto restore the old behaviour.
- Entities with name conflicts with any of their ancestors now have their aspect name generated properly again
- Fixed sporadic
[Object object]appearing in log output
- Properly import entities from other services that are used in arrays/ compositions of many/ associations to many
- Added flag
cds.env.typer.branded_primitive_typesfor branding CDStypedefinitions aliasing primitive TS types - Added support for non-ASCII identifiers in .cds files. Non-ASCII characters in identifiers are sanitised to valid TypeScript names. Identifiers consisting entirely of non-ASCII characters (e.g., Kanji) are replaced with random hashes. All affected identifiers are exported under their sanitised/hashed name and also as an alias preserving the original name. To use the original name, import it with
import ... as '...'syntax.
- Association keys pointing to entities with inline enum types are now correctly typed in service projections across namespace boundaries
- Added (experimental) flag
cds.env.typer.output_d_ts_filesfor generating output*.d.tsfiles instead of*.tsones
- unbound actions will now assume the
selftype ofnever, instead of the formernull - events will now have a static field
kind: 'event', akin to the one in entities
- Added declare statement on type definitions
- Explicitly add an
any[]type in generated boilerplate to avoid issues withnoImplicitAny - Entities included via
cds importnow have their properties properly generated
- targeting aspects in compositions now properly resolves them.
- transitive references to property types of other entities now also work for enums.
- action parameters annotated with
@mandatoryare no longer nullable - base definitions now properly import the default export of
@sap/cds
- Using
cds.Mapas type will no longer result in the property not being printed at all.
- Improved performance of repeated
cds-typerruns by introducing an option to cache CDS model between runs. By default, typer will only regenerate the files if the model has changed between runs, usingblake2s256as algorithm. The used version of cds-typer is included in the hash and will therefore be version-specific.
- [breaking] The config
use_entities_proxy(allowing for static imports) is now set totrueas default. You can set it tofalseto revert to the old behaviour. - Running
cds watchwill triggercds-typer "*"before the initial startup
- Enums are now exported in ESM style in ESM projects
- Support new
cds.Maptype, which is emitted as{[key:string]: unknown}. The most appropriate type would in fact be{[key:string]: any}, which would also allow any and all keys. But would also cause issues with strict project configurations. Therefore, to effectively usecds.Map, users will have to cast theunknowns to the effective type they expect. - Introduce
cds.env.typer.build_taskto allow disabling thetypescriptbuild task shipped with cds-typer by setting it tofalse
- [breaking] The types
cds.Binaryandcds.LargeBinaryare now generated asBufferandReadablerespectively to reflect the behaviour of the new database packages@cap-js/hanaand@cap-js/sqlite. You can switch back to the old behaviour by addinglegacy_binary_types: trueto your project configuration. CHANGELOG.mdandLICENSEfiles are no longer part of the npm package.
- default value for
inline_declarationsin help command - entity scope and namespace are now added in the correct order to inflected type names
- dedicated classes for inline compositions
- dedicated text-classes for entities with
localizedelements
- prefixed builtin types like
PromiseandRecordwithglobalThis., to allow using names of builtin types for entities without collisions - default export class representing the service itself is now exported without name
- bumped peer-dependency to
@cap-js/cds-typesto>=0.9
- referencing another entity's property of type
cds.Stringin an enum will now properly quote the generated values
- type-referencing a property that is a key no longer breaks the referring property
- when targeting ESM, all imports within the generated types now add a
/index.js-suffix to conform to modern module resolution mechanisms - leaving
target_module_typeat'auto'now properly acts on a detected"type":"module"
- cds aspects now generate a synthetic plural type too, to be used in
composition of many
- [breaking] when running cds-typer in a CAP project, the default for the
outputDirectoryoption will be./@cds-modelsinstead of./. This default takes the lowest precedence after setting it in the project'scds.env, or explicitly as CLI argument.
- cds-typer no longer ignores the selected
outputDirectory, which would also cause an issue during build
- [breaking] cds-typer now tries to automatically detect whether it has to generate ESM or CommonJS in the emitted index.js files. This behaviour can be overridden via the
--targetModuleTypeoption. If you rely on these generated index.js files to be CJS despite your project being of ESM type, you need to manually tell cds-typer to generate CJS files!
- The static
.keysproperty now properly reels in key types from inherited classes.
cds buildno longer fails on Windows with anEINVALerror.cds buildalso supports custom model paths intsconfig.jsonthat do not end with/index.ts. This is the case for projects running withtsx.
- Schema definition for
cds.typeroptions inpackage.jsonand.cdsrc-*.jsonfiles - Added a static
elementsproperty to all entities, which allows access to theLinkedDefinitionsinstance of an entity's elements - Schema definition for
typescriptcds build task. .draftsproperty of any entityEis 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 overridemodifier on.kindproperty is now only generated if the property is actually inherited, satisfying stricttsconfig.jsons- Properly support mandatory (
not null) action parameters witharray oftypes - Static property
.draftsis 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 nullin CDS/CDL, ornotNullin 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
.keysproperty in all entities. That property is dictionary which holds all properties as keys that are marked askeyin CDS - Added a CLI option
--useEntitiesProxy. When set totrue, all entities are wrapped intoProxyobjects during runtime, allowing top level imports of entity types. - Added a static
.kindproperty for entities and types, which contains'entity'or'type'respectively - Apps need to provide
@sap/cdsversion8.2or higher. - Apps need to provide
@cap-js/cds-typesversion0.6.4or 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
declaremodifier to pass strict tsconfigs usinguseDefineForClassFieldsornoImplicitOverride - The static
actionsproperty 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 buildno 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_singularattached 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.logand pipes output into thecds-typerlogger, which can be configured viacds.envin addition to explicitly passing a--logLevelparameter to CLI. Users now have to use the levels defined incds.log.levels. The formerly valid levelsWARNING,CRITICAL, andNONEare 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
IEEE754Compatibleflag 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 buildTypeScript projects. Can be explicitly called usingcds build --for typescript
- Types representing CDS events are now only
declared to avoid having to make their properties optional - Singular forms in generated index.js files now contain a
.is_singularproperty 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
typersection 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
.kindproperty which holds the string'function'or'action'respectively - Added the
CdsDate,CdsDateTime,CdsTime,CdsTimestamptypes, which are each represented as astring. - Plural types can now also contain an optional numeric
$countproperty
- Empty
.actionsproperties 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
typeofreferences 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.commonas erroneous during type creation
- Support for
cds.Vector, which will be represented asstring
- Resolving
@sap/cdswill 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
typedefinitions 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
typedefinitions 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
typeofsyntax would crash the type generation
- Changed default log level from
NONEtoERROR. 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
excludingclause in projections now actually excludes the specified properties in the generated types
- Generate
cds.LargeBinaryas string, buffer, or readable in the case of media content
- Added support for the
not nullmodifier
- 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
.nameproperty - 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 ofon a property they have inherited from another entity - Fixed an error during draftability propagation when defining compositions on types that are declared inline
compileFromCSNis no longer part of the package's API
- Actions and functions are now attached to a static
.actionsproperty of each generated class. This reflects the runtime behaviour better than the former way of generating instance methods
- Support for drafts via
@odata.draft.enabledannotation
- 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
@singularand@pluralnames are now properly used in generated index.js files
- Support for
[many] $selfsyntax 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
eventsyntax
- Initialise bound actions with stubs to support
"strict":truein tsconfig.json - Add leading underscore to appease
noUnusedParametersin strict tsconfigs - No longer inflect
typedefinitions when they are referenced within entities or other type definitions
- Facilitate strict property checks. Note:
checkJs: truemust be present in the project's jsconfig.json or tsconfig.json respectively for this feature to become effective
- Support for
array ofsyntax
- Generate
stringtype for date-related types in CDS definitions - Generate
Buffer | stringtype for the CDS typeLargeBinary
- Support for enums when they are defined separately (not inline in the property type of an entity)
- Support
functiondefinitions (apart fromactions)
- Bump version to next minor
- Properly import CDS
typedefinitions when they are referenced elsewhere
- Bump version
- Enable use of annotated singular/ plural names in associations/ compositions
- Rename package from
@sap/cds-dts-generatorto@cap-js/cds-typer
- Add missing library files
- Make class hierarchy flatter
- Add missing files
- use native Typescript AST in unit tests
- add
propertiesOptionalflag - support flat, as well as nested inline declarations
- support
typeofsyntax - 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