Skip to content

Commit

Permalink
Move minify to compile.ts (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady authored Oct 24, 2024
1 parent fc93c8e commit 51c6f24
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions apis/compile.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { CSN } from './csn'

/**
* Minifies a given CSN model by removing all unused1 types and aspects, as well all entities tagged with `@cds.persistence.skip:'if-unused'`
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-compile#cds-minify)
*/
export function minify (model: CSN): CSN
1 change: 1 addition & 0 deletions apis/facade.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './events'
export * from './utils'
export * from './cqn'
export * from './global'
export * from './compile'
export { log, debug } from './log'
export { test } from './test'

Expand Down
8 changes: 1 addition & 7 deletions apis/models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ export namespace linked {
*/
export function reflect (model: csn.CSN): ln.LinkedCSN

/**
* Minifies a given CSN model by removing all unused1 types and aspects, as well all entities tagged with `@cds.persistence.skip:'if-unused'`
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-compile#cds-minify)
*/
export function minify (model: csn.CSN): csn.CSN

/**
* Provides a set of methods to parse a given model, query or expression.
* You can also use `cds.compile(csn).to('<output>')` as a fluent variant.
Expand All @@ -219,7 +213,7 @@ export const compile: {
for: {
odata (model: csn.CSN, o?: _options): csn.CSN,
sql (model: csn.CSN, o?: _options): csn.CSN,
nodejs (mode: csn.CSN, o?: _options): csn.CSN,
nodejs (model: csn.CSN, o?: _options): linked.LinkedCSN,
},
to: {
parsed: {
Expand Down
1 change: 1 addition & 0 deletions apis/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const serve: (service: string, options?: {
[key: string]: any,
}) => Promise<cds_services> & cds_serve_fluent


/**
* Emitted whenever a model is loaded using cds.load().
*/
Expand Down
3 changes: 3 additions & 0 deletions test/typescript/apis/project/cds-compile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import cds from '@sap/cds'

cds.minify({})
4 changes: 3 additions & 1 deletion test/typescript/apis/project/cds-linked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,6 @@ cds.linked.classes.Association === cds.linked.classes.event
// but make sure we can still call .linked(CSN)
const ln: LinkedCSN = cds.linked({})

const ln2: LinkedCSN | undefined = cds.context?.model
const ln2: LinkedCSN | undefined = cds.context?.model

cds.minify({})

0 comments on commit 51c6f24

Please sign in to comment.