@sap/cds 6.8.3 → 7.0.0
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 +61 -2
- package/README.md +0 -1
- package/bin/cds-serve.js +50 -3
- package/bin/deploy/to-hana.js +1 -0
- package/bin/serve.js +16 -20
- package/lib/auth/basic-auth.js +6 -4
- package/lib/auth/index.js +4 -3
- package/lib/auth/jwt-auth.js +2 -5
- package/lib/compile/cds-compile.js +34 -89
- package/lib/compile/cdsc.js +11 -0
- package/lib/compile/etc/properties.js +2 -2
- package/lib/compile/for/lean_drafts.js +36 -69
- package/lib/compile/for/nodejs.js +2 -1
- package/lib/compile/load.js +1 -1
- package/lib/compile/minify.js +2 -0
- package/lib/compile/to/csn.js +74 -0
- package/{bin/build/provider/hana/2tabledata.js → lib/compile/to/hdbtabledata.js} +4 -6
- package/lib/compile/to/json.js +1 -1
- package/lib/compile/to/sql.js +8 -6
- package/lib/dbs/cds-deploy.js +174 -114
- package/lib/env/cds-env.js +64 -79
- package/lib/env/cds-requires.js +11 -28
- package/lib/env/defaults.js +13 -3
- package/lib/env/plugins.js +1 -12
- package/lib/env/presets.js +25 -21
- package/lib/index.js +121 -147
- package/lib/{core/reflect.js → linked/models.js} +2 -2
- package/lib/{core/infer.js → linked/queries.js} +2 -0
- package/lib/{core/index.js → linked/types.js} +2 -1
- package/lib/log/cds-error.js +13 -7
- package/lib/log/format/cf.js +1 -1
- package/lib/plugins.js +49 -0
- package/lib/ql/Query.js +0 -9
- package/lib/ql/STREAM.js +0 -1
- package/lib/req/context.js +2 -7
- package/lib/req/request.js +6 -2
- package/lib/req/response.js +23 -10
- package/lib/srv/middlewares/ctx-model.js +1 -1
- package/lib/srv/middlewares/errors.js +1 -1
- package/lib/srv/protocols/_legacy.js +1 -0
- package/lib/srv/protocols/graphql.js +7 -16
- package/lib/srv/protocols/index.js +59 -45
- package/lib/srv/protocols/odata-v2-proxy.js +2 -70
- package/lib/srv/srv-api.js +9 -3
- package/lib/srv/srv-dispatch.js +12 -9
- package/lib/srv/srv-models.js +4 -21
- package/lib/srv/srv-tx.js +15 -12
- package/lib/utils/cds-test.js +14 -9
- package/lib/utils/cds-utils.js +2 -12
- package/lib/utils/check-version.js +17 -0
- package/{bin/build → lib/utils}/csv-reader.js +23 -24
- package/libx/_runtime/auth/index.js +27 -23
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +15 -72
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +0 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +33 -63
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +14 -18
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +15 -5
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +5 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +37 -40
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/updateToCQN.js +7 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/utils.js +101 -38
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/AbstractError.js +5 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/ValueConverter.js +2 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +9 -8
- package/libx/_runtime/cds-services/adapter/odata-v4/to.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +15 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/readAfterWrite.js +4 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +5 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +1 -123
- package/libx/_runtime/cds-services/services/Service.js +79 -107
- package/libx/_runtime/cds-services/services/utils/columns.js +23 -19
- package/libx/_runtime/cds-services/services/utils/compareJson.js +11 -1
- package/libx/_runtime/cds-services/services/utils/differ.js +7 -2
- package/libx/_runtime/cds-services/util/assert.js +65 -2
- package/libx/_runtime/common/composition/data.js +1 -0
- package/libx/_runtime/common/generic/auth/expand.js +1 -1
- package/libx/_runtime/common/generic/auth/restrict.js +5 -10
- package/libx/_runtime/common/generic/auth/restrictions.js +40 -0
- package/libx/_runtime/common/generic/auth/utils.js +1 -2
- package/libx/_runtime/common/generic/crud.js +32 -16
- package/libx/_runtime/common/generic/etag.js +133 -104
- package/libx/_runtime/common/generic/input.js +6 -21
- package/libx/_runtime/common/generic/put.js +1 -1
- package/libx/_runtime/common/generic/stream.js +52 -0
- package/libx/_runtime/common/generic/temporal.js +25 -8
- package/libx/_runtime/common/i18n/messages.properties +0 -2
- package/libx/_runtime/common/utils/cqn.js +1 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +5 -2
- package/libx/_runtime/common/utils/csn.js +0 -51
- package/libx/_runtime/common/utils/etag.js +30 -0
- package/libx/_runtime/common/utils/keys.js +1 -1
- package/libx/_runtime/common/utils/normalizeTimestamp.js +25 -0
- package/libx/_runtime/common/utils/path.js +1 -1
- package/libx/_runtime/common/utils/resolveView.js +2 -1
- package/libx/_runtime/common/utils/rewriteAsterisks.js +6 -4
- package/libx/_runtime/common/utils/search2cqn4sql.js +12 -16
- package/libx/_runtime/common/utils/stream.js +140 -0
- package/libx/_runtime/common/utils/streamProp.js +29 -12
- package/libx/_runtime/common/utils/templateProcessorPathSerializer.js +0 -2
- package/libx/_runtime/db/generic/index.js +0 -2
- package/libx/_runtime/db/query/delete.js +2 -2
- package/libx/_runtime/db/query/insert.js +2 -2
- package/libx/_runtime/db/query/read.js +2 -2
- package/libx/_runtime/db/query/run.js +2 -2
- package/libx/_runtime/db/query/update.js +2 -2
- package/libx/_runtime/db/sql-builder/BaseBuilder.js +0 -6
- package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +23 -12
- package/libx/_runtime/db/sql-builder/FunctionBuilder.js +18 -6
- package/libx/_runtime/db/sql-builder/InsertBuilder.js +1 -0
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +3 -7
- package/libx/_runtime/db/sql-builder/UpsertBuilder.js +1 -0
- package/libx/_runtime/db/utils/normalizeTimeData.js +7 -3
- package/libx/_runtime/fiori/draft.js +2 -0
- package/libx/_runtime/fiori/generic/activate.js +8 -9
- package/libx/_runtime/fiori/generic/before.js +30 -20
- package/libx/_runtime/fiori/generic/cancel.js +5 -3
- package/libx/_runtime/fiori/generic/delete.js +5 -3
- package/libx/_runtime/fiori/generic/edit.js +7 -7
- package/libx/_runtime/fiori/generic/index.js +10 -16
- package/libx/_runtime/fiori/generic/new.js +5 -3
- package/libx/_runtime/fiori/generic/patch.js +11 -8
- package/libx/_runtime/fiori/generic/prepare.js +13 -6
- package/libx/_runtime/fiori/generic/read.js +12 -6
- package/libx/_runtime/fiori/lean-draft.js +207 -152
- package/libx/_runtime/fiori/utils/delete.js +10 -5
- package/libx/_runtime/fiori/utils/req.js +17 -5
- package/libx/_runtime/fiori/utils/stream.js +36 -0
- package/libx/_runtime/hana/Service.js +12 -9
- package/libx/_runtime/hana/conversion.js +10 -15
- package/libx/_runtime/hana/driver.js +2 -0
- package/libx/_runtime/hana/execute.js +28 -6
- package/libx/_runtime/hana/pool.js +36 -122
- package/libx/_runtime/hana/search2cqn4sql.js +34 -36
- package/libx/_runtime/messaging/enterprise-messaging-utils/getTenantInfo.js +2 -6
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +3 -1
- package/libx/_runtime/messaging/enterprise-messaging.js +10 -58
- package/libx/_runtime/messaging/outbox/utils.js +1 -1
- package/libx/_runtime/remote/Service.js +20 -1
- package/libx/_runtime/remote/utils/client.js +3 -5
- package/libx/_runtime/sqlite/Service.js +4 -6
- package/libx/_runtime/sqlite/conversion.js +3 -13
- package/libx/_runtime/sqlite/customBuilder/CustomFunctionBuilder.js +9 -6
- package/libx/_runtime/sqlite/customBuilder/CustomUpsertBuilder.js +6 -1
- package/libx/_runtime/sqlite/execute.js +5 -16
- package/libx/odata/afterburner.js +22 -6
- package/libx/odata/grammar.pegjs +6 -1
- package/libx/odata/parser.js +1 -1
- package/libx/rest/RestAdapter.js +16 -9
- package/libx/rest/RestRequest.js +1 -1
- package/libx/rest/middleware/input.js +2 -1
- package/libx/rest/middleware/operation.js +1 -0
- package/libx/rest/middleware/parse.js +3 -2
- package/libx/rest/middleware/payload.js +9 -8
- package/libx/rest/middleware/read.js +1 -0
- package/package.json +9 -16
- package/app/fiori/preview.js +0 -270
- package/app/fiori/routes.js +0 -59
- package/bin/build/buildTaskEngine.js +0 -360
- package/bin/build/buildTaskFactory.js +0 -283
- package/bin/build/buildTaskHandler.js +0 -241
- package/bin/build/buildTaskProvider.js +0 -22
- package/bin/build/buildTaskProviderFactory.js +0 -175
- package/bin/build/cds.js +0 -5
- package/bin/build/constants.js +0 -66
- package/bin/build/index.js +0 -58
- package/bin/build/provider/buildTaskHandlerEdmx.js +0 -82
- package/bin/build/provider/buildTaskHandlerFeatureToggles.js +0 -131
- package/bin/build/provider/buildTaskHandlerInternal.js +0 -254
- package/bin/build/provider/buildTaskProviderInternal.js +0 -383
- package/bin/build/provider/fiori/index.js +0 -171
- package/bin/build/provider/hana/2migration.js +0 -179
- package/bin/build/provider/hana/index.js +0 -505
- package/bin/build/provider/hana/migrationtable.js +0 -472
- package/bin/build/provider/hana/template/.hdiconfig-haas +0 -163
- package/bin/build/provider/hana/template/.hdiconfig-hanacloud +0 -137
- package/bin/build/provider/hana/template/.hdinamespace +0 -4
- package/bin/build/provider/hana/template/package.json +0 -12
- package/bin/build/provider/hana/template/undeploy.json +0 -5
- package/bin/build/provider/java/index.js +0 -111
- package/bin/build/provider/java-cf/index.js +0 -1
- package/bin/build/provider/mtx/index.js +0 -268
- package/bin/build/provider/mtx/resourcesTarBuilder.js +0 -95
- package/bin/build/provider/mtx-extension/index.js +0 -131
- package/bin/build/provider/mtx-sidecar/index.js +0 -137
- package/bin/build/provider/node-cf/index.js +0 -1
- package/bin/build/provider/nodejs/index.js +0 -192
- package/bin/build/util.js +0 -299
- package/bin/cds.js +0 -125
- package/bin/deploy/to-hana/cfUtil.js +0 -355
- package/bin/deploy/to-hana/gitUtil.js +0 -57
- package/bin/deploy/to-hana/hana.js +0 -306
- package/bin/deploy/to-hana/hdiDeployUtil.js +0 -153
- package/bin/deploy/to-hana/index.js +0 -16
- package/bin/deploy/to-hana/mtaUtil.js +0 -170
- package/bin/mtx/in-cds.js +0 -17
- package/bin/plugins.js +0 -32
- package/bin/run.js +0 -24
- package/bin/utils/log.js +0 -24
- package/bin/version.js +0 -178
- package/libx/_runtime/audit/Service.js +0 -222
- package/libx/_runtime/audit/generic/personal/access.js +0 -61
- package/libx/_runtime/audit/generic/personal/index.js +0 -56
- package/libx/_runtime/audit/generic/personal/modification.js +0 -132
- package/libx/_runtime/audit/generic/personal/utils.js +0 -186
- package/libx/_runtime/audit/utils/log.js +0 -23
- package/libx/_runtime/audit/utils/v2.js +0 -176
- package/libx/_runtime/db/data-conversion/timestamp.js +0 -9
- package/libx/_runtime/db/generic/integrity.js +0 -455
- package/srv/audit-log.cds +0 -87
- package/srv/mtx.cds +0 -2
- package/srv/mtx.js +0 -8
- /package/lib/{core → linked}/classes.js +0 -0
- /package/lib/{core → linked}/entities.js +0 -0
package/lib/env/cds-env.js
CHANGED
|
@@ -35,7 +35,8 @@ class Config {
|
|
|
35
35
|
if (_home) _add_static_profiles (_home, profiles);
|
|
36
36
|
if (!profiles.includes('production')) profiles.push('development')
|
|
37
37
|
this._profiles = new Set (profiles)
|
|
38
|
-
this._profiles._defined = new Set
|
|
38
|
+
this._profiles._defined = new Set
|
|
39
|
+
this._profiles._important = []
|
|
39
40
|
|
|
40
41
|
// 1. set compat requires default values
|
|
41
42
|
if (_context === 'cds' && _defaults) this.add (DEFAULTS, defaults)
|
|
@@ -50,21 +51,22 @@ class Config {
|
|
|
50
51
|
this._add_to_process_env (_home, '.env')
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const sources = Config.sources(_home, _context)
|
|
54
|
-
|
|
55
54
|
// 2. read config sources in defined order
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (const { path, file, mapper } of sources) {
|
|
64
|
-
this._load(path, file, mapper, important, true)
|
|
55
|
+
const sources = Config.sources(_home, _context)
|
|
56
|
+
for (let { path:dir, file, mapper = x=>x } of sources) {
|
|
57
|
+
let src = path.join(dir,file)
|
|
58
|
+
let json = _readJson(src,{paths:[_home]}); if (!json) continue
|
|
59
|
+
if (json.dependencies?.['@sap/cds-mtx']) {
|
|
60
|
+
console.error('@sap/cds-mtx is not supported by @sap/cds >= 7. Please upgrade to @sap/cds-mtxs following the migration guide on https://cap.cloud.sap/docs/guides/multitenancy/old-mtx-migration.')
|
|
61
|
+
process.exit(1)
|
|
65
62
|
}
|
|
63
|
+
this.add (mapper(json), src)
|
|
66
64
|
}
|
|
67
65
|
|
|
66
|
+
// 3. apply important (!) profiles from config sources
|
|
67
|
+
for (let each of this._profiles._important) each()
|
|
68
|
+
delete this._profiles._important
|
|
69
|
+
|
|
68
70
|
// 4. add process env before linking to allow things like CDS_requires_db=sql
|
|
69
71
|
this._add_process_env(_context, _home)
|
|
70
72
|
|
|
@@ -74,28 +76,15 @@ class Config {
|
|
|
74
76
|
// 6. complete service configurations from cloud service bindings
|
|
75
77
|
this._add_cloud_service_bindings(process.env)
|
|
76
78
|
|
|
77
|
-
// 7. Add compatibility and correlations for mtx
|
|
79
|
+
// 7. Add compatibility and correlations for mtx
|
|
78
80
|
const db = this.requires?.db
|
|
79
81
|
if (this.requires?.db) {
|
|
80
82
|
if (this.requires.multitenancy !== undefined)
|
|
81
83
|
Object.defineProperty (db, 'multiTenant', { value: !!this.requires.multitenancy })
|
|
82
84
|
else if (db.multiTenant !== undefined)
|
|
83
85
|
this.requires.multitenancy = db.multiTenant
|
|
84
|
-
// Automatically use new sqlite service if in package dependencies
|
|
85
|
-
const new_sqlite_service = '@cap-js/sqlite'
|
|
86
|
-
if (db.kind === 'sqlite') try {
|
|
87
|
-
const pkg = require(path.join(_home,'package.json'))
|
|
88
|
-
if (pkg.dependencies?.[new_sqlite_service] || pkg.devDependencies?.[new_sqlite_service]) {
|
|
89
|
-
db.impl = new_sqlite_service
|
|
90
|
-
}
|
|
91
|
-
} catch (e) {
|
|
92
|
-
if (e.code !== 'MODULE_NOT_FOUND') throw e
|
|
93
|
-
}
|
|
94
|
-
// Add correlation b/w better-sqlite and lean-draft
|
|
95
|
-
if (this.fiori && this.fiori.lean_draft === undefined && db.impl === new_sqlite_service) {
|
|
96
|
-
this.fiori.lean_draft = true
|
|
97
|
-
}
|
|
98
86
|
}
|
|
87
|
+
if (this.requires?.multitenancy && this.requires.db?.kind === 'hana' && !this.requires.db.vcap) Object.assign(this.requires.db, { vcap: { label: 'service-manager' } })
|
|
99
88
|
|
|
100
89
|
|
|
101
90
|
// 8. apply presets
|
|
@@ -116,25 +105,28 @@ class Config {
|
|
|
116
105
|
*/
|
|
117
106
|
static sources (home, context = 'cds') {
|
|
118
107
|
if (!home) throw new Error('Missing parameter "home".')
|
|
108
|
+
if (context !== 'cds') return [
|
|
109
|
+
{ path: home, file: 'package.json', mapper: x => x[context] },
|
|
110
|
+
]
|
|
119
111
|
const user_home = process.env.CDS_USER_HOME || require('os').homedir()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}},
|
|
129
|
-
{ name: 'PRIVATE', path: home, file: '.cdsrc-private.json' }
|
|
112
|
+
return [
|
|
113
|
+
...( global._plugins||[] ).map (root => ({
|
|
114
|
+
path: root, file: 'package.json', mapper: x => x.cds
|
|
115
|
+
})),
|
|
116
|
+
{ path: user_home, file: '.cdsrc.json' },
|
|
117
|
+
{ path: home, file: '.cdsrc-private.json' },
|
|
118
|
+
{ path: home, file: '.cdsrc.json' },
|
|
119
|
+
{ path: home, file: 'package.json', mapper: _package_json },
|
|
130
120
|
]
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
function _package_json (pkg) { // fill cds.extends from .extends
|
|
122
|
+
let cds = pkg.cds
|
|
123
|
+
if (pkg.extends) (cds||(cds={})).extends = pkg.extends
|
|
124
|
+
return cds
|
|
125
|
+
}
|
|
134
126
|
}
|
|
135
127
|
|
|
136
128
|
|
|
137
|
-
add (conf, /*from:*/ _src, profiles = this._profiles
|
|
129
|
+
add (conf, /*from:*/ _src, profiles = this._profiles) {
|
|
138
130
|
if (!conf) return this
|
|
139
131
|
if (_src) this._sources.push (_src)
|
|
140
132
|
const reqs = conf.requires
|
|
@@ -143,7 +135,7 @@ class Config {
|
|
|
143
135
|
if (typeof reqs[each] === 'string') reqs[each] = {kind:conf.requires[each]}
|
|
144
136
|
}
|
|
145
137
|
}
|
|
146
|
-
_merge (this, conf, profiles
|
|
138
|
+
_merge (this, conf, profiles)
|
|
147
139
|
return this
|
|
148
140
|
}
|
|
149
141
|
|
|
@@ -192,7 +184,7 @@ class Config {
|
|
|
192
184
|
* For BAS only: get all defined profiles (could include some from the defaults)
|
|
193
185
|
*/
|
|
194
186
|
get "defined-profiles" () {
|
|
195
|
-
return
|
|
187
|
+
return [...this._profiles._defined]
|
|
196
188
|
}
|
|
197
189
|
|
|
198
190
|
|
|
@@ -203,25 +195,10 @@ class Config {
|
|
|
203
195
|
//
|
|
204
196
|
|
|
205
197
|
|
|
206
|
-
/**
|
|
207
|
-
* Load from JSON file or directory
|
|
208
|
-
* No profile support!
|
|
209
|
-
*/
|
|
210
|
-
_loadFromPath (_path, _basePath) {
|
|
211
|
-
if (_basePath && !path.isAbsolute(_path)) _path = path.join(_basePath, _path)
|
|
212
|
-
const json = _readJson (_path) || _readFromDir (_path)
|
|
213
|
-
if (json) this.add (json, _path, new Set())
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
_load (cwd, file, _conf=o=>o, profiles, profiles_only) {
|
|
217
|
-
const json = _readJson (file = path.join(cwd, file)) // only support JSON
|
|
218
|
-
if (json) this.add (_conf (json), file, profiles, profiles_only)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
198
|
_add_to_process_env (cwd, filename) {
|
|
222
199
|
const file = path.resolve (cwd,filename)
|
|
223
200
|
try {
|
|
224
|
-
const all = require('../compile/etc/properties').read(file)
|
|
201
|
+
const all = require('../compile/etc/properties').read(file); if (!all) return
|
|
225
202
|
for (const key in all) {
|
|
226
203
|
if (key in process.env) continue // do not change existing env vars
|
|
227
204
|
const val = all[key]
|
|
@@ -240,13 +217,18 @@ class Config {
|
|
|
240
217
|
const PREF = prefix.toUpperCase(), my = { CONFIG: PREF+'_CONFIG', ENV: PREF+'_ENV' }
|
|
241
218
|
let config
|
|
242
219
|
|
|
243
|
-
|
|
244
|
-
if (
|
|
220
|
+
let val = env[my.CONFIG]
|
|
221
|
+
if (val) try {
|
|
245
222
|
// CDS_CONFIG={ /* json */}
|
|
246
|
-
config = JSON.parse (
|
|
223
|
+
config = JSON.parse (val)
|
|
247
224
|
} catch (e) {
|
|
248
225
|
// CDS_CONFIG=/path/to/config.json *OR* CDS_CONFIG=/path/to/config/dir
|
|
249
|
-
if (typeof
|
|
226
|
+
if (typeof val === "string") {
|
|
227
|
+
// Load from JSON file or directory; No profile support!
|
|
228
|
+
if (basePath && !path.isAbsolute(val)) val = path.join(basePath, val)
|
|
229
|
+
const json = _readJson(val) || _readFromDir(val)
|
|
230
|
+
if (json) this.add (json, val, false)
|
|
231
|
+
}
|
|
250
232
|
}
|
|
251
233
|
|
|
252
234
|
if (!config) config = {}
|
|
@@ -265,7 +247,7 @@ class Config {
|
|
|
265
247
|
o[next] = _value4(env[p])
|
|
266
248
|
}
|
|
267
249
|
|
|
268
|
-
this.add(config, '
|
|
250
|
+
this.add(config, 'process.env')
|
|
269
251
|
}
|
|
270
252
|
|
|
271
253
|
_link_required_services () {
|
|
@@ -290,14 +272,14 @@ class Config {
|
|
|
290
272
|
const preset1 = kinds[key]
|
|
291
273
|
if (typeof preset1 === 'object' && preset1 !== val) {
|
|
292
274
|
const top = val, base = _merge ({},_linked(key,preset1)), {kind} = base
|
|
293
|
-
val = _merge (base, top
|
|
294
|
-
if (kind) val.kind = kind
|
|
275
|
+
val = _merge (base, top) // apply/override with top-level data
|
|
276
|
+
if (kind) val.kind = kind // but inherited kind wins
|
|
295
277
|
}
|
|
296
278
|
}
|
|
297
279
|
if (typeof preset === 'object' && preset !== val) {
|
|
298
280
|
const top = val, base = _merge ({},_linked(p,preset), _profiles), {kind} = base
|
|
299
|
-
val = _merge (base, top, _profiles
|
|
300
|
-
if (kind) val.kind = kind
|
|
281
|
+
val = _merge (base, top, _profiles) // apply/override with top-level data
|
|
282
|
+
if (kind) val.kind = kind // but inherited kind wins
|
|
301
283
|
}
|
|
302
284
|
if (typeof val === 'object') Object.defineProperty (val, '_is_linked', {value:true})
|
|
303
285
|
return val
|
|
@@ -311,7 +293,7 @@ class Config {
|
|
|
311
293
|
try {
|
|
312
294
|
const vcaps = JSON.parse (VCAP_SERVICES)
|
|
313
295
|
const any = this._add_vcap_services_to (vcaps)
|
|
314
|
-
if (any) this._sources.push ('
|
|
296
|
+
if (any) this._sources.push ('process.env.VCAP_SERVICES')
|
|
315
297
|
} catch(e) {
|
|
316
298
|
throw new Error ('[cds.env] - failed to parse VCAP_SERVICES:\n '+ e.message)
|
|
317
299
|
}
|
|
@@ -324,7 +306,7 @@ class Config {
|
|
|
324
306
|
if (VCAP_SERVICES && !(this.features && this.features.vcaps == false)) {
|
|
325
307
|
try {
|
|
326
308
|
bindings = JSON.parse(VCAP_SERVICES)
|
|
327
|
-
bindingsSource = '
|
|
309
|
+
bindingsSource = 'process.env.VCAP_SERVICES'
|
|
328
310
|
} catch(e) {
|
|
329
311
|
throw new Error ('[cds.env] - failed to parse VCAP_SERVICES:\n '+ e.message)
|
|
330
312
|
}
|
|
@@ -461,7 +443,7 @@ function _add_static_profiles (_home, profiles) {
|
|
|
461
443
|
/**
|
|
462
444
|
* @returns {Config} dst
|
|
463
445
|
*/
|
|
464
|
-
function _merge (dst, src, _profiles
|
|
446
|
+
function _merge (dst, src, _profiles) {
|
|
465
447
|
const profiled = [], descr = Object.getOwnPropertyDescriptors(src)
|
|
466
448
|
for (let p in descr) {
|
|
467
449
|
const pd = descr[p]
|
|
@@ -472,24 +454,27 @@ function _merge (dst, src, _profiles, _cloned, _profiles_only = false) {
|
|
|
472
454
|
}
|
|
473
455
|
|
|
474
456
|
if (_profiles && p[0] === '[') {
|
|
475
|
-
const
|
|
476
|
-
|
|
457
|
+
const important = p.endsWith('!]')
|
|
458
|
+
const profile = p.slice (1, important ? -2 : -1)
|
|
459
|
+
if (_profiles._defined) _profiles._defined.add (profile)
|
|
477
460
|
if (_profiles.has(profile)) {
|
|
478
461
|
let o = src[p]; if (typeof o !== 'object') continue
|
|
479
|
-
|
|
462
|
+
let merge = () => _merge (dst, o, _profiles, false)
|
|
463
|
+
if (important && _profiles._important) _profiles._important.push(merge)
|
|
464
|
+
else profiled.push ({ profile, merge })
|
|
480
465
|
}
|
|
481
466
|
continue
|
|
482
467
|
}
|
|
483
468
|
|
|
484
469
|
const v = pd.value
|
|
485
470
|
if (typeof v === 'object' && !Array.isArray(v)) {
|
|
486
|
-
if (!dst[p]) dst[p] = {}
|
|
471
|
+
if (!dst[p]) dst[p] = {}
|
|
487
472
|
if (typeof dst[p] !== 'object') dst[p] = v
|
|
488
|
-
else _merge (dst[p], v, _profiles
|
|
473
|
+
else _merge (dst[p], v, _profiles)
|
|
489
474
|
continue
|
|
490
475
|
}
|
|
491
476
|
|
|
492
|
-
if (
|
|
477
|
+
else if (v !== undefined) dst[p] = v
|
|
493
478
|
}
|
|
494
479
|
if (profiled.length > 0 && !_profiles.has('production')) {
|
|
495
480
|
const profiles = Array.from(_profiles)
|
|
@@ -508,9 +493,9 @@ function _value4 (val) {
|
|
|
508
493
|
return val
|
|
509
494
|
}
|
|
510
495
|
|
|
511
|
-
function _readJson (file) {
|
|
496
|
+
function _readJson (file, _options) {
|
|
512
497
|
try {
|
|
513
|
-
const src = fs.readFileSync (require.resolve
|
|
498
|
+
const src = fs.readFileSync (require.resolve(file,_options))
|
|
514
499
|
return JSON.parse (src)
|
|
515
500
|
} catch (e) {
|
|
516
501
|
if (e instanceof SyntaxError) console.error(`Error parsing '${file}': ${e.message}`)
|
package/lib/env/cds-requires.js
CHANGED
|
@@ -2,7 +2,7 @@ const _runtime = '@sap/cds/libx/_runtime'
|
|
|
2
2
|
|
|
3
3
|
exports = module.exports = {
|
|
4
4
|
|
|
5
|
-
middlewares:
|
|
5
|
+
middlewares: true,
|
|
6
6
|
db: undefined, "[schevo]": { db: { schema_evolution: 'auto' }, },
|
|
7
7
|
messaging: undefined,
|
|
8
8
|
multitenancy: undefined,
|
|
@@ -121,40 +121,40 @@ const _databases = {
|
|
|
121
121
|
'[production]': { kind: 'hana' },
|
|
122
122
|
},
|
|
123
123
|
|
|
124
|
-
"sqlite":
|
|
124
|
+
"sqlite": {
|
|
125
125
|
'[better-sqlite]': { impl: '@cap-js/sqlite' },
|
|
126
126
|
impl: `${_runtime}/sqlite/Service.js`,
|
|
127
127
|
credentials: { url: 'db.sqlite' },
|
|
128
|
-
}
|
|
128
|
+
},
|
|
129
129
|
|
|
130
130
|
"better-sqlite": {
|
|
131
131
|
credentials: { url: ":memory:" },
|
|
132
132
|
impl: "@cap-js/sqlite",
|
|
133
133
|
kind: 'sqlite'
|
|
134
134
|
},
|
|
135
|
-
"legacy-sqlite":
|
|
135
|
+
"legacy-sqlite": {
|
|
136
136
|
impl: `${_runtime}/sqlite/Service.js`,
|
|
137
137
|
credentials: { url: 'db.sqlite' },
|
|
138
138
|
kind: 'sqlite'
|
|
139
|
-
}
|
|
139
|
+
},
|
|
140
140
|
|
|
141
|
-
"hana":
|
|
141
|
+
"hana": {
|
|
142
142
|
impl: `${_runtime}/hana/Service.js`,
|
|
143
|
-
}
|
|
144
|
-
"hana-cloud":
|
|
143
|
+
},
|
|
144
|
+
"hana-cloud": {
|
|
145
145
|
kind: 'hana', "deploy-format": "hdbtable",
|
|
146
|
-
}
|
|
146
|
+
},
|
|
147
147
|
|
|
148
148
|
"sql-mt": { // For compatibility only
|
|
149
149
|
'[development]': { kind: 'sqlite' },
|
|
150
150
|
'[production]': { kind: 'hana-mt' },
|
|
151
151
|
},
|
|
152
|
-
"hana-mt":
|
|
152
|
+
"hana-mt": { // For compatibility only
|
|
153
153
|
kind: 'hana', "deploy-format": "hdbtable",
|
|
154
154
|
"vcap": {
|
|
155
155
|
"label": "service-manager"
|
|
156
156
|
}
|
|
157
|
-
}
|
|
157
|
+
},
|
|
158
158
|
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -226,18 +226,6 @@ const _messaging = {
|
|
|
226
226
|
|
|
227
227
|
const _platform_services = {
|
|
228
228
|
|
|
229
|
-
"audit-log-service": {
|
|
230
|
-
impl: `${_runtime}/audit/Service.js`,
|
|
231
|
-
// model: 'AuditLogService.cds',
|
|
232
|
-
outbox: {},
|
|
233
|
-
vcap: { label: "auditlog" },
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
"audit-log-to-console": {
|
|
237
|
-
kind: "audit-log-service",
|
|
238
|
-
credentials: { logToConsole: true }
|
|
239
|
-
},
|
|
240
|
-
|
|
241
229
|
destinations: {
|
|
242
230
|
vcap: {
|
|
243
231
|
label: 'destination'
|
|
@@ -258,9 +246,4 @@ exports.kinds = {
|
|
|
258
246
|
}
|
|
259
247
|
|
|
260
248
|
|
|
261
|
-
function _compat_to_use(o) { return Object.defineProperties (o,{
|
|
262
|
-
// NOTE: Property .use is for compatibility only -> use .dialect instead!
|
|
263
|
-
use: { get(){ return this.dialect || this.kind }, configurable:true, enumerable:true },
|
|
264
|
-
})}
|
|
265
|
-
|
|
266
249
|
Object.defineProperty(exports,'_resolved',{value:exports._resolved,enumerable:false}) // hide it in outputs
|
package/lib/env/defaults.js
CHANGED
|
@@ -3,8 +3,17 @@ const path = require('path')
|
|
|
3
3
|
|
|
4
4
|
const defaults = module.exports = {
|
|
5
5
|
|
|
6
|
+
production,
|
|
7
|
+
|
|
8
|
+
cov2ap: false, // REVISIT: workaround for bug in @cap-js-community/odata-v2-adapter/cds-plugin -> cds/tests/_runtime/remote/__tests__/integration/mocked-v2-consumption/v2.test.js
|
|
9
|
+
|
|
6
10
|
requires: require('./cds-requires'),
|
|
7
11
|
|
|
12
|
+
server: {
|
|
13
|
+
force_exit_timeout: 1111,
|
|
14
|
+
port: 4004,
|
|
15
|
+
},
|
|
16
|
+
|
|
8
17
|
schemas: {
|
|
9
18
|
'cds-rc.json': path.join(__dirname, 'schemas/cds-rc.json'),
|
|
10
19
|
'cds-package.json': path.join(__dirname, 'schemas/cds-package.json'),
|
|
@@ -24,14 +33,15 @@ const defaults = module.exports = {
|
|
|
24
33
|
one_model: true,
|
|
25
34
|
localized: true,
|
|
26
35
|
assert_integrity: false,
|
|
27
|
-
cds_tx_protection: true,
|
|
28
36
|
cds_tx_inheritance: true,
|
|
37
|
+
serve_on_root: false,
|
|
38
|
+
precise_timestamps: false
|
|
29
39
|
},
|
|
30
40
|
|
|
31
41
|
fiori: {
|
|
32
42
|
preview: !production,
|
|
33
43
|
routes: !production,
|
|
34
|
-
lean_draft:
|
|
44
|
+
lean_draft: true,
|
|
35
45
|
draft_compat: undefined,
|
|
36
46
|
'[better-sqlite]': { lean_draft: true },
|
|
37
47
|
'[lean-draft]': { lean_draft: true },
|
|
@@ -132,7 +142,7 @@ const defaults = module.exports = {
|
|
|
132
142
|
},
|
|
133
143
|
|
|
134
144
|
hana: {
|
|
135
|
-
'deploy-format': '
|
|
145
|
+
'deploy-format': 'hdbtable',
|
|
136
146
|
journal: {
|
|
137
147
|
'change-mode': 'alter'
|
|
138
148
|
}
|
package/lib/env/plugins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// REVISIT: we should have a real modular plugin technique for cds.env
|
|
2
2
|
module.exports = function add_mtx_env (env) {
|
|
3
3
|
|
|
4
|
-
const mtx_env =
|
|
4
|
+
const mtx_env = require('@sap/cds-mtxs/env') // eslint-disable-line cds/no-missing-dependencies
|
|
5
5
|
if (mtx_env) {
|
|
6
6
|
const {requires} = env, {kinds} = requires
|
|
7
7
|
Object.assign (env, mtx_env, {requires})
|
|
@@ -14,16 +14,5 @@ module.exports = function add_mtx_env (env) {
|
|
|
14
14
|
catch(e) { if (e.code !== 'MODULE_NOT_FOUND') throw e }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function old_mtx_env() {
|
|
18
|
-
const {_oldMtx} = require('../utils/cds-utils')
|
|
19
|
-
if (_oldMtx()) return {
|
|
20
|
-
requires: { kinds: {
|
|
21
|
-
"multitenancy": { model: "@sap/cds/srv/mtx", kind: "saas-registry" },
|
|
22
|
-
"extensibility": { model: "@sap/cds/srv/mtx" },
|
|
23
|
-
// "toggles": { model: "@sap/cds/srv/mtx" },
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}}
|
|
27
|
-
|
|
28
17
|
return env
|
|
29
18
|
}
|
package/lib/env/presets.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
const cds = require('../index')
|
|
2
|
+
|
|
3
|
+
const { join } = cds.utils.path
|
|
4
|
+
|
|
5
|
+
const PROTOCOLS = {
|
|
6
|
+
'odata-v4': { path: '/odata/v4', impl: join(__dirname,'../srv/protocols/odata-v4') },
|
|
7
|
+
rest: { path: '/rest', impl: join(__dirname,'../srv/protocols/rest') }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// REVISIT: Looks very hard-coded -> move this to consumers?
|
|
2
11
|
module.exports = function (conf) {
|
|
3
|
-
|
|
4
|
-
if (!features) return
|
|
12
|
+
let { features, requires } = conf
|
|
5
13
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
features.assert_integrity = true
|
|
14
|
-
features.assert_integrity_type = 'RT'
|
|
15
|
-
break
|
|
16
|
-
case 'db':
|
|
17
|
-
features.assert_integrity = true
|
|
18
|
-
features.assert_integrity_type = 'DB'
|
|
19
|
-
break
|
|
20
|
-
default:
|
|
21
|
-
// > invalid -> set to default
|
|
22
|
-
features.assert_integrity = false
|
|
23
|
-
}
|
|
14
|
+
if (requires?.middlewares) {
|
|
15
|
+
let p = conf.protocols || {}
|
|
16
|
+
for (let [k, o] of Object.entries(p)) if (typeof o === 'string') p[k] = { path: o }
|
|
17
|
+
p['odata-v4'] = Object.assign({}, PROTOCOLS['odata-v4'], p['odata-v4'])
|
|
18
|
+
p.odata = Object.assign({}, PROTOCOLS['odata-v4'], p.odata)
|
|
19
|
+
p.rest = Object.assign({}, PROTOCOLS.rest, p.rest)
|
|
20
|
+
conf.protocols = p
|
|
24
21
|
}
|
|
25
22
|
|
|
23
|
+
// integrity checks
|
|
24
|
+
if (!features) return
|
|
25
|
+
if (typeof features.assert_integrity === 'string' && features.assert_integrity.match(/db/i)) {
|
|
26
|
+
features.assert_integrity = true
|
|
27
|
+
features.assert_integrity_type = 'DB'
|
|
28
|
+
} else features.assert_integrity = false
|
|
26
29
|
}
|
|
30
|
+
|