@hiliosai/sdk 0.1.23 → 0.1.26
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 +16 -7
- package/dist/index.js +19 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Context, ServiceBroker, ServiceSchema as ServiceSchema$1, ServiceSettingSchema, Service, ActionSchema, ServiceEvents,
|
|
1
|
+
import { Context, ServiceBroker, ServiceSchema as ServiceSchema$1, ServiceSettingSchema, Service, ActionSchema, ServiceEvents, 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
|
|
@@ -480,6 +488,7 @@ declare enum IntegrationPlatform {
|
|
|
480
488
|
FACEBOOK = "facebook",
|
|
481
489
|
DISCORD = "discord",
|
|
482
490
|
WEBCHAT = "webchat",
|
|
491
|
+
ZALO = "zalo",
|
|
483
492
|
CUSTOM = "custom"
|
|
484
493
|
}
|
|
485
494
|
declare enum IntegrationStatus {
|
|
@@ -669,11 +678,11 @@ type ActionSchemaWithContext<TDatasources = unknown, TParams = unknown> = Pick<A
|
|
|
669
678
|
handler: (ctx: AppContext<TDatasources, InferParamsType<TParams>>) => Promise<unknown> | unknown;
|
|
670
679
|
permissions?: string | string[];
|
|
671
680
|
};
|
|
672
|
-
type ActionHandler<TDatasources = unknown> = (ctx: AppContext<TDatasources>) => Promise<unknown> | unknown;
|
|
673
|
-
type ServiceActionsSchema<TDatasources = unknown> = {
|
|
681
|
+
type ActionHandler<TDatasources = unknown> = (this: Service, ctx: AppContext<TDatasources>) => Promise<unknown> | unknown;
|
|
682
|
+
type ServiceActionsSchema<TDatasources = unknown, TSettings = unknown> = {
|
|
674
683
|
[key: string]: ({
|
|
675
684
|
params?: any;
|
|
676
|
-
handler: (ctx: AppContext<TDatasources, any>) => Promise<unknown> | unknown;
|
|
685
|
+
handler: (this: Service<TSettings>, ctx: AppContext<TDatasources, any>) => Promise<unknown> | unknown;
|
|
677
686
|
permissions?: string | string[];
|
|
678
687
|
} & Pick<ActionSchema, 'name' | 'rest' | 'visibility' | 'service' | 'cache' | 'tracing' | 'bulkhead' | 'circuitBreaker' | 'retryPolicy' | 'fallback' | 'hooks'>) | ActionHandler<TDatasources> | false;
|
|
679
688
|
};
|
|
@@ -681,9 +690,9 @@ interface ServiceSchema<TSettings = unknown, TDatasources = unknown> extends Omi
|
|
|
681
690
|
name: string;
|
|
682
691
|
version?: string | number;
|
|
683
692
|
settings?: TSettings;
|
|
684
|
-
actions?: ServiceActionsSchema<TDatasources>;
|
|
693
|
+
actions?: ServiceActionsSchema<TDatasources, TSettings>;
|
|
685
694
|
events?: ServiceEvents;
|
|
686
|
-
methods?:
|
|
695
|
+
methods?: ThisType<Service<TSettings>>;
|
|
687
696
|
hooks?: ServiceHooks;
|
|
688
697
|
dependencies?: string | string[];
|
|
689
698
|
metadata?: Record<string, any>;
|
|
@@ -902,4 +911,4 @@ declare function DatasourceMixin(datasourceConstructors?: DatasourceConstructorR
|
|
|
902
911
|
|
|
903
912
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
904
913
|
|
|
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 };
|
|
914
|
+
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) {
|
|
@@ -1067,6 +1068,7 @@ var IntegrationPlatform = /* @__PURE__ */ ((IntegrationPlatform2) => {
|
|
|
1067
1068
|
IntegrationPlatform2["FACEBOOK"] = "facebook";
|
|
1068
1069
|
IntegrationPlatform2["DISCORD"] = "discord";
|
|
1069
1070
|
IntegrationPlatform2["WEBCHAT"] = "webchat";
|
|
1071
|
+
IntegrationPlatform2["ZALO"] = "zalo";
|
|
1070
1072
|
IntegrationPlatform2["CUSTOM"] = "custom";
|
|
1071
1073
|
return IntegrationPlatform2;
|
|
1072
1074
|
})(IntegrationPlatform || {});
|
|
@@ -1786,6 +1788,22 @@ var PrismaDatasource = class extends AbstractDatasource {
|
|
|
1786
1788
|
}
|
|
1787
1789
|
}
|
|
1788
1790
|
};
|
|
1791
|
+
var PrismaPgDatasource = class extends PrismaDatasource {
|
|
1792
|
+
getConnectionString() {
|
|
1793
|
+
const connectionString = env_default.string("DATABASE_URL");
|
|
1794
|
+
if (!connectionString) {
|
|
1795
|
+
throw new Error("DATABASE_URL is required");
|
|
1796
|
+
}
|
|
1797
|
+
return connectionString;
|
|
1798
|
+
}
|
|
1799
|
+
createAdapter(connectionString) {
|
|
1800
|
+
return new PrismaPg({ connectionString });
|
|
1801
|
+
}
|
|
1802
|
+
createClient() {
|
|
1803
|
+
const adapter = this.createAdapter(this.getConnectionString());
|
|
1804
|
+
return this.createPrismaPgClient(adapter);
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1789
1807
|
|
|
1790
1808
|
// src/datasources/extensions/soft-delete.extension.ts
|
|
1791
1809
|
var softDeleteExtension = {
|
|
@@ -1923,4 +1941,4 @@ var retryExtension = {
|
|
|
1923
1941
|
}
|
|
1924
1942
|
};
|
|
1925
1943
|
|
|
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 };
|
|
1944
|
+
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 };
|