@hiliosai/sdk 0.1.22 → 0.1.24

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
@@ -1,6 +1,7 @@
1
1
  import { Context, ServiceBroker, ServiceSchema as ServiceSchema$1, ServiceSettingSchema, Service, ActionSchema, ServiceEvents, ServiceMethods, ServiceHooks, Middleware, BrokerOptions } from 'moleculer';
2
2
  import env from '@ltv/env';
3
3
  export { default as env } from '@ltv/env';
4
+ import { PrismaPg } from '@prisma/adapter-pg';
4
5
 
5
6
  interface Tenant {
6
7
  id: string;
@@ -291,6 +292,13 @@ declare class PrismaDatasource<TPrismaClient extends PrismaClientLike = PrismaCl
291
292
  withTenant<T>(tenantId: string, fn: () => Promise<T>): Promise<T>;
292
293
  }
293
294
 
295
+ declare abstract class PrismaPgDatasource<TPrismaClient extends PrismaClientLike> extends PrismaDatasource<TPrismaClient> {
296
+ abstract createPrismaPgClient(adapter: PrismaPg): TPrismaClient;
297
+ private getConnectionString;
298
+ protected createAdapter(connectionString: string): PrismaPg;
299
+ protected createClient(): TPrismaClient;
300
+ }
301
+
294
302
  /**
295
303
  * Soft Delete Extension for Prisma
296
304
  * Automatically handles soft deletes by setting deletedAt instead of removing records
@@ -902,4 +910,4 @@ declare function DatasourceMixin(datasourceConstructors?: DatasourceConstructorR
902
910
 
903
911
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
904
912
 
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 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 };
913
+ 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, PrismaPgDatasource, 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
@@ -3,6 +3,7 @@ import http from 'http';
3
3
  import crypto from 'crypto';
4
4
  import os from 'os';
5
5
  import { Middleware } from '@moleculer/channels';
6
+ import { PrismaPg } from '@prisma/adapter-pg';
6
7
 
7
8
  // src/middlewares/datasource.middleware.ts
8
9
  function initializeDatasources(constructorRegistry) {
@@ -1786,6 +1787,22 @@ var PrismaDatasource = class extends AbstractDatasource {
1786
1787
  }
1787
1788
  }
1788
1789
  };
1790
+ var PrismaPgDatasource = class extends PrismaDatasource {
1791
+ getConnectionString() {
1792
+ const connectionString = env_default.string("DATABASE_URL");
1793
+ if (!connectionString) {
1794
+ throw new Error("DATABASE_URL is required");
1795
+ }
1796
+ return connectionString;
1797
+ }
1798
+ createAdapter(connectionString) {
1799
+ return new PrismaPg({ connectionString });
1800
+ }
1801
+ createClient() {
1802
+ const adapter = this.createAdapter(this.getConnectionString());
1803
+ return this.createPrismaPgClient(adapter);
1804
+ }
1805
+ };
1789
1806
 
1790
1807
  // src/datasources/extensions/soft-delete.extension.ts
1791
1808
  var softDeleteExtension = {
@@ -1923,4 +1940,4 @@ var retryExtension = {
1923
1940
  }
1924
1941
  };
1925
1942
 
1926
- export { AbstractDatasource, CHANNELS, ContextHelpersMiddleware, CreateHealthCheckMiddleware, DEFAULT_DATASOURCE_CACHE_TTL, DatasourceMixin, HEALTH_CHECK_DEFAULTS, INTEGRATION_CHANNELS, IntegrationCapability, IntegrationPlatform, IntegrationStatus, MemoizeMixin, MessageContentType, NAMESPACE, PERMISSIONS, PermissionsMiddleware, PrismaDatasource, REDIS_URL, ROLE_PERMISSIONS, UserRole, createDatasourceMiddleware, createTenantExtension, defineIntegration, defineService, env_default as env, isDev, isProd, isTest, moleculer_default as moleculer, nodeEnv, omit, retryExtension, softDeleteExtension };
1943
+ export { AbstractDatasource, CHANNELS, ContextHelpersMiddleware, CreateHealthCheckMiddleware, DEFAULT_DATASOURCE_CACHE_TTL, DatasourceMixin, HEALTH_CHECK_DEFAULTS, INTEGRATION_CHANNELS, IntegrationCapability, IntegrationPlatform, IntegrationStatus, MemoizeMixin, MessageContentType, NAMESPACE, PERMISSIONS, PermissionsMiddleware, PrismaDatasource, PrismaPgDatasource, REDIS_URL, ROLE_PERMISSIONS, UserRole, createDatasourceMiddleware, createTenantExtension, defineIntegration, defineService, env_default as env, isDev, isProd, isTest, moleculer_default as moleculer, nodeEnv, omit, retryExtension, softDeleteExtension };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
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"