@hiliosai/sdk 0.1.29 → 0.2.0

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,7 +1,8 @@
1
- import { Context, ServiceBroker, ServiceSchema as ServiceSchema$1, ServiceSettingSchema, Service, ActionSchema, ServiceEvents, ServiceHooks, Middleware, BrokerOptions } from 'moleculer';
1
+ import { Context, ServiceBroker, ServiceSchema as ServiceSchema$1, ServiceSettingSchema, Service, ActionSchema, ServiceEvents, ServiceHooks, Middleware, BrokerOptions, Errors, BrokerErrorHandlerInfoAction } 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';
5
+ import { IncomingMessage, ServerResponse } from 'http';
5
6
 
6
7
  interface Tenant {
7
8
  id: string;
@@ -900,4 +901,79 @@ declare function DatasourceMixin(datasourceConstructors?: DatasourceConstructorR
900
901
 
901
902
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
902
903
 
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 };
904
+ declare class PermissionError extends Error {
905
+ readonly code = "PERMISSION_DENIED";
906
+ readonly statusCode = 403;
907
+ readonly data: Record<string, unknown> | undefined;
908
+ constructor(message: string, data?: Record<string, unknown>);
909
+ }
910
+
911
+ declare class AuthenticationError extends Error {
912
+ readonly code = "AUTH_REQUIRED";
913
+ readonly statusCode = 401;
914
+ readonly data: Record<string, unknown> | undefined;
915
+ constructor(message: string, data?: Record<string, unknown>);
916
+ }
917
+ declare class TenantError extends Error {
918
+ readonly code = "TENANT_REQUIRED";
919
+ readonly statusCode = 401;
920
+ readonly data: Record<string, unknown> | undefined;
921
+ constructor(message: string, data?: Record<string, unknown>);
922
+ }
923
+
924
+ interface GatewayError extends Error {
925
+ code?: string | number;
926
+ statusCode?: number;
927
+ type?: string;
928
+ data?: any;
929
+ }
930
+ /**
931
+ * Custom error handler for the API Gateway
932
+ * Formats errors based on enterprise standards (Stripe, Google Cloud, AWS)
933
+ *
934
+ * Example response:
935
+ * {
936
+ * "error": {
937
+ * "code": "UNIQUE_VIOLATION",
938
+ * "message": "Unique constraint violation",
939
+ * "details": [{
940
+ * "field": "email",
941
+ * "constraint": "unique",
942
+ * "reason": "The value must be unique"
943
+ * }],
944
+ * "timestamp": "2024-01-27T10:30:00Z",
945
+ * "path": "/api/users",
946
+ * "requestId": "req_abc123",
947
+ * "help": "/docs/errors#unique-constraint"
948
+ * }
949
+ * }
950
+ */
951
+ declare const gatewayErrorHandler: (req: IncomingMessage & {
952
+ $ctx?: AppContext;
953
+ originalUrl?: string;
954
+ }, res: ServerResponse, error: GatewayError) => void;
955
+
956
+ declare class DBError extends Errors.MoleculerError {
957
+ constructor(message: string, code: number, type?: string, data?: unknown);
958
+ }
959
+ declare class DBValidationError extends Errors.MoleculerError {
960
+ constructor(message: string, type?: string, data?: unknown, code?: number);
961
+ }
962
+ declare class DBConstraintError extends Errors.MoleculerError {
963
+ constructor(message: string, type?: string, data?: unknown);
964
+ }
965
+ declare class DBNotFoundError extends Errors.MoleculerError {
966
+ constructor(message: string, data?: unknown);
967
+ }
968
+ declare class DBConnectionError extends Errors.MoleculerError {
969
+ constructor(message: string, data?: unknown);
970
+ }
971
+ declare class DBTimeoutError extends Errors.MoleculerError {
972
+ constructor(message: string, data?: unknown);
973
+ }
974
+ declare class DBTransactionError extends Errors.MoleculerError {
975
+ constructor(message: string, data?: unknown);
976
+ }
977
+ declare const prismaErrorHandler: (err: Error, info: BrokerErrorHandlerInfoAction) => undefined;
978
+
979
+ export { AbstractDatasource, type ActionHandler, type ActionWithPermissions, type AppContext, type AppMeta, type AuditTrailExtension, AuthenticationError, type BaseDatasource, type BaseSpec, CHANNELS, type CarouselItem, type ChannelSendOptions, ContextHelpersMiddleware, CreateHealthCheckMiddleware, DBConnectionError, DBConstraintError, DBError, DBNotFoundError, DBTimeoutError, DBTransactionError, DBValidationError, DEFAULT_DATASOURCE_CACHE_TTL, type DatasourceConstructorRegistry, type DatasourceContext, type DatasourceInstanceRegistry, type DatasourceInstanceTypes, DatasourceMixin, type Env, type GatewayError, 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, PermissionError, 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, TenantError, type TenantExtension, type User, UserRole, type WebhookEvent, createDatasourceMiddleware, createTenantExtension, defineIntegration, defineService, gatewayErrorHandler, isDev, isProd, isTest, configs as moleculer, nodeEnv, omit, prismaErrorHandler, retryExtension, softDeleteExtension };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import env4 from '@ltv/env';
2
2
  import http from 'http';
3
+ import { PrismaClientValidationError, PrismaClientInitializationError, PrismaClientUnknownRequestError, PrismaClientRustPanicError, PrismaClientKnownRequestError } from '@prisma/client/runtime/client';
4
+ import { Errors } from 'moleculer';
3
5
  import crypto from 'crypto';
4
6
  import os from 'os';
5
7
  import { Middleware } from '@moleculer/channels';
@@ -297,6 +299,421 @@ var TenantError = class _TenantError extends Error {
297
299
  }
298
300
  };
299
301
 
302
+ // src/errors/gateway.error.ts
303
+ var gatewayErrorHandler = (req, res, error) => {
304
+ res.setHeader("Content-Type", "application/json; charset=utf-8");
305
+ const statusCode = error.code ?? error.statusCode ?? 500;
306
+ res.writeHead(statusCode);
307
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
308
+ const requestId = req.$ctx?.id ?? req.$ctx?.requestID;
309
+ const path = req.originalUrl ?? req.url;
310
+ const docLinks = {
311
+ UNIQUE_VIOLATION: "/docs/errors#unique-constraint",
312
+ FOREIGN_KEY_VIOLATION: "/docs/errors#foreign-key",
313
+ VALIDATION_ERROR: "/docs/errors#validation",
314
+ NOT_FOUND: "/docs/errors#not-found",
315
+ MISSING_REQUIRED_VALUE: "/docs/errors#required-fields",
316
+ VALUE_TOO_LONG: "/docs/errors#field-length",
317
+ VALUE_OUT_OF_RANGE: "/docs/errors#value-range",
318
+ DB_CONNECTION_ERROR: "/docs/errors#connection",
319
+ DB_TIMEOUT: "/docs/errors#timeout",
320
+ TRANSACTION_ERROR: "/docs/errors#transaction"
321
+ };
322
+ const details = [];
323
+ if (error.data?.field) {
324
+ details.push({
325
+ field: error.data.field,
326
+ constraint: error.data.constraint,
327
+ reason: error.data.reason ?? error.message,
328
+ value: error.data.value
329
+ });
330
+ }
331
+ if (error.data?.errors && Array.isArray(error.data.errors)) {
332
+ error.data.errors.forEach((e) => {
333
+ details.push({
334
+ field: e.field ?? e.path,
335
+ reason: e.message ?? e.reason,
336
+ constraint: e.code ?? e.type
337
+ });
338
+ });
339
+ }
340
+ const errorCode = error.type ?? (error.name || "INTERNAL_ERROR");
341
+ const response = {
342
+ error: {
343
+ code: errorCode,
344
+ message: error.message || "An unexpected error occurred",
345
+ ...details.length > 0 && { details },
346
+ timestamp,
347
+ ...path && { path },
348
+ ...requestId && { requestId },
349
+ ...docLinks[errorCode] && { help: docLinks[errorCode] }
350
+ }
351
+ };
352
+ res.end(JSON.stringify(response));
353
+ };
354
+ var DBError = class extends Errors.MoleculerError {
355
+ constructor(message, code, type = "DB_ERROR", data) {
356
+ super(message, code, type, data);
357
+ }
358
+ };
359
+ var DBValidationError = class extends Errors.MoleculerError {
360
+ constructor(message, type = "VALIDATION_ERROR", data, code = 422) {
361
+ super(message, code, type, data);
362
+ }
363
+ };
364
+ var DBConstraintError = class extends Errors.MoleculerError {
365
+ constructor(message, type = "CONSTRAINT_ERROR", data) {
366
+ super(message, 409, type, data);
367
+ }
368
+ };
369
+ var DBNotFoundError = class extends Errors.MoleculerError {
370
+ constructor(message, data) {
371
+ super(message, 404, "NOT_FOUND", data);
372
+ }
373
+ };
374
+ var DBConnectionError = class extends Errors.MoleculerError {
375
+ constructor(message, data) {
376
+ super(message, 503, "DB_CONNECTION_ERROR", data);
377
+ }
378
+ };
379
+ var DBTimeoutError = class extends Errors.MoleculerError {
380
+ constructor(message, data) {
381
+ super(message, 504, "DB_TIMEOUT", data);
382
+ }
383
+ };
384
+ var DBTransactionError = class extends Errors.MoleculerError {
385
+ constructor(message, data) {
386
+ super(message, 500, "TRANSACTION_ERROR", data);
387
+ }
388
+ };
389
+ var prismaErrorHandlers = {
390
+ P2002: (err, ctx) => {
391
+ throw new DBConstraintError(
392
+ "Unique constraint violation",
393
+ "UNIQUE_VIOLATION",
394
+ {
395
+ field: err.meta?.target ?? err.meta?.field_name,
396
+ constraint: "unique",
397
+ reason: `The value must be unique`,
398
+ prismaCode: err.code,
399
+ originalError: err.message,
400
+ requestId: ctx.id
401
+ }
402
+ );
403
+ },
404
+ P2003: (err, ctx) => {
405
+ throw new DBConstraintError(
406
+ "Foreign key constraint failed",
407
+ "FOREIGN_KEY_VIOLATION",
408
+ {
409
+ field: err.meta?.field_name,
410
+ original: err.message,
411
+ ctx: ctx.id
412
+ }
413
+ );
414
+ },
415
+ P2014: (err, ctx) => {
416
+ throw new DBConstraintError(
417
+ "Invalid relation reference",
418
+ "INVALID_RELATION",
419
+ {
420
+ relation: err.meta?.relation_name,
421
+ original: err.message,
422
+ ctx: ctx.id
423
+ }
424
+ );
425
+ },
426
+ P2000: (err, ctx) => {
427
+ throw new DBValidationError("Value too long for column", "VALUE_TOO_LONG", {
428
+ column: err.meta?.column_name,
429
+ original: err.message,
430
+ ctx: ctx.id
431
+ });
432
+ },
433
+ P2001: (err, ctx) => {
434
+ throw new DBNotFoundError("Record not found in where condition", {
435
+ model: err.meta?.model_name,
436
+ original: err.message,
437
+ ctx: ctx.id
438
+ });
439
+ },
440
+ P2004: (err, ctx) => {
441
+ throw new DBConstraintError(
442
+ "Database constraint failed",
443
+ "CONSTRAINT_FAILED",
444
+ {
445
+ constraint: err.meta?.constraint,
446
+ original: err.message,
447
+ ctx: ctx.id
448
+ }
449
+ );
450
+ },
451
+ P2021: (err, ctx) => {
452
+ throw new DBError("Table does not exist", 500, "TABLE_NOT_FOUND", {
453
+ table: err.meta?.table,
454
+ original: err.message,
455
+ ctx: ctx.id
456
+ });
457
+ },
458
+ P2022: (err, ctx) => {
459
+ throw new DBError("Column does not exist", 500, "COLUMN_NOT_FOUND", {
460
+ column: err.meta?.column,
461
+ original: err.message,
462
+ ctx: ctx.id
463
+ });
464
+ },
465
+ P2006: (err, ctx) => {
466
+ throw new DBValidationError("Invalid value for field", "INVALID_VALUE", {
467
+ field: err.meta?.field_name,
468
+ original: err.message,
469
+ ctx: ctx.id
470
+ });
471
+ },
472
+ P2007: (err, ctx) => {
473
+ throw new DBValidationError(
474
+ "Data validation error",
475
+ "DATA_VALIDATION_ERROR",
476
+ {
477
+ original: err.message,
478
+ ctx: ctx.id
479
+ }
480
+ );
481
+ },
482
+ P2008: (err, ctx) => {
483
+ throw new DBError("Failed to parse the query", 400, "QUERY_PARSE_ERROR", {
484
+ original: err.message,
485
+ ctx: ctx.id
486
+ });
487
+ },
488
+ P2009: (err, ctx) => {
489
+ throw new DBError(
490
+ "Failed to validate the query",
491
+ 400,
492
+ "QUERY_VALIDATION_ERROR",
493
+ {
494
+ original: err.message,
495
+ ctx: ctx.id
496
+ }
497
+ );
498
+ },
499
+ P2010: (err, ctx) => {
500
+ throw new DBError("Raw query failed", 500, "RAW_QUERY_FAILED", {
501
+ code: err.meta?.code,
502
+ original: err.message,
503
+ ctx: ctx.id
504
+ });
505
+ },
506
+ P2011: (err, ctx) => {
507
+ throw new DBConstraintError(
508
+ "Null constraint violation",
509
+ "NULL_CONSTRAINT_VIOLATION",
510
+ {
511
+ constraint: err.meta?.constraint,
512
+ original: err.message,
513
+ ctx: ctx.id
514
+ }
515
+ );
516
+ },
517
+ P2012: (err, ctx) => {
518
+ throw new DBValidationError(
519
+ "Missing a required value",
520
+ "MISSING_REQUIRED_VALUE",
521
+ {
522
+ field: err.meta?.field_name,
523
+ original: err.message,
524
+ ctx: ctx.id
525
+ }
526
+ );
527
+ },
528
+ P2013: (err, ctx) => {
529
+ throw new DBValidationError(
530
+ "Missing the required argument",
531
+ "MISSING_REQUIRED_ARGUMENT",
532
+ {
533
+ argument: err.meta?.argument_name,
534
+ original: err.message,
535
+ ctx: ctx.id
536
+ }
537
+ );
538
+ },
539
+ P2015: (err, ctx) => {
540
+ throw new DBNotFoundError("Related record not found", {
541
+ original: err.message,
542
+ ctx: ctx.id
543
+ });
544
+ },
545
+ P2016: (err, ctx) => {
546
+ throw new DBError(
547
+ "Query interpretation error",
548
+ 400,
549
+ "QUERY_INTERPRETATION_ERROR",
550
+ {
551
+ original: err.message,
552
+ ctx: ctx.id
553
+ }
554
+ );
555
+ },
556
+ P2017: (err, ctx) => {
557
+ throw new DBConstraintError(
558
+ "Records relation violation",
559
+ "RELATION_VIOLATION",
560
+ {
561
+ relation: err.meta?.relation_name,
562
+ original: err.message,
563
+ ctx: ctx.id
564
+ }
565
+ );
566
+ },
567
+ P2018: (err, ctx) => {
568
+ throw new DBNotFoundError("Required connected records not found", {
569
+ original: err.message,
570
+ ctx: ctx.id
571
+ });
572
+ },
573
+ P2019: (err, ctx) => {
574
+ throw new DBValidationError("Input error", "INPUT_ERROR", {
575
+ original: err.message,
576
+ ctx: ctx.id
577
+ });
578
+ },
579
+ P2020: (err, ctx) => {
580
+ throw new DBValidationError("Value out of range", "VALUE_OUT_OF_RANGE", {
581
+ original: err.message,
582
+ ctx: ctx.id
583
+ });
584
+ },
585
+ P2023: (err, ctx) => {
586
+ throw new DBError(
587
+ "Inconsistent column data",
588
+ 500,
589
+ "INCONSISTENT_COLUMN_DATA",
590
+ {
591
+ original: err.message,
592
+ ctx: ctx.id
593
+ }
594
+ );
595
+ },
596
+ P2024: (err, ctx) => {
597
+ throw new DBTimeoutError("Operation timed out", {
598
+ original: err.message,
599
+ ctx: ctx.id
600
+ });
601
+ },
602
+ P2025: (err, ctx) => {
603
+ throw new DBNotFoundError("Record not found for required operation", {
604
+ operation: err.meta?.operation_name,
605
+ model: err.meta?.model_name,
606
+ original: err.message,
607
+ ctx: ctx.id
608
+ });
609
+ },
610
+ P2026: (err, ctx) => {
611
+ throw new DBError("Unsupported feature", 501, "UNSUPPORTED_FEATURE", {
612
+ feature: err.meta?.feature,
613
+ original: err.message,
614
+ ctx: ctx.id
615
+ });
616
+ },
617
+ P2027: (err, ctx) => {
618
+ throw new DBError(
619
+ "Multiple database errors during execution",
620
+ 500,
621
+ "MULTIPLE_DB_ERRORS",
622
+ {
623
+ original: err.message,
624
+ ctx: ctx.id
625
+ }
626
+ );
627
+ },
628
+ P2028: (err, ctx) => {
629
+ throw new DBTransactionError("Transaction API error", {
630
+ original: err.message,
631
+ ctx: ctx.id
632
+ });
633
+ },
634
+ P2030: (err, ctx) => {
635
+ throw new DBError(
636
+ "Cannot find fulltext index",
637
+ 500,
638
+ "FULLTEXT_INDEX_NOT_FOUND",
639
+ {
640
+ original: err.message,
641
+ ctx: ctx.id
642
+ }
643
+ );
644
+ },
645
+ P2033: (err, ctx) => {
646
+ throw new DBValidationError("Number out of range", "NUMBER_OUT_OF_RANGE", {
647
+ field: err.meta?.field_name,
648
+ original: err.message,
649
+ ctx: ctx.id
650
+ });
651
+ },
652
+ P2034: (err, ctx) => {
653
+ throw new DBTransactionError("Transaction conflict", {
654
+ original: err.message,
655
+ ctx: ctx.id
656
+ });
657
+ }
658
+ };
659
+ var prismaErrorHandler = (err, info) => {
660
+ const { ctx, service, action } = info;
661
+ if (err instanceof PrismaClientValidationError) {
662
+ throw new DBValidationError("Invalid input data", "INVALID_INPUT_DATA", {
663
+ original: err.message,
664
+ ctx: ctx.id,
665
+ service: service?.name,
666
+ action: action?.name
667
+ });
668
+ }
669
+ if (err instanceof PrismaClientInitializationError) {
670
+ throw new DBConnectionError("Database initialization failed", {
671
+ original: err.message,
672
+ ctx: ctx.id,
673
+ service: service?.name,
674
+ action: action?.name
675
+ });
676
+ }
677
+ if (err instanceof PrismaClientUnknownRequestError) {
678
+ throw new DBError("Unknown database error", 500, "DB_UNKNOWN_ERROR", {
679
+ original: err.message,
680
+ ctx: ctx.id,
681
+ service: service?.name,
682
+ action: action?.name
683
+ });
684
+ }
685
+ if (err instanceof PrismaClientRustPanicError) {
686
+ throw new DBError("Database engine panic", 500, "DB_ENGINE_PANIC", {
687
+ original: err.message,
688
+ ctx: ctx.id,
689
+ service: service?.name,
690
+ action: action?.name
691
+ });
692
+ }
693
+ if (err instanceof PrismaClientKnownRequestError) {
694
+ const handler = prismaErrorHandlers[err.code];
695
+ if (handler) {
696
+ return handler(err, ctx);
697
+ }
698
+ throw new DBError(
699
+ "Unknown database constraint error",
700
+ 500,
701
+ "DB_CONSTRAINT_ERROR",
702
+ {
703
+ code: err.code,
704
+ meta: err.meta,
705
+ original: err.message,
706
+ ctx: ctx.id,
707
+ service: service?.name,
708
+ action: action?.name
709
+ }
710
+ );
711
+ }
712
+ if (err instanceof Errors.MoleculerError) {
713
+ throw err;
714
+ }
715
+ };
716
+
300
717
  // src/middlewares/permissions.middleware.ts
301
718
  var permissionHandlers = {
302
719
  [PERMISSIONS.AUTHENTICATED]: async (ctx) => !!ctx.meta.user?.id,
@@ -1099,8 +1516,7 @@ function defineIntegration(config) {
1099
1516
  credentials: integrationRaw.credentials
1100
1517
  };
1101
1518
  const createChannelAction = `v${this.version}.${this.name}.i_createChannel`;
1102
- await ctx.broker.call(createChannelAction, { integration });
1103
- payload.ackAck().then(
1519
+ await ctx.broker.call(createChannelAction, { integration }).then(() => payload.ackAck()).then(
1104
1520
  () => ctx.broker.logger.debug("Integration registered", {
1105
1521
  name: this.name,
1106
1522
  version: this.version
@@ -1435,7 +1851,23 @@ var configs = {
1435
1851
  ChannelsMiddleware,
1436
1852
  PermissionsMiddleware,
1437
1853
  ContextHelpersMiddleware
1438
- ]
1854
+ ],
1855
+ errorHandler: (err, info) => {
1856
+ prismaErrorHandler(err, info);
1857
+ const { ctx, service, action } = info;
1858
+ throw new Errors.MoleculerError(
1859
+ err.message || "Internal server error",
1860
+ 500,
1861
+ "INTERNAL_ERROR",
1862
+ {
1863
+ original: err.message,
1864
+ stack: err.stack,
1865
+ ctx: ctx.id,
1866
+ service: service?.name,
1867
+ action: action?.name
1868
+ }
1869
+ );
1870
+ }
1439
1871
  };
1440
1872
  var moleculer_default = configs;
1441
1873
 
@@ -2012,4 +2444,4 @@ var retryExtension = {
2012
2444
  }
2013
2445
  };
2014
2446
 
2015
- 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 };
2447
+ export { AbstractDatasource, AuthenticationError, CHANNELS, ContextHelpersMiddleware, CreateHealthCheckMiddleware, DBConnectionError, DBConstraintError, DBError, DBNotFoundError, DBTimeoutError, DBTransactionError, DBValidationError, DEFAULT_DATASOURCE_CACHE_TTL, DatasourceMixin, HEALTH_CHECK_DEFAULTS, INTEGRATION_CHANNELS, IntegrationCapability, IntegrationPlatform, IntegrationStatus, MemoizeMixin, MessageContentType, NAMESPACE, PERMISSIONS, PermissionError, PermissionsMiddleware, PrismaDatasource, PrismaPgDatasource, REDIS_URL, ROLE_PERMISSIONS, TenantError, UserRole, createDatasourceMiddleware, createTenantExtension, defineIntegration, defineService, env_default as env, gatewayErrorHandler, isDev, isProd, isTest, moleculer_default as moleculer, nodeEnv, omit, prismaErrorHandler, retryExtension, softDeleteExtension };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.29",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",
@@ -29,8 +29,9 @@
29
29
  "@hiliosai/typescript": "workspace:*",
30
30
  "@pkg/dev-utils": "workspace:*",
31
31
  "@prisma/adapter-pg": "7.2.0",
32
+ "@prisma/client": "7.2.0",
32
33
  "bun-types": "latest",
33
34
  "nats": "2.29.3"
34
35
  },
35
36
  "prettier": "@hiliosai/prettier"
36
- }
37
+ }