@sap/cds 6.6.1 → 6.7.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 +67 -3
- package/README.md +1 -1
- package/apis/connect.d.ts +11 -4
- package/apis/core.d.ts +1 -1
- package/apis/csn.d.ts +1 -0
- package/apis/internal/inference.d.ts +15 -2
- package/apis/log.d.ts +10 -0
- package/apis/serve.d.ts +4 -9
- package/apis/services.d.ts +86 -19
- package/bin/build/buildTaskEngine.js +16 -42
- package/bin/build/constants.js +4 -2
- package/bin/build/provider/buildTaskProviderInternal.js +117 -85
- package/bin/build/provider/hana/index.js +6 -1
- package/bin/build/provider/mtx-extension/index.js +74 -34
- package/bin/build/provider/mtx-sidecar/index.js +3 -3
- package/bin/build/provider/nodejs/index.js +2 -2
- package/bin/build/util.js +63 -14
- package/bin/cds-serve.js +6 -0
- package/bin/cds.js +20 -4
- package/bin/deploy/to-hana/cfUtil.js +15 -1
- package/bin/deploy/to-hana/hana.js +1 -1
- package/bin/deploy/to-hana/hdiDeployUtil.js +1 -1
- package/bin/mtx/in-cds.js +2 -9
- package/bin/plugins.js +31 -0
- package/bin/serve.js +12 -12
- package/lib/compile/etc/_localized.js +1 -1
- package/lib/compile/for/lean_drafts.js +22 -6
- package/lib/compile/for/nodejs.js +4 -1
- package/lib/compile/load.js +4 -2
- package/lib/core/index.js +35 -15
- package/lib/dbs/cds-deploy.js +129 -133
- package/lib/env/cds-env.js +25 -17
- package/lib/env/cds-requires.js +10 -40
- package/lib/env/compat.js +12 -0
- package/lib/env/defaults.js +17 -9
- package/lib/env/plugins.js +29 -0
- package/lib/env/schemas/cds-rc.json +14 -0
- package/lib/index.js +3 -0
- package/lib/log/cds-log.js +7 -4
- package/lib/ql/CREATE.js +1 -1
- package/lib/ql/DELETE.js +1 -1
- package/lib/ql/DROP.js +3 -3
- package/lib/ql/INSERT.js +1 -1
- package/lib/ql/Query.js +14 -6
- package/lib/ql/SELECT.js +8 -2
- package/lib/ql/UPDATE.js +1 -1
- package/lib/ql/Whereable.js +1 -1
- package/lib/ql/cds-ql.js +1 -9
- package/lib/req/cds-context.js +1 -4
- package/lib/req/request.js +63 -2
- package/lib/req/response.js +3 -2
- package/lib/srv/bindings.js +69 -71
- package/lib/srv/cds-connect.js +4 -1
- package/lib/srv/cds-serve.js +4 -0
- package/lib/srv/middlewares/index.js +37 -6
- package/lib/srv/protocols/_legacy.js +1 -1
- package/lib/srv/protocols/index.js +1 -1
- package/lib/srv/srv-api.js +4 -6
- package/lib/srv/srv-dispatch.js +4 -3
- package/lib/srv/srv-handlers.js +1 -1
- package/lib/srv/srv-methods.js +8 -2
- package/lib/utils/cds-test.js +4 -1
- package/libx/_runtime/audit/Service.js +8 -9
- package/libx/_runtime/audit/generic/personal/index.js +1 -1
- package/libx/_runtime/audit/generic/personal/utils.js +1 -1
- package/libx/_runtime/audit/utils/v2.js +17 -20
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +2 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +11 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +0 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +3 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/metaInfo.js +4 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/oDataConfiguration.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +1 -1
- package/libx/_runtime/cds-services/services/Service.js +1 -1
- package/libx/_runtime/cds-services/util/assert.js +41 -65
- package/libx/_runtime/common/code-ext/WorkerPool.js +90 -0
- package/libx/_runtime/common/code-ext/WorkerReq.js +0 -4
- package/libx/_runtime/common/code-ext/execute.js +28 -18
- package/libx/_runtime/common/code-ext/handlers.js +5 -4
- package/libx/_runtime/common/code-ext/worker.js +45 -3
- package/libx/_runtime/common/code-ext/workerQueryExecutor.js +8 -7
- package/libx/_runtime/common/composition/delete.js +1 -1
- package/libx/_runtime/common/composition/update.js +3 -5
- package/libx/_runtime/common/generic/auth/expand.js +1 -1
- package/libx/_runtime/common/generic/auth/readOnly.js +5 -4
- package/libx/_runtime/common/generic/auth/restrict.js +7 -2
- package/libx/_runtime/common/generic/crud.js +12 -1
- package/libx/_runtime/common/generic/etag.js +11 -3
- package/libx/_runtime/common/generic/input.js +8 -6
- package/libx/_runtime/common/generic/paging.js +25 -8
- package/libx/_runtime/common/generic/put.js +1 -1
- package/libx/_runtime/common/generic/sorting.js +0 -1
- package/libx/_runtime/common/i18n/messages.properties +1 -0
- package/libx/_runtime/common/utils/cqn.js +5 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +2 -2
- package/libx/_runtime/common/utils/resolveView.js +14 -10
- package/libx/_runtime/common/utils/rewriteAsterisks.js +2 -3
- package/libx/_runtime/common/utils/templateProcessor.js +15 -17
- package/libx/_runtime/common/utils/templateProcessorPathSerializer.js +18 -6
- package/libx/_runtime/db/Service.js +1 -0
- package/libx/_runtime/db/data-conversion/post-processing.js +0 -18
- package/libx/_runtime/db/expand/expand-v2.js +2 -2
- package/libx/_runtime/db/expand/rawToExpanded.js +6 -6
- package/libx/_runtime/db/generic/integrity.js +1 -1
- package/libx/_runtime/db/utils/columns.js +5 -5
- package/libx/_runtime/fiori/generic/activate.js +3 -3
- package/libx/_runtime/fiori/generic/edit.js +1 -1
- package/libx/_runtime/fiori/generic/new.js +4 -0
- package/libx/_runtime/fiori/lean-draft.js +138 -46
- package/libx/_runtime/hana/execute.js +3 -1
- package/libx/_runtime/hana/pool.js +10 -2
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +6 -1
- package/libx/_runtime/messaging/enterprise-messaging.js +1 -0
- package/libx/_runtime/remote/Service.js +16 -13
- package/libx/_runtime/remote/utils/client.js +6 -1
- package/libx/_runtime/sqlite/Service.js +5 -59
- package/libx/_runtime/sqlite/convertDraftAdminPathExpression.js +1 -0
- package/libx/_runtime/sqlite/customBuilder/CustomUpsertBuilder.js +2 -2
- package/libx/_runtime/sqlite/execute.js +3 -1
- package/libx/_runtime/types/api.js +12 -3
- package/libx/odata/afterburner.js +36 -0
- package/libx/odata/cqn2odata.js +1 -1
- package/libx/odata/grammar.pegjs +5 -3
- package/libx/odata/parser.js +1 -1
- package/libx/odata/utils.js +1 -1
- package/libx/rest/RestAdapter.js +1 -1
- package/libx/rest/RestRequest.js +1 -0
- package/package.json +5 -2
- package/libx/_runtime/common/code-ext/workerQuery.js +0 -45
- package/libx/_runtime/common/constants/limit.js +0 -12
- package/libx/_runtime/common/utils/page.js +0 -39
|
@@ -13,7 +13,7 @@ const cds = require('../../../lib');
|
|
|
13
13
|
const LOG = cds.log ? cds.log('deploy') : console;
|
|
14
14
|
const DEBUG = cds.debug('deploy');
|
|
15
15
|
|
|
16
|
-
const { bold } = require('../../utils/term');
|
|
16
|
+
const { bold, warn } = require('../../utils/term');
|
|
17
17
|
|
|
18
18
|
const CF_COMMAND = 'cf';
|
|
19
19
|
|
|
@@ -25,6 +25,8 @@ const OPERATION_STATE_IN_PROGRESS = 'in progress';
|
|
|
25
25
|
const OPERATION_STATE_FAILED = 'failed';
|
|
26
26
|
const OPERATION_STATE_SUCCEEDED = 'succeeded';
|
|
27
27
|
|
|
28
|
+
const CF_CLIENT_MINIMUM_VERSION = 8;
|
|
29
|
+
|
|
28
30
|
|
|
29
31
|
class CfUtil {
|
|
30
32
|
|
|
@@ -135,10 +137,22 @@ class CfUtil {
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
async getCfTarget() {
|
|
140
|
+
await this.checkCliVersion();
|
|
138
141
|
await this._cfRun('oauth-token'); // check if token is valid or expired / missing
|
|
139
142
|
return await this.getCfTargetFromConfigFile() || await this.getCfTargetFromCli();
|
|
140
143
|
}
|
|
141
144
|
|
|
145
|
+
async checkCliVersion() {
|
|
146
|
+
const result = await this._cfRun('-v');
|
|
147
|
+
const version = result?.stdout?.match(/version.*(\d+\.\d+\.\d+)/i)
|
|
148
|
+
if (parseInt(version?.[1]) < CF_CLIENT_MINIMUM_VERSION) {
|
|
149
|
+
console.log(warn(`
|
|
150
|
+
[Warning] You are using Cloud Foundry client version ${version[1]}. We recommend version ${CF_CLIENT_MINIMUM_VERSION} or higher.
|
|
151
|
+
Deployment will stop in the near future for Cloud Foundry client versions < ${CF_CLIENT_MINIMUM_VERSION}.
|
|
152
|
+
`));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
142
156
|
async getCfSpaceInfo() {
|
|
143
157
|
if (!this.spaceInfo) {
|
|
144
158
|
LOG.debug('getting space info');
|
|
@@ -72,7 +72,7 @@ class HanaDeployer {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const hasVCAPEnv = Object.keys(vcapEnv).length > 0;
|
|
75
|
-
if (hasVCAPEnv) {
|
|
75
|
+
if (!serviceName && hasVCAPEnv) {
|
|
76
76
|
await fs.mkdir(currentModelFolder, { recursive: true });
|
|
77
77
|
} else {
|
|
78
78
|
const { cfServiceInstanceName, cfServiceInstanceKeyName, serviceKey } =
|
package/bin/mtx/in-cds.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
const cds = require('../build/cds')
|
|
2
|
-
const { _oldMtx } = cds.utils
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
if (_oldMtx()) return false
|
|
6
|
-
try { return !!require.resolve('@sap/cds-mtxs/srv/deployment-service') }
|
|
7
|
-
catch {/* ignored */}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!cds.requires.multitenancy || _is_streamlined_mtx()) module.exports = undefined
|
|
11
|
-
else try {
|
|
3
|
+
if (cds.requires.multitenancy && cds.utils._oldMtx()) try {
|
|
12
4
|
// eslint-disable-next-line cds/no-missing-dependencies
|
|
13
5
|
const mtx = module.exports = require ('@sap/cds-mtx')()
|
|
14
6
|
mtx.inject (cds)
|
|
@@ -17,6 +9,7 @@ else try {
|
|
|
17
9
|
if (e.code === 'MODULE_NOT_FOUND') throw new Error('Error serving MTX APIs: @sap/cds-mtx is not installed')
|
|
18
10
|
else throw e
|
|
19
11
|
}
|
|
12
|
+
else module.exports = undefined
|
|
20
13
|
|
|
21
14
|
/*
|
|
22
15
|
cds.requires.multitenancy -- use this to check whether mt is enabled (old or new)
|
package/bin/plugins.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const cds = require('../lib')
|
|
2
|
+
const DEBUG = cds.debug('plugins')
|
|
3
|
+
|
|
4
|
+
module.exports = async function load_plugins (log = console.log) {
|
|
5
|
+
|
|
6
|
+
if (DEBUG) console.time('[cds] - loaded plugins in')
|
|
7
|
+
const plugins = []
|
|
8
|
+
if (cds.env.plugins) {
|
|
9
|
+
for (let each of cds.env.plugins) {
|
|
10
|
+
let impl = typeof each === 'string' ? each : each.impl
|
|
11
|
+
if (impl.startsWith('.'))
|
|
12
|
+
impl = require.resolve(cds.root + '/' + impl)
|
|
13
|
+
plugins.push(_load_plugin(impl, each))
|
|
14
|
+
}
|
|
15
|
+
} else
|
|
16
|
+
try {
|
|
17
|
+
const { dependencies } = require(cds.root + '/package.json')
|
|
18
|
+
for (let each in dependencies) {
|
|
19
|
+
plugins.push(_load_plugin(each + '/cds-plugin'))
|
|
20
|
+
}
|
|
21
|
+
} catch { /* ignored */ }
|
|
22
|
+
try { await Promise.all(plugins); } catch { /* ignored */ }
|
|
23
|
+
if (DEBUG) console.timeEnd('[cds] - loaded plugins in')
|
|
24
|
+
|
|
25
|
+
async function _load_plugin (impl, conf) {
|
|
26
|
+
// TODO support ESM plugins. But see cap/cds/pull/1838#issuecomment-1177200 !
|
|
27
|
+
const plugin = require(impl)
|
|
28
|
+
log('loaded plugin:', { impl })
|
|
29
|
+
if (plugin.activate) await plugin.activate(conf)
|
|
30
|
+
}
|
|
31
|
+
}
|
package/bin/serve.js
CHANGED
|
@@ -154,12 +154,19 @@ async function serve (all=[], o={}) {
|
|
|
154
154
|
if (o.watch) return _watch.call(this, o.project,o) // cds serve --watch <project>
|
|
155
155
|
if (o.project) _chdir_to (o.project) // cds run --project <project>
|
|
156
156
|
|
|
157
|
+
const TRACE = cds.debug('trace')
|
|
158
|
+
// if (TRACE) {
|
|
159
|
+
// TRACE?.time('load express '); require('express') // eslint-disable-line cds/no-missing-dependencies
|
|
160
|
+
// TRACE?.timeEnd('load express ')
|
|
161
|
+
// }
|
|
162
|
+
TRACE?.time('cds bootstrap ')
|
|
163
|
+
|
|
157
164
|
// Load local server.js early in order to allow setting custom cds.log.Loggers
|
|
158
165
|
const cds_server = await _local_server_js() || cds.server
|
|
159
166
|
if (!o.silent) _prepare_logging ()
|
|
160
167
|
|
|
161
168
|
// The following things are meant for dev mode, which can be overruled by feature flagse...
|
|
162
|
-
const {features} = cds.env
|
|
169
|
+
const {features,fiori} = cds.env
|
|
163
170
|
{
|
|
164
171
|
// handle --with-mocks resp. --mocked
|
|
165
172
|
if (features.with_mocks) o.mocked = _with_mocks(o)
|
|
@@ -174,23 +181,16 @@ async function serve (all=[], o={}) {
|
|
|
174
181
|
if (features.live_reload) require('../app/etc/livereload')
|
|
175
182
|
|
|
176
183
|
// add dev helper for Fiori URLs
|
|
177
|
-
if (
|
|
184
|
+
if (fiori.routes) require('../app/fiori/routes')
|
|
178
185
|
|
|
179
186
|
// add fiori preview links to default index.html
|
|
180
|
-
if (
|
|
187
|
+
if (fiori.preview) require('../app/fiori/preview')
|
|
181
188
|
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
// activate plugins
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
let impl = each.impl
|
|
188
|
-
if (impl.startsWith('.')) impl = require.resolve(cds.root+'/'+impl)
|
|
189
|
-
log ('loading plugin:', {impl})
|
|
190
|
-
// TODO support ESM plugins. But see cap/cds/pull/1838#issuecomment-1177200 !
|
|
191
|
-
const plugin = require(impl)
|
|
192
|
-
if (plugin.activate) await plugin.activate(each)
|
|
193
|
-
}
|
|
192
|
+
await require("./plugins")(log)
|
|
193
|
+
TRACE?.timeEnd('cds bootstrap ')
|
|
194
194
|
|
|
195
195
|
// bootstrap server from project-local server.js or from @sap/cds/server.js
|
|
196
196
|
const server = await cds_server(o)
|
|
@@ -45,7 +45,7 @@ function unfold_csn (m) { // NOSONAR
|
|
|
45
45
|
const pass2 = []
|
|
46
46
|
|
|
47
47
|
const _conf = env.requires.db || env.requires.sql || env.requires.kinds && env.requires.kinds.sql
|
|
48
|
-
const _on_sqlite = _conf.kind === 'sqlite' || _conf.
|
|
48
|
+
const _on_sqlite = _conf.kind === 'sqlite' || _conf.dialect === 'sqlite'
|
|
49
49
|
const _locales = _on_sqlite && _locales_4sql.sqlite
|
|
50
50
|
|
|
51
51
|
// Pass 1 - add localized.<locale> entities and views
|
|
@@ -19,7 +19,13 @@ function _isCompositionBacklink(e) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const IGNORED_ENTITY_ANNOTATIONS = new Set([
|
|
23
|
+
'@readonly',
|
|
24
|
+
'@insertonly',
|
|
25
|
+
'@restrict',
|
|
26
|
+
])
|
|
27
|
+
|
|
28
|
+
const IGNORED_ELEMENT_ANNOTATIONS = [
|
|
23
29
|
'@assert.range',
|
|
24
30
|
'@assert.enum',
|
|
25
31
|
'@assert.format',
|
|
@@ -27,14 +33,21 @@ const IGNORED_ANNOTATIONS = [
|
|
|
27
33
|
'@mandatory',
|
|
28
34
|
'@Core.Immutable',
|
|
29
35
|
'@readonly',
|
|
30
|
-
'@cds.on.update',
|
|
31
|
-
'@cds.on.insert',
|
|
32
36
|
'@Core.Computed',
|
|
33
37
|
'@Common.FieldControl.Readonly',
|
|
34
38
|
'@Common.FieldControl.Mandatory',
|
|
35
39
|
'@FieldControl.Mandatory',
|
|
36
40
|
'@FieldControl.ReadOnly',
|
|
37
|
-
'@Common.FieldControl'
|
|
41
|
+
'@Common.FieldControl',
|
|
42
|
+
'@PersonalData.DataSubjectRole',
|
|
43
|
+
'@PersonalData.EntitySemantics',
|
|
44
|
+
'@PersonalData.IsPotentiallyPersonal',
|
|
45
|
+
'@PersonalData.IsPotentiallySensitive',
|
|
46
|
+
'@PersonalData.FieldSemantics'
|
|
47
|
+
// These are still needed:
|
|
48
|
+
// '@odata.etag',
|
|
49
|
+
// '@cds.on.update',
|
|
50
|
+
// '@cds.on.insert',
|
|
38
51
|
]
|
|
39
52
|
|
|
40
53
|
module.exports = function cds_compile_for_lean_drafts(csn) {
|
|
@@ -96,7 +109,10 @@ module.exports = function cds_compile_for_lean_drafts(csn) {
|
|
|
96
109
|
Object.defineProperty(active, 'drafts', { value: draft })
|
|
97
110
|
Object.defineProperty(draft, 'actives', { value: active })
|
|
98
111
|
draft['@cds.persistence.table'] = _draftEntity
|
|
99
|
-
|
|
112
|
+
|
|
113
|
+
for (const key in draft) {
|
|
114
|
+
if (IGNORED_ENTITY_ANNOTATIONS.has(key) || key.startsWith('@Capabilities') || key.startsWith('@PersonalData')) draft[key] = undefined
|
|
115
|
+
}
|
|
100
116
|
// Recursively add drafts for compositions
|
|
101
117
|
for (const each in draft.elements) {
|
|
102
118
|
const e = draft.elements[each]
|
|
@@ -106,7 +122,7 @@ module.exports = function cds_compile_for_lean_drafts(csn) {
|
|
|
106
122
|
_redirect(newEl, draftEntity(e._target, model))
|
|
107
123
|
}
|
|
108
124
|
newEl.parent = draft
|
|
109
|
-
for (const ignoredAnno of
|
|
125
|
+
for (const ignoredAnno of IGNORED_ELEMENT_ANNOTATIONS) {
|
|
110
126
|
if (newEl[ignoredAnno]) newEl[ignoredAnno] = undefined
|
|
111
127
|
}
|
|
112
128
|
draft.elements[each] = newEl
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
const cds = require ('../../index')
|
|
2
|
+
const TRACE = cds.debug('trace')
|
|
2
3
|
|
|
3
4
|
module.exports = function cds_compile_for_nodejs (csn,o) {
|
|
4
5
|
if ('_4nodejs' in csn) return csn._4nodejs
|
|
6
|
+
TRACE?.time('cds.compile 4n ')
|
|
5
7
|
let dsn = csn // cds.minify (csn)
|
|
6
8
|
dsn = cds.compile.for.drafts (csn,o) //> creates a partial copy -> avoid any cds.linked() before
|
|
7
9
|
dsn = cds.compile._localized.unfold_csn (dsn)
|
|
8
10
|
dsn = cds.linked (dsn)
|
|
9
|
-
if (cds.env.
|
|
11
|
+
if (cds.env.fiori.lean_draft) cds.compile.for.lean_drafts(dsn, o)
|
|
10
12
|
Object.defineProperty (csn, '_4nodejs', {value:dsn})
|
|
11
13
|
Object.defineProperty (dsn, '_4nodejs', {value:dsn})
|
|
14
|
+
TRACE?.timeEnd('cds.compile 4n ')
|
|
12
15
|
return dsn
|
|
13
16
|
}
|
package/lib/compile/load.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const cds = require('..')
|
|
2
|
-
|
|
2
|
+
const TRACE = cds.debug('trace')
|
|
3
3
|
|
|
4
4
|
module.exports = exports = function cds_load (files, options) {
|
|
5
5
|
const all = cds.resolve(files,options)
|
|
6
|
-
if (!all)
|
|
6
|
+
if (!all) return Promise.reject (new cds.error ({
|
|
7
7
|
message: `Couldn't find a CDS model for '${files}' in ${cds.root}`,
|
|
8
8
|
code: 'MODEL_NOT_FOUND', files,
|
|
9
9
|
}))
|
|
@@ -13,6 +13,7 @@ module.exports = exports = function cds_load (files, options) {
|
|
|
13
13
|
|
|
14
14
|
exports.parsed = function cds_get (files, options, _flavor) { // NOSONAR
|
|
15
15
|
|
|
16
|
+
TRACE?.time('cds.load model ')
|
|
16
17
|
const o = typeof options === 'string' ? { flavor:options } : options || {}
|
|
17
18
|
if (!files) files = ['*']; else if (!Array.isArray(files)) files = [files]
|
|
18
19
|
if (o.files || o.flavor === 'files') return cds.resolve(files,o)
|
|
@@ -31,6 +32,7 @@ exports.parsed = function cds_get (files, options, _flavor) { // NOSONAR
|
|
|
31
32
|
|
|
32
33
|
const _finalize = (csn,o) => {
|
|
33
34
|
if (!o.silent) cds.emit ('loaded', csn)
|
|
35
|
+
TRACE?.timeEnd('cds.load model ')
|
|
34
36
|
return csn
|
|
35
37
|
}
|
|
36
38
|
|
package/lib/core/index.js
CHANGED
|
@@ -50,27 +50,21 @@ const roots = _roots ({
|
|
|
50
50
|
/** Construct builtin.types as dictionary of all roots and common types */
|
|
51
51
|
const types = _common ({ __proto__: roots,
|
|
52
52
|
UUID: {type:'string',length:36,isUUID:true},
|
|
53
|
+
String: {type:'string'}, LargeString: {type:'String'},
|
|
54
|
+
Binary: {type:'string'}, LargeBinary: {type:'Binary'},
|
|
53
55
|
Boolean: {type:'boolean'},
|
|
54
56
|
Integer: {type:'number'},
|
|
55
57
|
UInt8: {type:'Integer'},
|
|
56
|
-
Int16: {type:'Integer'},
|
|
57
|
-
Int32: {type:'Integer'},
|
|
58
|
-
Int64: {type:'Integer'},
|
|
59
|
-
Integer16: {type:'Int16'},
|
|
60
|
-
Integer32: {type:'Int32'},
|
|
61
|
-
Integer64: {type:'Int64'},
|
|
62
|
-
Decimal: {type:'number'},
|
|
63
|
-
DecimalFloat: {type:'number'},
|
|
58
|
+
Int16: {type:'Integer'}, Integer16: {type:'Int16'},
|
|
59
|
+
Int32: {type:'Integer'}, Integer32: {type:'Int32'},
|
|
60
|
+
Int64: {type:'Integer'}, Integer64: {type:'Int64'},
|
|
64
61
|
Float: {type:'number'},
|
|
65
|
-
Double: {type:'
|
|
66
|
-
|
|
62
|
+
Double: {type:'Float'},
|
|
63
|
+
Decimal: {type:'Float'}, DecimalFloat: {type:'Decimal'},
|
|
67
64
|
Date: {type:'date'},
|
|
68
65
|
Time: {type:'date'},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Binary: {type:'string'},
|
|
72
|
-
LargeString: {type:'string'},
|
|
73
|
-
LargeBinary: {type:'string'}
|
|
66
|
+
DateTime: {type:'date'},
|
|
67
|
+
Timestamp: {type:'DateTime'},
|
|
74
68
|
})
|
|
75
69
|
|
|
76
70
|
/**
|
|
@@ -90,5 +84,31 @@ function _common (defs) {
|
|
|
90
84
|
return prefixed
|
|
91
85
|
}
|
|
92
86
|
|
|
87
|
+
;(
|
|
88
|
+
/**
|
|
89
|
+
* Adds convenience functions which can be used like that:
|
|
90
|
+
* ```js
|
|
91
|
+
* var { Date, Time, DateTime } = cds.builtin.types
|
|
92
|
+
* DateTime.now() //> 2023-02-10T14:41:36.218Z
|
|
93
|
+
* Date.now() //> 2023-02-10T14:41:36.218Z
|
|
94
|
+
* Time.now() //> 14:43:18
|
|
95
|
+
* Date.today() //> 2023-02-10
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
function _add_convenience_functions(){
|
|
99
|
+
Object.defineProperties (types.Date, {
|
|
100
|
+
today: { value: ()=> (new Date).toISOString().slice(0,10) },
|
|
101
|
+
now: { value: ()=> (new Date).toISOString() },
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
Object.defineProperties (types.Time, {
|
|
105
|
+
now: { value: ()=> (new Date).toISOString().slice(11,19) },
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
Object.defineProperties (types.DateTime, {
|
|
109
|
+
now: { value: ()=> (new Date).toISOString() },
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
)()
|
|
93
113
|
|
|
94
114
|
module.exports = { types, classes }
|