@sap/cds-mtxs
Advanced tools
Comparing version 1.6.0 to 1.6.1
{ | ||
"name": "@sap/cds-mtxs", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "SAP Cloud Application Programming Model - Multitenancy library", | ||
@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/", |
@@ -137,7 +137,7 @@ const cds = require('@sap/cds/lib') | ||
async delete(context) { | ||
LOG.debug('Received unsubscription request', context.data) | ||
LOG.debug('received unsubscription request', context.data) | ||
const { isSync } = parseHeaders(context.http?.req.headers) | ||
const tenant = this._getSubscribedTenant(context) | ||
LOG.info(`Unsubscribing tenant ${tenant}`) | ||
LOG.info(`unsubscribing tenant ${tenant}`) | ||
@@ -155,2 +155,3 @@ const one = await cds.tx({ tenant: t0 }, tx => | ||
await this._sendCallback('SUCCEEDED', 'Tenant deletion succeeded') | ||
LOG.info(`successfully unsubscribed tenant ${tenant}`) | ||
} catch (error) { | ||
@@ -157,0 +158,0 @@ if (error.statusCode === 404) { |
@@ -11,2 +11,3 @@ const cds = require('@sap/cds/lib') | ||
const t0 = cds.env.requires.multitenancy?.t0 ?? 't0' | ||
const { lazyT0 } = cds.env.requires['cds.xt.DeploymentService'] ?? cds.env.requires.multitenancy ?? {} | ||
@@ -19,4 +20,5 @@ ds.before ('*', req => { | ||
ds.before ('subscribe', req => { | ||
if (cds.requires.multitenancy?.lazyT0 && req.data.tenant !== cds.env.requires.multitenancy.t0) { | ||
return _resubscribeT0IfNeeded() | ||
const { lazyT0 } = cds.env.requires['cds.xt.DeploymentService'] ?? cds.env.requires.multitenancy ?? {} | ||
if (lazyT0 && req.data.tenant !== cds.env.requires.multitenancy.t0) { | ||
return _resubscribeT0IfNeeded(req.data.options?._) | ||
} | ||
@@ -45,3 +47,3 @@ }) | ||
async function _resubscribeT0IfNeeded() { | ||
async function _resubscribeT0IfNeeded(params) { | ||
await cds.connect() // REVISIT: Ideally shouldn't be necessary | ||
@@ -53,10 +55,11 @@ // REVISIT: schema evolution/delta deployment (might be unnecessarily expensive tho) | ||
await ds.tx({ tenant: t0 }, async tx => { | ||
const columns = await tx.getColumns(t0, cds.requires.db.kind === 'hana' ? 'CDS_XT_JOBS' : 'cds_xt_Jobs') | ||
const columns = await tx.getColumns(t0, cds.requires.db.kind === 'hana' ? 'CDS_XT_JOBS' : 'cds_xt_Jobs', params) | ||
const needsT0Redeployment = !columns.includes('error') && !columns.includes('ERROR') | ||
if (!needsT0Redeployment) return | ||
const csn = await cds.load(`${__dirname}/../../../db/t0.cds`) | ||
await tx.subscribe({ tenant: t0, options: { csn }}) | ||
await tx.subscribe({ tenant: t0, options: { csn, _: params }}) | ||
}) | ||
} | ||
if (!cds.requires.multitenancy?.lazyT0) return _resubscribeT0IfNeeded() | ||
if (!lazyT0) return _resubscribeT0IfNeeded() | ||
}) |
@@ -55,4 +55,4 @@ const cds = require('@sap/cds/lib'), {db} = cds.env.requires | ||
ds.on ('getColumns', async req => { | ||
const { tenant:t, table } = req.data | ||
const { schema } = (t === t0 ? await hana.acquire(t, _imCreateParams(t)) : await hana.get(t)).credentials | ||
const { tenant:t, table, params } = req.data | ||
const { schema } = (t === t0 ? await hana.acquire(t, _imCreateParams(t, params)) : await hana.get(t)).credentials | ||
return (await cds.tx({ tenant: t }, tx => | ||
@@ -59,0 +59,0 @@ tx.run('SELECT * FROM TABLE_COLUMNS WHERE SCHEMA_NAME = ? AND TABLE_NAME = ?', [schema, table]) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164252
3364