@objectstack/driver-sql 7.6.0 → 7.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/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -353,6 +353,15 @@ declare class SqlDriver implements IDataDriver {
|
|
|
353
353
|
* Returns `null` when the object has no tenant-isolation field.
|
|
354
354
|
*/
|
|
355
355
|
protected resolveTenantField(object: string): string | null;
|
|
356
|
+
/**
|
|
357
|
+
* Whether the host kernel runs in multi-tenant mode — read once from
|
|
358
|
+
* `OS_MULTI_ORG_ENABLED` (or the deprecated `OS_MULTI_TENANT`), matching how
|
|
359
|
+
* the SchemaRegistry / SecurityPlugin pick the mode. Used to gate the
|
|
360
|
+
* tenant-audit warning: it's only meaningful where tenant isolation is
|
|
361
|
+
* actually enforced (org-scoping installed).
|
|
362
|
+
*/
|
|
363
|
+
private _multiTenantMode?;
|
|
364
|
+
protected isMultiTenantMode(): boolean;
|
|
356
365
|
/**
|
|
357
366
|
* Apply a `WHERE tenant_field = ?` clause to the given query builder
|
|
358
367
|
* when:
|
package/dist/index.d.ts
CHANGED
|
@@ -353,6 +353,15 @@ declare class SqlDriver implements IDataDriver {
|
|
|
353
353
|
* Returns `null` when the object has no tenant-isolation field.
|
|
354
354
|
*/
|
|
355
355
|
protected resolveTenantField(object: string): string | null;
|
|
356
|
+
/**
|
|
357
|
+
* Whether the host kernel runs in multi-tenant mode — read once from
|
|
358
|
+
* `OS_MULTI_ORG_ENABLED` (or the deprecated `OS_MULTI_TENANT`), matching how
|
|
359
|
+
* the SchemaRegistry / SecurityPlugin pick the mode. Used to gate the
|
|
360
|
+
* tenant-audit warning: it's only meaningful where tenant isolation is
|
|
361
|
+
* actually enforced (org-scoping installed).
|
|
362
|
+
*/
|
|
363
|
+
private _multiTenantMode?;
|
|
364
|
+
protected isMultiTenantMode(): boolean;
|
|
356
365
|
/**
|
|
357
366
|
* Apply a `WHERE tenant_field = ?` clause to the given query builder
|
|
358
367
|
* when:
|
package/dist/index.js
CHANGED
|
@@ -1059,6 +1059,13 @@ var SqlDriver = class {
|
|
|
1059
1059
|
const cached = this.tenantFieldByTable[tableName] ?? this.tenantFieldByTable[object];
|
|
1060
1060
|
return cached ?? null;
|
|
1061
1061
|
}
|
|
1062
|
+
isMultiTenantMode() {
|
|
1063
|
+
if (this._multiTenantMode === void 0) {
|
|
1064
|
+
const raw = process.env.OS_MULTI_ORG_ENABLED ?? process.env.OS_MULTI_TENANT ?? "false";
|
|
1065
|
+
this._multiTenantMode = String(raw).toLowerCase() !== "false";
|
|
1066
|
+
}
|
|
1067
|
+
return this._multiTenantMode;
|
|
1068
|
+
}
|
|
1062
1069
|
/**
|
|
1063
1070
|
* Apply a `WHERE tenant_field = ?` clause to the given query builder
|
|
1064
1071
|
* when:
|
|
@@ -1109,6 +1116,7 @@ var SqlDriver = class {
|
|
|
1109
1116
|
auditMissingTenant(object, op, options) {
|
|
1110
1117
|
if (process.env.OS_TENANT_AUDIT === "0") return;
|
|
1111
1118
|
if (options?.bypassTenantAudit === true) return;
|
|
1119
|
+
if (!this.isMultiTenantMode()) return;
|
|
1112
1120
|
const tenantId = options?.tenantId;
|
|
1113
1121
|
if (tenantId !== void 0 && tenantId !== null && tenantId !== "") return;
|
|
1114
1122
|
const field = this.resolveTenantField(object);
|