@hiliosai/sdk 0.1.21 → 0.1.23
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 +4 -18
- package/dist/index.js +16 -6
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -239,6 +239,8 @@ declare class PrismaDatasource<TPrismaClient extends PrismaClientLike = PrismaCl
|
|
|
239
239
|
protected applyExtensions(client: TPrismaClient): TPrismaClient;
|
|
240
240
|
/**
|
|
241
241
|
* Get extended client with all applied extensions
|
|
242
|
+
* Note: Since extensions are already applied in initializePrismaClient,
|
|
243
|
+
* this just returns the client directly to avoid double-applying extensions
|
|
242
244
|
*/
|
|
243
245
|
get extendedClient(): TPrismaClient;
|
|
244
246
|
/**
|
|
@@ -248,6 +250,7 @@ declare class PrismaDatasource<TPrismaClient extends PrismaClientLike = PrismaCl
|
|
|
248
250
|
/**
|
|
249
251
|
* Called automatically when context is injected
|
|
250
252
|
* Sets tenant context from service context if available
|
|
253
|
+
* Skips update if currently in bypass mode to avoid overriding admin operations
|
|
251
254
|
*/
|
|
252
255
|
private updateTenantFromContext;
|
|
253
256
|
/**
|
|
@@ -325,23 +328,6 @@ declare const softDeleteExtension: {
|
|
|
325
328
|
};
|
|
326
329
|
};
|
|
327
330
|
|
|
328
|
-
/**
|
|
329
|
-
* Multi-Tenant Extension for Prisma
|
|
330
|
-
* Automatically filters queries by tenant context for multi-tenant applications
|
|
331
|
-
*
|
|
332
|
-
* Usage:
|
|
333
|
-
* ```typescript
|
|
334
|
-
* import { createTenantExtension } from './extensions/tenant.extension';
|
|
335
|
-
*
|
|
336
|
-
* class MyPrismaDS extends PrismaDatasource<PrismaClient> {
|
|
337
|
-
* protected applyExtensions(client: PrismaClient) {
|
|
338
|
-
* return client.$extends(createTenantExtension());
|
|
339
|
-
* }
|
|
340
|
-
* }
|
|
341
|
-
* ```
|
|
342
|
-
*
|
|
343
|
-
* Requires models to have `tenantId String` field
|
|
344
|
-
*/
|
|
345
331
|
declare function createTenantExtension(): {
|
|
346
332
|
name: string;
|
|
347
333
|
client: {
|
|
@@ -916,4 +902,4 @@ declare function DatasourceMixin(datasourceConstructors?: DatasourceConstructorR
|
|
|
916
902
|
|
|
917
903
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
918
904
|
|
|
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 };
|
|
905
|
+
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 PrismaClientLike, 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
|
@@ -1417,12 +1417,16 @@ var AbstractDatasource = class {
|
|
|
1417
1417
|
};
|
|
1418
1418
|
|
|
1419
1419
|
// src/datasources/extensions/tenant.extension.ts
|
|
1420
|
+
var globalTenantContext = {
|
|
1421
|
+
currentTenantId: null,
|
|
1422
|
+
bypassMode: false,
|
|
1423
|
+
strictMode: false
|
|
1424
|
+
};
|
|
1425
|
+
function isInBypassMode() {
|
|
1426
|
+
return globalTenantContext.bypassMode;
|
|
1427
|
+
}
|
|
1420
1428
|
function createTenantExtension() {
|
|
1421
|
-
const tenantContext =
|
|
1422
|
-
currentTenantId: null,
|
|
1423
|
-
bypassMode: false,
|
|
1424
|
-
strictMode: false
|
|
1425
|
-
};
|
|
1429
|
+
const tenantContext = globalTenantContext;
|
|
1426
1430
|
return {
|
|
1427
1431
|
name: "Tenant",
|
|
1428
1432
|
client: {
|
|
@@ -1621,9 +1625,11 @@ var PrismaDatasource = class extends AbstractDatasource {
|
|
|
1621
1625
|
}
|
|
1622
1626
|
/**
|
|
1623
1627
|
* Get extended client with all applied extensions
|
|
1628
|
+
* Note: Since extensions are already applied in initializePrismaClient,
|
|
1629
|
+
* this just returns the client directly to avoid double-applying extensions
|
|
1624
1630
|
*/
|
|
1625
1631
|
get extendedClient() {
|
|
1626
|
-
return this.
|
|
1632
|
+
return this.client;
|
|
1627
1633
|
}
|
|
1628
1634
|
/**
|
|
1629
1635
|
* Initialize datasource - called after broker injection
|
|
@@ -1634,8 +1640,12 @@ var PrismaDatasource = class extends AbstractDatasource {
|
|
|
1634
1640
|
/**
|
|
1635
1641
|
* Called automatically when context is injected
|
|
1636
1642
|
* Sets tenant context from service context if available
|
|
1643
|
+
* Skips update if currently in bypass mode to avoid overriding admin operations
|
|
1637
1644
|
*/
|
|
1638
1645
|
updateTenantFromContext() {
|
|
1646
|
+
if (isInBypassMode()) {
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1639
1649
|
const tenantId = this.context?.meta?.tenantId;
|
|
1640
1650
|
if (tenantId && typeof tenantId === "string") {
|
|
1641
1651
|
this.setTenantContext(tenantId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hiliosai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@hiliosai/prettier": "workspace:*",
|
|
29
29
|
"@hiliosai/typescript": "workspace:*",
|
|
30
30
|
"@pkg/dev-utils": "workspace:*",
|
|
31
|
+
"@prisma/adapter-pg": "7.2.0",
|
|
31
32
|
"bun-types": "latest"
|
|
32
33
|
},
|
|
33
34
|
"prettier": "@hiliosai/prettier"
|