@hiliosai/sdk 0.1.24 → 0.1.27
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 +32 -42
- package/dist/index.js +104 -39
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
import { PrismaPg } from '@prisma/adapter-pg';
|
|
@@ -488,6 +488,7 @@ declare enum IntegrationPlatform {
|
|
|
488
488
|
FACEBOOK = "facebook",
|
|
489
489
|
DISCORD = "discord",
|
|
490
490
|
WEBCHAT = "webchat",
|
|
491
|
+
ZALO = "zalo",
|
|
491
492
|
CUSTOM = "custom"
|
|
492
493
|
}
|
|
493
494
|
declare enum IntegrationStatus {
|
|
@@ -659,29 +660,11 @@ type DatasourceInstanceTypes<T extends Record<string, new (...args: unknown[]) =
|
|
|
659
660
|
[K in keyof T]: InstanceType<T[K]>;
|
|
660
661
|
};
|
|
661
662
|
|
|
662
|
-
type
|
|
663
|
-
|
|
664
|
-
type: 'string';
|
|
665
|
-
} ? string : T[K] extends {
|
|
666
|
-
type: 'number';
|
|
667
|
-
} ? number : T[K] extends {
|
|
668
|
-
type: 'boolean';
|
|
669
|
-
} ? boolean : T[K] extends {
|
|
670
|
-
type: 'array';
|
|
671
|
-
} ? any[] : T[K] extends {
|
|
672
|
-
type: 'object';
|
|
673
|
-
} ? Record<string, any> : unknown;
|
|
674
|
-
} : unknown;
|
|
675
|
-
type ActionSchemaWithContext<TDatasources = unknown, TParams = unknown> = Pick<ActionSchema, 'name' | 'rest' | 'visibility' | 'service' | 'cache' | 'tracing' | 'bulkhead' | 'circuitBreaker' | 'retryPolicy' | 'fallback' | 'hooks'> & {
|
|
676
|
-
params?: TParams;
|
|
677
|
-
handler: (ctx: AppContext<TDatasources, InferParamsType<TParams>>) => Promise<unknown> | unknown;
|
|
678
|
-
permissions?: string | string[];
|
|
679
|
-
};
|
|
680
|
-
type ActionHandler<TDatasources = unknown> = (ctx: AppContext<TDatasources>) => Promise<unknown> | unknown;
|
|
681
|
-
type ServiceActionsSchema<TDatasources = unknown> = {
|
|
663
|
+
type ActionHandler<TDatasources = unknown> = (this: Service, ctx: AppContext<TDatasources>) => Promise<unknown> | unknown;
|
|
664
|
+
type ServiceActionsSchema<TDatasources = unknown, TSettings = unknown> = {
|
|
682
665
|
[key: string]: ({
|
|
683
666
|
params?: any;
|
|
684
|
-
handler: (ctx: AppContext<TDatasources, any>) => Promise<unknown> | unknown;
|
|
667
|
+
handler: (this: Service<TSettings>, ctx: AppContext<TDatasources, any>) => Promise<unknown> | unknown;
|
|
685
668
|
permissions?: string | string[];
|
|
686
669
|
} & Pick<ActionSchema, 'name' | 'rest' | 'visibility' | 'service' | 'cache' | 'tracing' | 'bulkhead' | 'circuitBreaker' | 'retryPolicy' | 'fallback' | 'hooks'>) | ActionHandler<TDatasources> | false;
|
|
687
670
|
};
|
|
@@ -689,9 +672,9 @@ interface ServiceSchema<TSettings = unknown, TDatasources = unknown> extends Omi
|
|
|
689
672
|
name: string;
|
|
690
673
|
version?: string | number;
|
|
691
674
|
settings?: TSettings;
|
|
692
|
-
actions?: ServiceActionsSchema<TDatasources>;
|
|
675
|
+
actions?: ServiceActionsSchema<TDatasources, TSettings>;
|
|
693
676
|
events?: ServiceEvents;
|
|
694
|
-
methods?:
|
|
677
|
+
methods?: ThisType<Service<TSettings>>;
|
|
695
678
|
hooks?: ServiceHooks;
|
|
696
679
|
dependencies?: string | string[];
|
|
697
680
|
metadata?: Record<string, any>;
|
|
@@ -704,11 +687,13 @@ type ServiceConfig<TSettings = unknown, TDatasourceConstructors extends Datasour
|
|
|
704
687
|
};
|
|
705
688
|
interface IntegrationServiceConfig<TSettings = unknown, TDatasourceConstructors extends DatasourceConstructorRegistry = DatasourceConstructorRegistry, TContext extends AppContext<DatasourceInstanceTypes<TDatasourceConstructors>> = AppContext<DatasourceInstanceTypes<TDatasourceConstructors>>> extends ServiceConfig<TSettings, TDatasourceConstructors> {
|
|
706
689
|
name: string;
|
|
690
|
+
version: string;
|
|
707
691
|
spec: BaseSpec;
|
|
708
692
|
normalize<TPayload = any>(webhook: WebhookEvent<TPayload>): Promise<Message[]>;
|
|
709
693
|
getChannelConfig(ctx: TContext, channelId: string): Promise<IntegrationConfig | null>;
|
|
710
694
|
validateWebhook?<TPayload = any>(webhook: WebhookEvent<TPayload>): boolean;
|
|
711
695
|
sendMessage(ctx: TContext, message: Message, config: IntegrationConfig): Promise<SendResult>;
|
|
696
|
+
createChannel<TChannel>(ctx: TContext, integration: TChannel): Promise<boolean>;
|
|
712
697
|
verifyWebhook?(params: {
|
|
713
698
|
mode: string;
|
|
714
699
|
token: string;
|
|
@@ -748,31 +733,36 @@ interface IntegrationServiceSchema<TSettings = unknown> extends ServiceSchema$1<
|
|
|
748
733
|
declare const NAMESPACE: string;
|
|
749
734
|
declare const CHANNELS: {
|
|
750
735
|
readonly WEBHOOK: {
|
|
751
|
-
readonly PATTERN:
|
|
752
|
-
readonly PREFIX:
|
|
736
|
+
readonly PATTERN: "webhook.*.*";
|
|
737
|
+
readonly PREFIX: "webhook";
|
|
753
738
|
readonly build: (tenantId: string, platform: string) => string;
|
|
754
739
|
};
|
|
755
740
|
readonly PROCESSING: {
|
|
756
|
-
readonly PATTERN:
|
|
757
|
-
readonly PREFIX:
|
|
741
|
+
readonly PATTERN: "processing.*.*";
|
|
742
|
+
readonly PREFIX: "processing";
|
|
758
743
|
readonly build: (tenantId: string, messageType: string) => string;
|
|
759
744
|
};
|
|
760
745
|
readonly RESPONSE: {
|
|
761
|
-
readonly PATTERN:
|
|
762
|
-
readonly PREFIX:
|
|
746
|
+
readonly PATTERN: "response.*.*";
|
|
747
|
+
readonly PREFIX: "response";
|
|
763
748
|
readonly build: (tenantId: string, platform: string) => string;
|
|
764
749
|
};
|
|
765
750
|
readonly SYSTEM: {
|
|
766
|
-
readonly ERRORS:
|
|
767
|
-
readonly METRICS:
|
|
768
|
-
readonly HEALTH:
|
|
769
|
-
|
|
770
|
-
|
|
751
|
+
readonly ERRORS: "system.errors";
|
|
752
|
+
readonly METRICS: "system.metrics";
|
|
753
|
+
readonly HEALTH: "system.health";
|
|
754
|
+
};
|
|
755
|
+
readonly INTEGRATION: {
|
|
756
|
+
readonly STARTED: "integration.started";
|
|
757
|
+
readonly STOPPED: "integration.stopped";
|
|
758
|
+
readonly REGISTERED: "integration.registered";
|
|
759
|
+
readonly UNREGISTERED: "integration.unregistered";
|
|
760
|
+
readonly UPDATED: "integration.updated";
|
|
771
761
|
};
|
|
772
762
|
readonly DLQ: {
|
|
773
|
-
readonly WEBHOOK_FAILED:
|
|
774
|
-
readonly SEND_FAILED:
|
|
775
|
-
readonly PROCESSING_FAILED:
|
|
763
|
+
readonly WEBHOOK_FAILED: "dlq.webhook.failed";
|
|
764
|
+
readonly SEND_FAILED: "dlq.send.failed";
|
|
765
|
+
readonly PROCESSING_FAILED: "dlq.processing.failed";
|
|
776
766
|
readonly buildSendFailed: (platform: string) => string;
|
|
777
767
|
};
|
|
778
768
|
};
|
|
@@ -780,9 +770,9 @@ declare const CHANNELS: {
|
|
|
780
770
|
* Integration-specific channel names
|
|
781
771
|
*/
|
|
782
772
|
declare const INTEGRATION_CHANNELS: {
|
|
783
|
-
readonly MESSAGE_RECEIVED:
|
|
784
|
-
readonly MESSAGE_SENT:
|
|
785
|
-
readonly MESSAGE_FAILED:
|
|
773
|
+
readonly MESSAGE_RECEIVED: "processing.message.received";
|
|
774
|
+
readonly MESSAGE_SENT: "processing.message.sent";
|
|
775
|
+
readonly MESSAGE_FAILED: "processing.message.failed";
|
|
786
776
|
};
|
|
787
777
|
type IntegrationChannelName = (typeof INTEGRATION_CHANNELS)[keyof typeof INTEGRATION_CHANNELS];
|
|
788
778
|
|
|
@@ -910,4 +900,4 @@ declare function DatasourceMixin(datasourceConstructors?: DatasourceConstructorR
|
|
|
910
900
|
|
|
911
901
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
912
902
|
|
|
913
|
-
export { AbstractDatasource, type ActionHandler, type
|
|
903
|
+
export { AbstractDatasource, type ActionHandler, 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
|
@@ -682,53 +682,57 @@ var CHANNELS = {
|
|
|
682
682
|
// Webhook processing channels
|
|
683
683
|
WEBHOOK: {
|
|
684
684
|
// Pattern: hios.webhook.{tenantId}.{platform}
|
|
685
|
-
PATTERN:
|
|
686
|
-
PREFIX:
|
|
687
|
-
build: (tenantId, platform) =>
|
|
685
|
+
PATTERN: "webhook.*.*",
|
|
686
|
+
PREFIX: "webhook",
|
|
687
|
+
build: (tenantId, platform) => `webhook.${tenantId}.${platform}`
|
|
688
688
|
},
|
|
689
689
|
// Message processing channels
|
|
690
690
|
PROCESSING: {
|
|
691
691
|
// Pattern: hios.processing.{tenantId}.{messageType}
|
|
692
|
-
PATTERN:
|
|
693
|
-
PREFIX:
|
|
694
|
-
build: (tenantId, messageType) =>
|
|
692
|
+
PATTERN: "processing.*.*",
|
|
693
|
+
PREFIX: "processing",
|
|
694
|
+
build: (tenantId, messageType) => `processing.${tenantId}.${messageType}`
|
|
695
695
|
},
|
|
696
696
|
// Response/outbound message channels
|
|
697
697
|
RESPONSE: {
|
|
698
698
|
// Pattern: hios.response.{tenantId}.{platform}
|
|
699
|
-
PATTERN:
|
|
700
|
-
PREFIX:
|
|
701
|
-
build: (tenantId, platform) =>
|
|
699
|
+
PATTERN: "response.*.*",
|
|
700
|
+
PREFIX: "response",
|
|
701
|
+
build: (tenantId, platform) => `response.${tenantId}.${platform}`
|
|
702
702
|
},
|
|
703
703
|
// System channels
|
|
704
704
|
SYSTEM: {
|
|
705
705
|
// Error handling
|
|
706
|
-
ERRORS:
|
|
706
|
+
ERRORS: "system.errors",
|
|
707
707
|
// Metrics and monitoring
|
|
708
|
-
METRICS:
|
|
708
|
+
METRICS: "system.metrics",
|
|
709
709
|
// Health checks
|
|
710
|
-
HEALTH:
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
710
|
+
HEALTH: "system.health"
|
|
711
|
+
},
|
|
712
|
+
INTEGRATION: {
|
|
713
|
+
STARTED: "integration.started",
|
|
714
|
+
STOPPED: "integration.stopped",
|
|
715
|
+
REGISTERED: "integration.registered",
|
|
716
|
+
UNREGISTERED: "integration.unregistered",
|
|
717
|
+
UPDATED: "integration.updated"
|
|
714
718
|
},
|
|
715
719
|
// Dead letter queues
|
|
716
720
|
DLQ: {
|
|
717
721
|
// Failed webhook processing
|
|
718
|
-
WEBHOOK_FAILED:
|
|
722
|
+
WEBHOOK_FAILED: "dlq.webhook.failed",
|
|
719
723
|
// Failed message sends
|
|
720
|
-
SEND_FAILED:
|
|
724
|
+
SEND_FAILED: "dlq.send.failed",
|
|
721
725
|
// Failed processing
|
|
722
|
-
PROCESSING_FAILED:
|
|
726
|
+
PROCESSING_FAILED: "dlq.processing.failed",
|
|
723
727
|
// Build DLQ name for specific integration
|
|
724
|
-
buildSendFailed: (platform) =>
|
|
728
|
+
buildSendFailed: (platform) => `dlq.send.${platform}.failed`
|
|
725
729
|
}
|
|
726
730
|
};
|
|
727
731
|
var INTEGRATION_CHANNELS = {
|
|
728
732
|
// Message events
|
|
729
|
-
MESSAGE_RECEIVED:
|
|
730
|
-
MESSAGE_SENT:
|
|
731
|
-
MESSAGE_FAILED:
|
|
733
|
+
MESSAGE_RECEIVED: "processing.message.received",
|
|
734
|
+
MESSAGE_SENT: "processing.message.sent",
|
|
735
|
+
MESSAGE_FAILED: "processing.message.failed"
|
|
732
736
|
};
|
|
733
737
|
var CHANNEL_CONFIG = {
|
|
734
738
|
// Default settings for message channels
|
|
@@ -758,15 +762,17 @@ var CHANNEL_CONFIG = {
|
|
|
758
762
|
};
|
|
759
763
|
var SUBJECTS = {
|
|
760
764
|
// All webhook subjects
|
|
761
|
-
WEBHOOK_ALL:
|
|
765
|
+
WEBHOOK_ALL: "webhook.>",
|
|
762
766
|
// All processing subjects
|
|
763
|
-
PROCESSING_ALL:
|
|
767
|
+
PROCESSING_ALL: "processing.>",
|
|
764
768
|
// All response subjects
|
|
765
|
-
RESPONSE_ALL:
|
|
769
|
+
RESPONSE_ALL: "response.>",
|
|
766
770
|
// All system subjects
|
|
767
|
-
SYSTEM_ALL:
|
|
771
|
+
SYSTEM_ALL: "system.>",
|
|
772
|
+
// All integrations subjects
|
|
773
|
+
INTEGRATION_ALL: "integration.>",
|
|
768
774
|
// All DLQ subjects
|
|
769
|
-
DLQ_ALL:
|
|
775
|
+
DLQ_ALL: "dlq.>"};
|
|
770
776
|
|
|
771
777
|
// src/service/define-integration.ts
|
|
772
778
|
var SecurityHelpers = {
|
|
@@ -1011,6 +1017,24 @@ function defineIntegration(config) {
|
|
|
1011
1017
|
}
|
|
1012
1018
|
return true;
|
|
1013
1019
|
}
|
|
1020
|
+
},
|
|
1021
|
+
i_createChannel: {
|
|
1022
|
+
params: {
|
|
1023
|
+
integration: "object"
|
|
1024
|
+
},
|
|
1025
|
+
async handler(ctx) {
|
|
1026
|
+
try {
|
|
1027
|
+
ctx.broker.logger.info(
|
|
1028
|
+
`Creating channel for integration ${config.name}`
|
|
1029
|
+
);
|
|
1030
|
+
await config.createChannel(ctx, ctx.params.integration);
|
|
1031
|
+
} catch (err) {
|
|
1032
|
+
ctx.broker.logger.error(
|
|
1033
|
+
`Failed to create channel for integration ${config.name}`,
|
|
1034
|
+
err
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1014
1038
|
}
|
|
1015
1039
|
};
|
|
1016
1040
|
if (config.actions) {
|
|
@@ -1048,7 +1072,36 @@ function defineIntegration(config) {
|
|
|
1048
1072
|
},
|
|
1049
1073
|
created: config.created,
|
|
1050
1074
|
started: config.started,
|
|
1051
|
-
stopped: config.stopped
|
|
1075
|
+
stopped: config.stopped,
|
|
1076
|
+
mixins: [
|
|
1077
|
+
{
|
|
1078
|
+
started() {
|
|
1079
|
+
this.broker.logger.info("Integration service started");
|
|
1080
|
+
this.broker.emit(CHANNELS.INTEGRATION.STARTED, {
|
|
1081
|
+
name: config.name,
|
|
1082
|
+
version: config.version,
|
|
1083
|
+
spec: config.spec
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
],
|
|
1088
|
+
channels: {
|
|
1089
|
+
[`${CHANNELS.INTEGRATION.REGISTERED}.${config.spec.id}`]: {
|
|
1090
|
+
context: true,
|
|
1091
|
+
handler(ctx, payload) {
|
|
1092
|
+
const integration = payload.json();
|
|
1093
|
+
payload.ackAck().then(() => {
|
|
1094
|
+
ctx.broker.logger.debug("Integration registered", {
|
|
1095
|
+
name: this.name,
|
|
1096
|
+
version: this.version
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
ctx.broker.call(`v${this.version}.${this.name}.i_createChannel`, {
|
|
1100
|
+
integration
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1052
1105
|
});
|
|
1053
1106
|
return {
|
|
1054
1107
|
...baseService,
|
|
@@ -1068,6 +1121,7 @@ var IntegrationPlatform = /* @__PURE__ */ ((IntegrationPlatform2) => {
|
|
|
1068
1121
|
IntegrationPlatform2["FACEBOOK"] = "facebook";
|
|
1069
1122
|
IntegrationPlatform2["DISCORD"] = "discord";
|
|
1070
1123
|
IntegrationPlatform2["WEBCHAT"] = "webchat";
|
|
1124
|
+
IntegrationPlatform2["ZALO"] = "zalo";
|
|
1071
1125
|
IntegrationPlatform2["CUSTOM"] = "custom";
|
|
1072
1126
|
return IntegrationPlatform2;
|
|
1073
1127
|
})(IntegrationPlatform || {});
|
|
@@ -1166,8 +1220,9 @@ var middleware = Middleware({
|
|
|
1166
1220
|
SUBJECTS.PROCESSING_ALL,
|
|
1167
1221
|
SUBJECTS.RESPONSE_ALL,
|
|
1168
1222
|
SUBJECTS.SYSTEM_ALL,
|
|
1169
|
-
SUBJECTS.DLQ_ALL
|
|
1170
|
-
|
|
1223
|
+
SUBJECTS.DLQ_ALL,
|
|
1224
|
+
SUBJECTS.INTEGRATION_ALL
|
|
1225
|
+
].map((subject) => `${NAMESPACE2.toLowerCase()}.${subject}`),
|
|
1171
1226
|
retention: "limits",
|
|
1172
1227
|
max_msgs: env4.int("NATS_MAX_MESSAGES", 1e5),
|
|
1173
1228
|
// 100K for dev, 10M+ for prod
|
|
@@ -1226,9 +1281,7 @@ var middleware = Middleware({
|
|
|
1226
1281
|
}
|
|
1227
1282
|
}
|
|
1228
1283
|
});
|
|
1229
|
-
var ChannelsMiddleware =
|
|
1230
|
-
...middleware
|
|
1231
|
-
};
|
|
1284
|
+
var ChannelsMiddleware = middleware;
|
|
1232
1285
|
|
|
1233
1286
|
// src/configs/moleculer/circuit-breaker.ts
|
|
1234
1287
|
var circuitBreakerConfig = {
|
|
@@ -1507,7 +1560,9 @@ function createTenantExtension() {
|
|
|
1507
1560
|
args.where ?? (args.where = {});
|
|
1508
1561
|
(_a = args.where).tenantId ?? (_a.tenantId = tenantContext.currentTenantId);
|
|
1509
1562
|
} else if (tenantContext.strictMode && !tenantContext.bypassMode && !tenantContext.currentTenantId) {
|
|
1510
|
-
throw new Error(
|
|
1563
|
+
throw new Error(
|
|
1564
|
+
"Tenant context required for this operation. Use $withSystemMode() for system-level operations."
|
|
1565
|
+
);
|
|
1511
1566
|
}
|
|
1512
1567
|
return query(args);
|
|
1513
1568
|
},
|
|
@@ -1517,7 +1572,9 @@ function createTenantExtension() {
|
|
|
1517
1572
|
args.where ?? (args.where = {});
|
|
1518
1573
|
(_a = args.where).tenantId ?? (_a.tenantId = tenantContext.currentTenantId);
|
|
1519
1574
|
} else if (tenantContext.strictMode && !tenantContext.bypassMode && !tenantContext.currentTenantId) {
|
|
1520
|
-
throw new Error(
|
|
1575
|
+
throw new Error(
|
|
1576
|
+
"Tenant context required for this operation. Use $withSystemMode() for system-level operations."
|
|
1577
|
+
);
|
|
1521
1578
|
}
|
|
1522
1579
|
return query(args);
|
|
1523
1580
|
},
|
|
@@ -1527,7 +1584,9 @@ function createTenantExtension() {
|
|
|
1527
1584
|
args.where ?? (args.where = {});
|
|
1528
1585
|
(_a = args.where).tenantId ?? (_a.tenantId = tenantContext.currentTenantId);
|
|
1529
1586
|
} else if (tenantContext.strictMode && !tenantContext.bypassMode && !tenantContext.currentTenantId) {
|
|
1530
|
-
throw new Error(
|
|
1587
|
+
throw new Error(
|
|
1588
|
+
"Tenant context required for this operation. Use $withSystemMode() for system-level operations."
|
|
1589
|
+
);
|
|
1531
1590
|
}
|
|
1532
1591
|
return query(args);
|
|
1533
1592
|
},
|
|
@@ -1538,7 +1597,9 @@ function createTenantExtension() {
|
|
|
1538
1597
|
args.data ?? (args.data = {});
|
|
1539
1598
|
(_a = args.data).tenantId ?? (_a.tenantId = tenantContext.currentTenantId);
|
|
1540
1599
|
} else if (tenantContext.strictMode && !tenantContext.bypassMode && !tenantContext.currentTenantId) {
|
|
1541
|
-
throw new Error(
|
|
1600
|
+
throw new Error(
|
|
1601
|
+
"Tenant context required for this operation. Use $withSystemMode() for system-level operations."
|
|
1602
|
+
);
|
|
1542
1603
|
}
|
|
1543
1604
|
return query(args);
|
|
1544
1605
|
},
|
|
@@ -1549,7 +1610,9 @@ function createTenantExtension() {
|
|
|
1549
1610
|
args.where ?? (args.where = {});
|
|
1550
1611
|
(_a = args.where).tenantId ?? (_a.tenantId = tenantContext.currentTenantId);
|
|
1551
1612
|
} else if (tenantContext.strictMode && !tenantContext.bypassMode && !tenantContext.currentTenantId) {
|
|
1552
|
-
throw new Error(
|
|
1613
|
+
throw new Error(
|
|
1614
|
+
"Tenant context required for this operation. Use $withSystemMode() for system-level operations."
|
|
1615
|
+
);
|
|
1553
1616
|
}
|
|
1554
1617
|
return query(args);
|
|
1555
1618
|
},
|
|
@@ -1560,7 +1623,9 @@ function createTenantExtension() {
|
|
|
1560
1623
|
args.where ?? (args.where = {});
|
|
1561
1624
|
(_a = args.where).tenantId ?? (_a.tenantId = tenantContext.currentTenantId);
|
|
1562
1625
|
} else if (tenantContext.strictMode && !tenantContext.bypassMode && !tenantContext.currentTenantId) {
|
|
1563
|
-
throw new Error(
|
|
1626
|
+
throw new Error(
|
|
1627
|
+
"Tenant context required for this operation. Use $withSystemMode() for system-level operations."
|
|
1628
|
+
);
|
|
1564
1629
|
}
|
|
1565
1630
|
return query(args);
|
|
1566
1631
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hiliosai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"@hiliosai/typescript": "workspace:*",
|
|
30
30
|
"@pkg/dev-utils": "workspace:*",
|
|
31
31
|
"@prisma/adapter-pg": "7.2.0",
|
|
32
|
-
"bun-types": "latest"
|
|
32
|
+
"bun-types": "latest",
|
|
33
|
+
"nats": "2.29.3"
|
|
33
34
|
},
|
|
34
35
|
"prettier": "@hiliosai/prettier"
|
|
35
36
|
}
|