@cap-js/postgres 1.3.0 → 1.3.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 +4 -0
- package/cds-plugin.js +1 -1
- package/lib/build.js +54 -0
- package/lib/func.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
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
|
+
### Version 1.3.1 - 2023-10-10
|
|
8
|
+
|
|
9
|
+
- `cds build`-relevant files are now correctly packaged into the release. #266
|
|
10
|
+
|
|
7
11
|
### Version 1.3.0 - 2023-10-06
|
|
8
12
|
|
|
9
13
|
### Added
|
package/cds-plugin.js
CHANGED
package/lib/build.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const cds = require('@sap/cds')
|
|
2
|
+
|
|
3
|
+
let BuildPlugin
|
|
4
|
+
try {
|
|
5
|
+
({ BuildPlugin } = require('@sap/cds-dk/lib/build'))
|
|
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 }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
init() {
|
|
23
|
+
this.task.dest = cds.env.build.target === '.' ? path.join('gen','pg') : path.join('gen', 'pg')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async clean() {
|
|
27
|
+
await rimraf(this.task.dest)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async build() {
|
|
31
|
+
const model = await this.model()
|
|
32
|
+
if (!model) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const promises = []
|
|
37
|
+
promises.push(this.write({
|
|
38
|
+
dependencies: { '@sap/cds': '^7', '@cap-js/postgres': '^1' },
|
|
39
|
+
scripts: { start: 'cds-deploy' },
|
|
40
|
+
}).to('package.json'))
|
|
41
|
+
promises.push(this.write(cds.compile.to.json(model)).to(path.join('db', 'csn.json')))
|
|
42
|
+
|
|
43
|
+
let data
|
|
44
|
+
if (fs.existsSync(path.join(this.task.src, 'data'))) {
|
|
45
|
+
data = 'data'
|
|
46
|
+
} else if (fs.existsSync(path.join(this.task.src, 'csv'))) {
|
|
47
|
+
data = 'csv'
|
|
48
|
+
}
|
|
49
|
+
if (data) {
|
|
50
|
+
promises.push(this.copy(data).to(path.join('db', 'data')))
|
|
51
|
+
}
|
|
52
|
+
return Promise.all(promises)
|
|
53
|
+
}
|
|
54
|
+
}
|
package/lib/func.js
CHANGED
|
@@ -2,7 +2,7 @@ const session = require('./session.json')
|
|
|
2
2
|
|
|
3
3
|
const StandardFunctions = {
|
|
4
4
|
session_context: x => {
|
|
5
|
-
let sql = `current_setting('${
|
|
5
|
+
let sql = `current_setting('${session[x.val] || x.val}')`
|
|
6
6
|
if (x.val === '$now') sql += '::timestamp'
|
|
7
7
|
return sql
|
|
8
8
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/postgres",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.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": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"start": "docker-compose -f pg-stack.yml up -d"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@cap-js/db-service": "^1.3.
|
|
34
|
+
"@cap-js/db-service": "^1.3.1",
|
|
35
35
|
"pg": "^8"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|