@hiliosai/sdk 0.1.17 → 0.1.18

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1482,7 +1482,9 @@ var PrismaDatasource = class extends AbstractDatasource {
1482
1482
  async disconnect() {
1483
1483
  try {
1484
1484
  this.broker.logger.info("Disconnecting from database");
1485
- await this.client.$disconnect();
1485
+ if (this._client) {
1486
+ await this._client.$disconnect();
1487
+ }
1486
1488
  this.broker.logger.info("Successfully disconnected from database");
1487
1489
  } catch (error) {
1488
1490
  this.broker.logger.error("Error disconnecting from database:", error);
@@ -1549,7 +1551,8 @@ var PrismaDatasource = class extends AbstractDatasource {
1549
1551
  * Requires tenant extension to be applied
1550
1552
  */
1551
1553
  setTenantContext(tenantId) {
1552
- const tenantClient = this.client;
1554
+ this._client ?? (this._client = this.initializePrismaClient());
1555
+ const tenantClient = this._client;
1553
1556
  if (tenantClient.$setTenant) {
1554
1557
  tenantClient.$setTenant(tenantId);
1555
1558
  this.broker.logger.debug("Tenant context set:", { tenantId });
@@ -1563,7 +1566,10 @@ var PrismaDatasource = class extends AbstractDatasource {
1563
1566
  * Get current tenant context
1564
1567
  */
1565
1568
  getCurrentTenant() {
1566
- const tenantClient = this.client;
1569
+ if (!this._client) {
1570
+ return null;
1571
+ }
1572
+ const tenantClient = this._client;
1567
1573
  if (tenantClient.$getCurrentTenant) {
1568
1574
  return tenantClient.$getCurrentTenant();
1569
1575
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",