@cap-js/postgres 1.3.1 → 1.4.1
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 +24 -3
- package/README.md +5 -2
- package/cds-plugin.js +6 -4
- package/lib/build.js +17 -29
- package/lib/func.js +10 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
3
|
- All notable changes to this project are documented in this file.
|
|
4
4
|
- The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## [1.4.1](https://github.com/cap-js/cds-dbs/compare/postgres-v1.4.0...postgres-v1.4.1) (2023-11-24)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
* `cds build` now generates the correct output folder structure for Node.js and Java apps. ([#353](https://github.com/cap-js/cds-dbs/issues/353)) ([875aca4](https://github.com/cap-js/cds-dbs/commit/875aca4f5a0ee71bcfbb13be47d4349970b40605))
|
|
13
|
+
|
|
14
|
+
## [1.4.0](https://github.com/cap-js/cds-dbs/compare/postgres-v1.3.1...postgres-v1.4.0) (2023-11-20)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
* adapt build plugin implementation to new API ([#319](https://github.com/cap-js/cds-dbs/issues/319)) ([aec9966](https://github.com/cap-js/cds-dbs/commit/aec9966e54cd9900f85fe7406cbe38ec5c6fa4b9))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
* align time function behavior ([#322](https://github.com/cap-js/cds-dbs/issues/322)) ([c3ab40a](https://github.com/cap-js/cds-dbs/commit/c3ab40a007c105465349dd2f612178367b8e713a))
|
|
25
|
+
|
|
26
|
+
## [1.3.1](https://github.com/cap-js/cds-dbs/compare/v1.3.0...v1.3.1) (2023-10-10)
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
8
29
|
|
|
9
30
|
- `cds build`-relevant files are now correctly packaged into the release. #266
|
|
10
31
|
|
|
11
|
-
|
|
32
|
+
## Version 1.3.0 - 2023-10-06
|
|
12
33
|
|
|
13
34
|
### Added
|
|
14
35
|
|
package/README.md
CHANGED
|
@@ -6,14 +6,12 @@ Welcome to the new Postgres database service for [SAP Cloud Application Programm
|
|
|
6
6
|
|
|
7
7
|
In general, all you need to do is to install one of the database packages, as follows:
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
```sh
|
|
11
10
|
npm add @cap-js/postgres
|
|
12
11
|
```
|
|
13
12
|
|
|
14
13
|
Learn more about setup and usage in the [respective database guide](https://cap.cloud.sap/docs/guides/databases-postgres).
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
## Support
|
|
18
16
|
|
|
19
17
|
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/cds-dbs/issues).
|
|
@@ -22,6 +20,11 @@ This project is open to feature requests/suggestions, bug reports etc. via [GitH
|
|
|
22
20
|
|
|
23
21
|
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).
|
|
24
22
|
|
|
23
|
+
## Versioning
|
|
24
|
+
|
|
25
|
+
This library follows [Semantic Versioning](https://semver.org/).
|
|
26
|
+
All notable changes are documented in [CHANGELOG.md](CHANGELOG.md).
|
|
27
|
+
|
|
25
28
|
## Code of Conduct
|
|
26
29
|
|
|
27
30
|
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.
|
package/cds-plugin.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
const cds = require('@sap/cds
|
|
1
|
+
const cds = require('@sap/cds')
|
|
2
2
|
|
|
3
3
|
if (!cds.env.fiori.lean_draft) {
|
|
4
4
|
throw new Error('"@cap-js/postgres" only works if cds.fiori.lean_draft is enabled. Please adapt your configuration.')
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// requires @sap/cds-dk version >= 7.3.2
|
|
8
|
+
cds.build?.register?.('postgres', {
|
|
9
|
+
impl: '@cap-js/postgres/lib/build.js',
|
|
10
|
+
taskDefaults: { src: cds.env.folders.db }
|
|
11
|
+
})
|
package/lib/build.js
CHANGED
|
@@ -1,43 +1,31 @@
|
|
|
1
1
|
const cds = require('@sap/cds')
|
|
2
|
+
const { fs, path } = cds.utils
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} catch (e) {
|
|
7
|
-
if (e.code === 'ENOTFOUND') throw `No build plugin mechanism for @sap/cds-dk found. Please install @sap/cds-dk for development using 'npm i -D @sap/cds-dk@^7.3.0'`
|
|
8
|
-
else throw e
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { fs, path, rimraf } = cds.utils
|
|
12
|
-
|
|
13
|
-
module.exports = class PostgresBuildPlugin extends BuildPlugin {
|
|
14
|
-
static hasTask() { // REVISIT: should be unnecessary -> plugin mechanism knows what to pull
|
|
15
|
-
return cds.requires.db.kind === 'postgres'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static getTaskDefaults() {
|
|
19
|
-
return { src: cds.env.folders.db }
|
|
4
|
+
module.exports = class PostgresBuildPlugin extends cds.build.BuildPlugin {
|
|
5
|
+
static hasTask() {
|
|
6
|
+
return cds.requires.db?.kind === 'postgres'
|
|
20
7
|
}
|
|
21
8
|
|
|
22
9
|
init() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
async clean() {
|
|
27
|
-
await rimraf(this.task.dest)
|
|
10
|
+
// different from the default build output structure
|
|
11
|
+
this.task.dest = path.join(cds.root, cds.env.build.target !== '.' ? cds.env.build.target : 'gen', 'pg')
|
|
28
12
|
}
|
|
29
13
|
|
|
30
14
|
async build() {
|
|
31
15
|
const model = await this.model()
|
|
32
|
-
if (!model)
|
|
33
|
-
return
|
|
34
|
-
}
|
|
16
|
+
if (!model) return
|
|
35
17
|
|
|
36
18
|
const promises = []
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
if (fs.existsSync(path.join(this.task.src, 'package.json'))) {
|
|
20
|
+
promises.push(this.copy(path.join(this.task.src, 'package.json')).to('package.json'))
|
|
21
|
+
} else {
|
|
22
|
+
promises.push(
|
|
23
|
+
this.write({
|
|
24
|
+
dependencies: { '@sap/cds': '^7', '@cap-js/postgres': '^1' },
|
|
25
|
+
scripts: { start: 'cds-deploy' },
|
|
26
|
+
}).to('package.json'),
|
|
27
|
+
)
|
|
28
|
+
}
|
|
41
29
|
promises.push(this.write(cds.compile.to.json(model)).to(path.join('db', 'csn.json')))
|
|
42
30
|
|
|
43
31
|
let data
|
package/lib/func.js
CHANGED
|
@@ -13,14 +13,18 @@ const StandardFunctions = {
|
|
|
13
13
|
endswith: (x, y) => `substr(${x},length(${x}) + 1 - length(${y})) = ${y}`,
|
|
14
14
|
|
|
15
15
|
// Date and Time Functions
|
|
16
|
-
year: x => `date_part('year',
|
|
17
|
-
month: x => `date_part('month',
|
|
18
|
-
day: x => `date_part('day',
|
|
19
|
-
hour: x => `date_part('hour',
|
|
20
|
-
minute: x => `date_part('minute',
|
|
21
|
-
second: x => `date_part('second',
|
|
16
|
+
year: x => `date_part('year', ${castVal(x)})`,
|
|
17
|
+
month: x => `date_part('month', ${castVal(x)})`,
|
|
18
|
+
day: x => `date_part('day', ${castVal(x)})`,
|
|
19
|
+
hour: x => `date_part('hour', ${castVal(x)})`,
|
|
20
|
+
minute: x => `date_part('minute', ${castVal(x)})`,
|
|
21
|
+
second: x => `date_part('second', ${castVal(x)})`,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const isTime = /^\d{1,2}:\d{1,2}:\d{1,2}$/
|
|
25
|
+
const isVal = x => x && 'val' in x
|
|
26
|
+
const castVal = (x) => `${x}${isVal(x) ? isTime.test(x.val) ? '::TIME' : '::TIMESTAMP' : ''}`
|
|
27
|
+
|
|
24
28
|
const HANAFunctions = {
|
|
25
29
|
// https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/f12b86a6284c4aeeb449e57eb5dd3ebd.html
|
|
26
30
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/postgres",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "CDS database service for Postgres",
|
|
5
5
|
"homepage": "https://github.com/cap-js/cds-dbs/tree/main/postgres#cds-database-service-for-postgres",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@sap/cds-dk": ">=7"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
|
-
"cds-dk": {
|
|
42
|
+
"@sap/cds-dk": {
|
|
43
43
|
"optional": true
|
|
44
44
|
}
|
|
45
45
|
},
|