Skip to content

Commit

Permalink
Merge branch 'main' into chore/refactor-ql
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady authored Oct 7, 2024
2 parents b4111bc + 9571d15 commit 67273e3
Show file tree
Hide file tree
Showing 12 changed files with 373 additions and 222 deletions.
16 changes: 13 additions & 3 deletions .github/rollup-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ function _getImports (src) {
if (what.includes('{')) {
destructured.push({
package: from.trim(),
properties: what.replace('{','').replace('}','').split(',').map(p => p.trim())
properties: what
.replace('{','')
.replace('}','')
.split(',')
.map(p => {
const tokens = p.trim().split(' as ')
return {
property: tokens[0],
alias: tokens[1] ?? tokens[0]
}
})
})
} else {
named.push({
Expand Down Expand Up @@ -63,8 +73,8 @@ function replaceImports (src) {
// v
// x: import('foo').bar
for (const { package, properties } of destructured) {
for (const prop of properties) {
lines = lines.map(l => replace(l, re(prop), `import('${package}').${prop}`))
for (const { alias, property } of properties) {
lines = lines.map(l => replace(l, re(alias), `import('${package}').${property}`))
}
}
return lines.join('\n')
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 0.6.6 - TBD
## Version 0.7.0 - tbd

### Added
- `cds.app` typed as express.js application
- `cds.cli` CLI arguments
- `cds.requires` types for MTX services
- `cds.utils.colors` types
- The CQL methods `.where` and `.having` now suggest property names for certain overloads.

### Changed
- Most `cds.requires` entries are now optionals.
- `cds.connect.to` now also supports using a precompiled model.
- Properties of entities are no longer optional in projections, eliminating the need to perform optional chaining on them when using nested projections

## Version 0.6.5 - 2024-08-13
Expand Down
36 changes: 32 additions & 4 deletions apis/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const env: {
folders: string[],
[key: string]: any,
},
profiles: string[],
requires: env.Requires,
folders: {
app: string,
Expand Down Expand Up @@ -64,23 +65,50 @@ export namespace env {
binding?: Binding,
[key: string]: any,
},
multitenancy: boolean | { kind: string, jobs: {
multitenancy?: boolean | { kind: string, jobs: {
clusterSize: number,
workerSize: number,
t0: string,
[key: string]: any,
},},
toggles: boolean,
extensibility: boolean | {
toggles?: boolean,
extensibility?: boolean | {
model: string[],
tenantCheckInterval: number,
[key: string]: any,
},
messaging: {
messaging?: {
kind: 'file-based-messaging' | 'redis-messaging' | 'local-messaging' | 'enterprise-messaging' | 'enterprise-messaging-shared' | string,
format: 'cloudevents' | string,
[key: string]: any,
},
'cds.xt.SaasProvisioningService'?: {
model: string,
kind: string,
alwaysUpgradeModel?: boolean,
[key: string]: any,
},
'cds.xt.SmsProvisioningService'?: {
model: string,
kind: string,
[key: string]: any,
},
'cds.xt.ExtensibilityService'?: {
model: string,
kind?: string,
[key: string]: any,
},
'cds.xt.ModelProviderService'?: {
model: string,
root: string,
kind?: string,
[key: string]: any,
},
'cds.xt.DeploymentService'?: {
model: string,
kind?: string,
[key: string]: any,
},
[key: string]: any,
}

Expand Down
13 changes: 13 additions & 0 deletions apis/facade.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,18 @@ export const version: string
export const home: string
export const root: string

type CliCommands = 'add' | 'build' | 'compile' | 'deploy' | 'import' | 'init' | 'serve' | (string & {})
/**
* The parsed effective `cds` CLI command and arguments.
* May be undefined if not started from the `cds` CLI.
* @see https://cap.cloud.sap/docs/node.js/cds-facade#cds-cli
*/
export const cli: {
/** Basic command like `serve` */ command?: CliCommands,
/** Positional arguments */ argv?: string[],
/** Named arguments */ options?: Record<string, any>,
} | undefined


import { env } from './env'
export const requires: env.Requires
9 changes: 8 additions & 1 deletion apis/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ interface cds_connect_options {
impl?: string
service?: string
kind?: string
model?: string
model?: string | CSN
credentials?: object
}

Expand All @@ -163,3 +163,10 @@ type Middleswares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
export const middlewares: {
add: (middleware: RequestHandler, pos?: XOR<XOR<{ at: number }, { after: Middleswares }>, { before: Middleswares }>) => void,
}

/**
* The {@link https://expressjs.com/en/4x/api.html#app| express.js application} constructed by the server implementation.
*
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-server#cds-app)
*/
export const app: Application
55 changes: 54 additions & 1 deletion apis/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as fs from 'node:fs'

/**
* Provides a set of utility functionss
* Provides a set of utility functions
*/
declare const utils: {

Expand Down Expand Up @@ -87,4 +87,57 @@ declare const utils: {
* @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rm-path
*/
rm: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,

/**
* @since 8.3.0
* @see https://cap.cloud.sap/docs/node.js/cds-utils#colors
*/
colors: {
enabled: boolean,
RESET: '\x1b[0m',
BOLD: '\x1b[1m' | '',
BRIGHT: '\x1b[1m' | '',
DIMMED: '\x1b[2m' | '',
ITALIC: '\x1b[3m' | '',
UNDER: '\x1b[4m' | '',
BLINK: '\x1b[5m' | '',
FLASH: '\x1b[6m' | '',
INVERT: '\x1b[7m' | '',
BLACK: '\x1b[30m' | '',
RED: '\x1b[31m' | '',
GREEN: '\x1b[32m' | '',
YELLOW: '\x1b[33m' | '',
BLUE: '\x1b[34m' | '',
PINK: '\x1b[35m' | '',
CYAN: '\x1b[36m' | '',
LIGHT_GRAY: '\x1b[37m' | '',
DEFAULT: '\x1b[39m' | '',
GRAY: '\x1b[90m' | '',
LIGHT_RED: '\x1b[91m' | '',
LIGHT_GREEN: '\x1b[92m' | '',
LIGHT_YELLOW: '\x1b[93m' | '',
LIGHT_BLUE: '\x1b[94m' | '',
LIGHT_PINK: '\x1b[95m' | '',
LIGHT_CYAN: '\x1b[96m' | '',
WHITE: '\x1b[97m' | '',
bg: {
BLACK: '\x1b[40m' | '',
RED: '\x1b[41m' | '',
GREEN: '\x1b[42m' | '',
YELLOW: '\x1b[43m' | '',
BLUE: '\x1b[44m' | '',
PINK: '\x1b[45m' | '',
CYAN: '\x1b[46m' | '',
WHITE: '\x1b[47m' | '',
DEFAULT: '\x1b[49m' | '',
LIGHT_GRAY: '\x1b[100m' | '',
LIGHT_RED: '\x1b[101m' | '',
LIGHT_GREEN: '\x1b[102m' | '',
LIGHT_YELLOW: '\x1b[103m' | '',
LIGHT_BLUE: '\x1b[104m' | '',
LIGHT_PINK: '\x1b[105m' | '',
LIGHT_CYAN: '\x1b[106m' | '',
LIGHT_WHITE: '\x1b[107m' | '',
},
},
}
Loading

0 comments on commit 67273e3

Please sign in to comment.