@hiliosai/sdk 0.1.20 → 0.1.21

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.ts CHANGED
@@ -156,14 +156,6 @@ declare abstract class AbstractDatasource<TContext = AppContext> implements Base
156
156
  }): Promise<R>;
157
157
  }
158
158
 
159
- interface PrismaClientLike {
160
- $connect(): Promise<void>;
161
- $disconnect(): Promise<void>;
162
- $queryRaw: any;
163
- $transaction: any;
164
- $extends: any;
165
- [key: string]: any;
166
- }
167
159
  interface SoftDeleteExtension {
168
160
  softDelete: {
169
161
  [model: string]: {
@@ -180,10 +172,25 @@ interface AuditTrailExtension {
180
172
  };
181
173
  }
182
174
  interface TenantExtension {
183
- $tenant: {
184
- setContext: (tenantId: string) => void;
185
- getCurrentTenant: () => string | null;
186
- };
175
+ $setTenant: (tenantId: string) => void;
176
+ $getCurrentTenant: () => string | null;
177
+ $clearTenant: () => void;
178
+ $enableBypassMode: () => void;
179
+ $disableBypassMode: () => void;
180
+ $enableStrictMode: () => void;
181
+ $disableStrictMode: () => void;
182
+ $withBypassMode: <T>(fn: () => Promise<T>) => Promise<T>;
183
+ $withTenant: <T>(tenantId: string, fn: () => Promise<T>) => Promise<T>;
184
+ $withSystemMode: <T>(fn: () => Promise<T>) => Promise<T>;
185
+ }
186
+ type PrismaClientWithTenant<T = any> = T & TenantExtension;
187
+ interface PrismaClientLike extends Partial<TenantExtension> {
188
+ $connect(): Promise<void>;
189
+ $disconnect(): Promise<void>;
190
+ $queryRaw: any;
191
+ $transaction: any;
192
+ $extends: any;
193
+ [key: string]: any;
187
194
  }
188
195
  declare global {
189
196
  var __prisma: PrismaClientLike | undefined;
@@ -909,4 +916,4 @@ declare function DatasourceMixin(datasourceConstructors?: DatasourceConstructorR
909
916
 
910
917
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
911
918
 
912
- export { AbstractDatasource, type ActionHandler, type ActionSchemaWithContext, type ActionWithPermissions, type AppContext, type AppMeta, type AuditTrailExtension, type BaseDatasource, type BaseSpec, CHANNELS, type CarouselItem, type ChannelSendOptions, ContextHelpersMiddleware, CreateHealthCheckMiddleware, DEFAULT_DATASOURCE_CACHE_TTL, type DatasourceConstructorRegistry, type DatasourceContext, type DatasourceInstanceRegistry, type DatasourceInstanceTypes, DatasourceMixin, type Env, HEALTH_CHECK_DEFAULTS, INTEGRATION_CHANNELS, IntegrationCapability, type IntegrationChannelName, type IntegrationConfig, type IntegrationMessageFailedPayload, type IntegrationMessageReceivedPayload, type IntegrationMessageSentPayload, IntegrationPlatform, type IntegrationRegisteredPayload, type IntegrationServiceConfig, type IntegrationServiceSchema, IntegrationStatus, type IntegrationUnregisteredPayload, MemoizeMixin, type MemoizeMixinOptions, type Message, type MessageAttachment, type MessageButton, type MessageContent, MessageContentType, type MessageDirection, type MessageParticipant, type MessageStatus, type MessageType, NAMESPACE, PERMISSIONS, type Permission, type PermissionHelpers, PermissionsMiddleware, type PlatformMessage, PrismaDatasource, REDIS_URL, ROLE_PERMISSIONS, type SendResult, type SendToChannelMethod, type ServiceActionsSchema, type ServiceConfig, type ServiceSchema, type ServiceWithDatasources, type SoftDeleteExtension, type Tenant, type TenantExtension, type User, UserRole, type WebhookEvent, createDatasourceMiddleware, createTenantExtension, defineIntegration, defineService, isDev, isProd, isTest, configs as moleculer, nodeEnv, omit, retryExtension, softDeleteExtension };
919
+ export { AbstractDatasource, type ActionHandler, type ActionSchemaWithContext, type ActionWithPermissions, type AppContext, type AppMeta, type AuditTrailExtension, type BaseDatasource, type BaseSpec, CHANNELS, type CarouselItem, type ChannelSendOptions, ContextHelpersMiddleware, CreateHealthCheckMiddleware, DEFAULT_DATASOURCE_CACHE_TTL, type DatasourceConstructorRegistry, type DatasourceContext, type DatasourceInstanceRegistry, type DatasourceInstanceTypes, DatasourceMixin, type Env, HEALTH_CHECK_DEFAULTS, INTEGRATION_CHANNELS, IntegrationCapability, type IntegrationChannelName, type IntegrationConfig, type IntegrationMessageFailedPayload, type IntegrationMessageReceivedPayload, type IntegrationMessageSentPayload, IntegrationPlatform, type IntegrationRegisteredPayload, type IntegrationServiceConfig, type IntegrationServiceSchema, IntegrationStatus, type IntegrationUnregisteredPayload, MemoizeMixin, type MemoizeMixinOptions, type Message, type MessageAttachment, type MessageButton, type MessageContent, MessageContentType, type MessageDirection, type MessageParticipant, type MessageStatus, type MessageType, NAMESPACE, PERMISSIONS, type Permission, type PermissionHelpers, PermissionsMiddleware, type PlatformMessage, type PrismaClientWithTenant, PrismaDatasource, REDIS_URL, ROLE_PERMISSIONS, type SendResult, type SendToChannelMethod, type ServiceActionsSchema, type ServiceConfig, type ServiceSchema, type ServiceWithDatasources, type SoftDeleteExtension, type Tenant, type TenantExtension, type User, UserRole, type WebhookEvent, createDatasourceMiddleware, createTenantExtension, defineIntegration, defineService, isDev, isProd, isTest, configs as moleculer, nodeEnv, omit, retryExtension, softDeleteExtension };
package/dist/index.js CHANGED
@@ -1675,9 +1675,8 @@ var PrismaDatasource = class extends AbstractDatasource {
1675
1675
  async healthCheck() {
1676
1676
  try {
1677
1677
  this.broker.logger.info("Running Prisma health check");
1678
- const client = this.client;
1679
- if (client.$withSystemMode) {
1680
- await client.$withSystemMode(async () => {
1678
+ if (this.client.$withSystemMode) {
1679
+ await this.client.$withSystemMode(async () => {
1681
1680
  await this.client.$queryRaw`SELECT 1`;
1682
1681
  });
1683
1682
  } else {
@@ -1737,9 +1736,8 @@ var PrismaDatasource = class extends AbstractDatasource {
1737
1736
  */
1738
1737
  setTenantContext(tenantId) {
1739
1738
  this._client ?? (this._client = this.initializePrismaClient());
1740
- const tenantClient = this._client;
1741
- if (tenantClient.$setTenant) {
1742
- tenantClient.$setTenant(tenantId);
1739
+ if (this._client.$setTenant) {
1740
+ this._client.$setTenant(tenantId);
1743
1741
  this.broker.logger.debug("Tenant context set:", { tenantId });
1744
1742
  } else {
1745
1743
  this.broker.logger.warn(
@@ -1754,9 +1752,8 @@ var PrismaDatasource = class extends AbstractDatasource {
1754
1752
  if (!this._client) {
1755
1753
  return null;
1756
1754
  }
1757
- const tenantClient = this._client;
1758
- if (tenantClient.$getCurrentTenant) {
1759
- return tenantClient.$getCurrentTenant();
1755
+ if (this._client.$getCurrentTenant) {
1756
+ return this._client.$getCurrentTenant();
1760
1757
  }
1761
1758
  return null;
1762
1759
  }
@@ -1772,9 +1769,8 @@ var PrismaDatasource = class extends AbstractDatasource {
1772
1769
  if (previousTenant) {
1773
1770
  this.setTenantContext(previousTenant);
1774
1771
  } else {
1775
- const tenantClient = this.client;
1776
- if (tenantClient.$clearTenant) {
1777
- tenantClient.$clearTenant();
1772
+ if (this.client.$clearTenant) {
1773
+ this.client.$clearTenant();
1778
1774
  }
1779
1775
  }
1780
1776
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",