@sap/cds 6.3.2 → 6.4.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 +76 -0
- package/apis/cds.d.ts +1 -1
- package/apis/core.d.ts +118 -90
- package/apis/cqn.d.ts +11 -2
- package/apis/internal/inference.d.ts +7 -2
- package/apis/ql.d.ts +45 -11
- package/apis/serve.d.ts +8 -1
- package/apis/services.d.ts +303 -305
- package/bin/build/buildTaskEngine.js +28 -36
- package/bin/build/buildTaskFactory.js +32 -81
- package/bin/build/buildTaskHandler.js +3 -2
- package/bin/build/buildTaskProvider.js +2 -2
- package/bin/build/buildTaskProviderFactory.js +5 -14
- package/bin/build/constants.js +0 -1
- package/bin/build/provider/buildTaskHandlerEdmx.js +7 -6
- package/bin/build/provider/buildTaskHandlerFeatureToggles.js +6 -5
- package/bin/build/provider/buildTaskHandlerInternal.js +9 -30
- package/bin/build/provider/buildTaskProviderInternal.js +70 -58
- package/bin/build/provider/fiori/index.js +6 -5
- package/bin/build/provider/hana/2migration.js +20 -3
- package/bin/build/provider/hana/2tabledata.js +1 -0
- package/bin/build/provider/hana/index.js +40 -17
- package/bin/build/provider/java/index.js +10 -10
- package/bin/build/provider/mtx/index.js +25 -16
- package/bin/build/provider/mtx/resourcesTarBuilder.js +22 -27
- package/bin/build/provider/mtx-extension/index.js +3 -2
- package/bin/build/provider/mtx-sidecar/index.js +16 -15
- package/bin/build/provider/nodejs/index.js +14 -56
- package/bin/build/util.js +56 -16
- package/bin/deploy/to-hana/cfUtil.js +2 -0
- package/bin/deploy/to-hana/gitUtil.js +1 -1
- package/bin/deploy/to-hana/hana.js +45 -38
- package/bin/deploy/to-hana/hdiDeployUtil.js +8 -9
- package/bin/deploy/to-hana/mtaUtil.js +13 -14
- package/bin/mtx/in-cds.js +3 -1
- package/bin/serve.js +1 -1
- package/bin/version.js +2 -1
- package/lib/compile/cds-compile.js +1 -0
- package/lib/compile/cdsc.js +1 -0
- package/lib/compile/etc/_localized.js +2 -2
- package/lib/compile/for/lean_drafts.js +83 -0
- package/lib/compile/for/nodejs.js +1 -0
- package/lib/compile/minify.js +2 -1
- package/lib/compile/to/gql.js +1 -1
- package/lib/compile/to/sql.js +11 -1
- package/lib/core/entities.js +1 -1
- package/lib/core/index.js +8 -9
- package/lib/core/infer.js +1 -0
- package/lib/dbs/cds-deploy.js +97 -41
- package/lib/env/cds-env.js +9 -10
- package/lib/env/cds-requires.js +8 -2
- package/lib/env/defaults.js +0 -4
- package/lib/env/schemas/cds-rc.json +38 -0
- package/lib/ql/SELECT.js +10 -4
- package/lib/srv/bindings.js +1 -1
- package/lib/srv/factory.js +1 -1
- package/lib/srv/srv-methods.js +1 -1
- package/lib/utils/cds-utils.js +11 -0
- package/lib/utils/inflect.js +13 -12
- package/lib/utils/tar.js +12 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/delete.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +1 -15
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/UriSyntaxError.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +6 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/BufferedWriter.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/ConditionalRequestValidator.js +0 -12
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/oDataConfiguration.js +1 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +4 -0
- package/libx/_runtime/cds-services/services/Service.js +23 -1
- package/libx/_runtime/cds-services/util/assert.js +0 -41
- package/libx/_runtime/common/composition/data.js +5 -1
- package/libx/_runtime/common/generic/auth/utils.js +3 -3
- package/libx/_runtime/common/generic/input.js +4 -24
- package/libx/_runtime/common/generic/paging.js +3 -3
- package/libx/_runtime/common/utils/csn.js +21 -15
- package/libx/_runtime/common/utils/draft.js +2 -1
- package/libx/_runtime/common/utils/resolveView.js +25 -4
- package/libx/_runtime/common/utils/rewriteAsterisks.js +3 -1
- package/libx/_runtime/common/utils/rowUUIDGenerator.js +21 -0
- package/libx/_runtime/common/utils/templateProcessor.js +12 -15
- package/libx/_runtime/common/utils/templateProcessorPathSerializer.js +23 -0
- package/libx/_runtime/db/expand/expandCQNToJoin.js +29 -12
- package/libx/_runtime/db/generic/input.js +7 -13
- package/libx/_runtime/db/sql-builder/UpsertBuilder.js +47 -0
- package/libx/_runtime/db/sql-builder/index.js +2 -0
- package/libx/_runtime/db/sql-builder/sqlFactory.js +9 -0
- package/libx/_runtime/db/utils/columns.js +4 -2
- package/libx/_runtime/fiori/generic/read.js +1 -12
- package/libx/_runtime/fiori/lean-draft.js +657 -0
- package/libx/_runtime/fiori/utils/handler.js +1 -1
- package/libx/_runtime/hana/pool.js +16 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/getTenantInfo.js +2 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging.js +2 -3
- package/libx/_runtime/messaging/outbox/utils.js +109 -70
- package/libx/_runtime/messaging/service.js +16 -7
- package/libx/_runtime/remote/Service.js +15 -2
- package/libx/_runtime/remote/utils/client.js +41 -11
- package/libx/_runtime/sqlite/Service.js +3 -0
- package/libx/_runtime/sqlite/convertDraftAdminPathExpression.js +56 -0
- package/libx/_runtime/sqlite/customBuilder/CustomUpsertBuilder.js +59 -0
- package/libx/_runtime/sqlite/customBuilder/index.js +5 -0
- package/libx/_runtime/sqlite/execute.js +1 -1
- package/libx/_runtime/types/api.js +2 -2
- package/libx/rest/RestAdapter.js +15 -13
- package/package.json +1 -1
- package/server.js +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const InsertBuilder = require('./InsertBuilder')
|
|
2
|
+
const getAnnotatedColumns = require('./annotations')
|
|
3
|
+
|
|
4
|
+
class UpsertBuilder extends InsertBuilder {
|
|
5
|
+
constructor(obj, options, csn) {
|
|
6
|
+
super(obj, options, csn)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// REVISIT: We need to copy over the implementation for annotation handling
|
|
10
|
+
build() {
|
|
11
|
+
this._outputObj = {
|
|
12
|
+
sql: ['UPSERT'],
|
|
13
|
+
values: []
|
|
14
|
+
}
|
|
15
|
+
this._obj = { INSERT: this._obj.UPSERT, _target: this._obj._target }
|
|
16
|
+
|
|
17
|
+
const entityName = this._into()
|
|
18
|
+
|
|
19
|
+
this._columnIndexesToDelete = []
|
|
20
|
+
const annotatedColumns = getAnnotatedColumns(entityName, this._csn)
|
|
21
|
+
// hack: treat update annotations as insert because of sql builder impl
|
|
22
|
+
if (annotatedColumns) {
|
|
23
|
+
annotatedColumns.insertAnnotatedColumns = annotatedColumns.updateAnnotatedColumns
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (this._obj.INSERT.columns) {
|
|
27
|
+
this._removeAlreadyExistingInsertAnnotatedColumnsFromMap(annotatedColumns)
|
|
28
|
+
this._columns(annotatedColumns)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (this._obj.INSERT.values || this._obj.INSERT.rows) {
|
|
32
|
+
if (annotatedColumns && !this._obj.INSERT.columns) {
|
|
33
|
+
// if columns not provided get indexes from csn
|
|
34
|
+
this._getAnnotatedColumnIndexes(annotatedColumns)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this._values(annotatedColumns)
|
|
38
|
+
} else if (this._obj.INSERT.entries && this._obj.INSERT.entries.length !== 0) {
|
|
39
|
+
this._entries(annotatedColumns)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this._outputObj.sql = this._outputObj.sql.join(' ') + ' WITH PRIMARY KEY'
|
|
43
|
+
return this._outputObj
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = UpsertBuilder
|
|
@@ -3,6 +3,7 @@ const DropBuilder = require('./DropBuilder')
|
|
|
3
3
|
const SelectBuilder = require('./SelectBuilder')
|
|
4
4
|
const InsertBuilder = require('./InsertBuilder')
|
|
5
5
|
const UpdateBuilder = require('./UpdateBuilder')
|
|
6
|
+
const UpsertBuilder = require('./UpsertBuilder')
|
|
6
7
|
const DeleteBuilder = require('./DeleteBuilder')
|
|
7
8
|
const ExpressionBuilder = require('./ExpressionBuilder')
|
|
8
9
|
const ReferenceBuilder = require('./ReferenceBuilder')
|
|
@@ -18,6 +19,7 @@ module.exports = {
|
|
|
18
19
|
SelectBuilder,
|
|
19
20
|
InsertBuilder,
|
|
20
21
|
UpdateBuilder,
|
|
22
|
+
UpsertBuilder,
|
|
21
23
|
DeleteBuilder,
|
|
22
24
|
ExpressionBuilder,
|
|
23
25
|
ReferenceBuilder,
|
|
@@ -2,6 +2,7 @@ const DeleteBuilder = require('./DeleteBuilder')
|
|
|
2
2
|
const InsertBuilder = require('./InsertBuilder')
|
|
3
3
|
const SelectBuilder = require('./SelectBuilder')
|
|
4
4
|
const UpdateBuilder = require('./UpdateBuilder')
|
|
5
|
+
const UpsertBuilder = require('./UpsertBuilder')
|
|
5
6
|
const CreateBuilder = require('./CreateBuilder')
|
|
6
7
|
const DropBuilder = require('./DropBuilder')
|
|
7
8
|
|
|
@@ -16,6 +17,10 @@ const _getCustomBuilderIfExists = (options, type) => {
|
|
|
16
17
|
return options.customBuilder.UpdateBuilder
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
case 'UPSERT': {
|
|
21
|
+
return options.customBuilder.UpsertBuilder
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
case 'DELETE': {
|
|
20
25
|
return options.customBuilder.DeleteBuilder
|
|
21
26
|
}
|
|
@@ -77,6 +82,10 @@ const build = (cqn, options, csn) => {
|
|
|
77
82
|
return build(_getCustomBuilderIfExists(options, 'UPDATE') || UpdateBuilder)
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
if (cqn.UPSERT) {
|
|
86
|
+
return build(_getCustomBuilderIfExists(options, 'UPSERT') || UpsertBuilder)
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
if (cqn.DELETE) {
|
|
81
90
|
return build(_getCustomBuilderIfExists(options, 'DELETE') || DeleteBuilder)
|
|
82
91
|
}
|
|
@@ -16,12 +16,14 @@ const getColumns = (entity, { _4db, onlyKeys } = { _4db: true, onlyKeys: false }
|
|
|
16
16
|
if (!(entity && entity.elements)) return []
|
|
17
17
|
const columnNames = []
|
|
18
18
|
// REVISIT!!!
|
|
19
|
-
const elements =
|
|
19
|
+
const elements = cds.env.features.lean_draft
|
|
20
|
+
? entity.elements
|
|
21
|
+
: Object.getPrototypeOf(entity.elements) || entity.elements
|
|
20
22
|
for (const elementName in elements) {
|
|
21
23
|
const element = elements[elementName]
|
|
22
24
|
if (onlyKeys && !element.key) continue
|
|
23
25
|
if (element.isAssociation) continue
|
|
24
|
-
if (_4db && entity._isDraftEnabled && elementName in DRAFT_COLUMNS_MAP) continue
|
|
26
|
+
if (!cds.env.features.lean_draft && _4db && entity._isDraftEnabled && elementName in DRAFT_COLUMNS_MAP) continue
|
|
25
27
|
if ((cds.env.effective.odata.structs || cds.env.features.ucsn_struct_conversion) && element.elements) {
|
|
26
28
|
columnNames.push(...resolveStructured({ element, structProperties: [] }, false))
|
|
27
29
|
continue
|
|
@@ -714,16 +714,6 @@ const _getSiblingScenario = (req, columns, model, siblingIndex, nav) => {
|
|
|
714
714
|
const _getSiblingQueryFromWhere = (query, queryIndex, parentQuery) => {
|
|
715
715
|
if (query.SELECT && query.SELECT.where && queryIndex > 0) {
|
|
716
716
|
for (let i = 0; i < query.SELECT.where.length; i++) {
|
|
717
|
-
if (query.SELECT.where[i].xpr && queryIndex > 0) {
|
|
718
|
-
const sibilingQueryFromWhere = _getSiblingQueryFromWhere(
|
|
719
|
-
{ SELECT: { where: query.SELECT.where[i].xpr } },
|
|
720
|
-
queryIndex - 1,
|
|
721
|
-
query
|
|
722
|
-
)
|
|
723
|
-
|
|
724
|
-
if (sibilingQueryFromWhere) return sibilingQueryFromWhere
|
|
725
|
-
}
|
|
726
|
-
|
|
727
717
|
if (query.SELECT.where[i] === 'exists' && queryIndex > 0) {
|
|
728
718
|
return _getSiblingQueryFromWhere(query.SELECT.where[i + 1], queryIndex - 1, query)
|
|
729
719
|
}
|
|
@@ -757,7 +747,6 @@ const _replaceWhereExists = (query, _siblingIndex, siblingCQN) => {
|
|
|
757
747
|
|
|
758
748
|
const indexExists = query.SELECT.where.indexOf('exists')
|
|
759
749
|
if (indexExists > -1) {
|
|
760
|
-
if (_siblingIndex > 0) return _replaceWhereExists(query.SELECT.where[indexExists + 1], _siblingIndex - 1)
|
|
761
750
|
query.SELECT.where.splice(indexExists + 1, 1, siblingCQN)
|
|
762
751
|
}
|
|
763
752
|
}
|
|
@@ -1019,7 +1008,7 @@ const _generateCQN = (req, columns, from, model) => {
|
|
|
1019
1008
|
let siblingIndex = nav.indexOf('SiblingEntity')
|
|
1020
1009
|
|
|
1021
1010
|
// it can also be a property access (new parser), then we must shift it
|
|
1022
|
-
if (siblingIndex
|
|
1011
|
+
if (siblingIndex > 0 && req.target.elements[nav[0]] && !req.target.elements[nav[0]].isAssociation) {
|
|
1023
1012
|
nav.shift()
|
|
1024
1013
|
siblingIndex = siblingIndex - 1
|
|
1025
1014
|
}
|