@plyaz/types 1.27.13 → 1.27.14

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.
@@ -5,28 +5,15 @@
5
5
  * Services must implement these interfaces to be auto-initialized.
6
6
  */
7
7
  import type { ApiClientOptions } from '../../api';
8
- import type { FeatureFlagValue, FeatureFlagPollingConfig, CacheStrategyType } from '../../features';
8
+ import type { FeatureFlagValue, FeatureFlagPollingConfig } from '../../features';
9
9
  import type { PackageErrorLike, MessageCatalog } from '../../errors';
10
10
  import type { GlobalErrorHandlerConfig, ErrorHandlerLogger } from '../../errors/middleware';
11
11
  import type { RootStoreSlice } from '../../store';
12
12
  import type { CoreAppEnvironment, CoreAppContext, CoreRuntimeEnvironment, CoreServiceRuntime } from '../modules';
13
- import type { CoreDbServiceConfig } from '../services';
13
+ import type { CoreDbServiceConfig, CoreCacheConfig, CoreStorageConfig, CoreNotificationConfig } from '../services';
14
14
  import type { CoreInjectedServices } from '../domain';
15
- import type { StorageServiceConfig } from '../../storage';
16
- import type { NotificationServiceConfig } from '../../notifications';
17
15
  import type { MonitoringObservabilityAdapter, MonitoringAdapterWithPriority } from '../../observability';
18
- /**
19
- * Storage service configuration for Core initialization.
20
- * Uses the StorageServiceConfig from @plyaz/storage.
21
- * Backend-only - not available in browser/frontend runtimes.
22
- */
23
- export type CoreStorageConfig = StorageServiceConfig;
24
- /**
25
- * Notification service configuration for Core initialization.
26
- * Uses the NotificationServiceConfig from @plyaz/notifications.
27
- * Backend-only - not available in browser/frontend runtimes.
28
- */
29
- export type CoreNotificationConfig = NotificationServiceConfig;
16
+ export type { CoreCacheConfig, CoreStorageConfig, CoreNotificationConfig } from '../services';
30
17
  /**
31
18
  * Base interface that all domain service instances must implement.
32
19
  * This allows the registry to manage services generically.
@@ -676,36 +663,6 @@ export interface CoreErrorHandlerInitConfig extends Omit<GlobalErrorHandlerConfi
676
663
  replaceBuiltIn?: boolean;
677
664
  };
678
665
  }
679
- /**
680
- * Cache initialization configuration
681
- */
682
- export interface CoreCacheConfig {
683
- /** Cache strategy to use */
684
- strategy: CacheStrategyType;
685
- /** Whether caching is enabled (default: true) */
686
- isEnabled: boolean;
687
- /** Default TTL in seconds (default: 300 - 5 minutes) */
688
- ttl?: number;
689
- /** Key prefix for all cache entries (default: 'app') */
690
- prefix?: string;
691
- /** Redis-specific configuration (required when strategy is 'redis') */
692
- redis?: {
693
- /** Redis connection URL (e.g., redis://localhost:6379) */
694
- url?: string;
695
- /** Redis host (alternative to url) */
696
- host?: string;
697
- /** Redis port (default: 6379) */
698
- port?: number;
699
- /** Redis password */
700
- password?: string;
701
- /** Redis database number (default: 0) */
702
- db?: number;
703
- /** Connection timeout in milliseconds */
704
- connectTimeout?: number;
705
- /** Key prefix for Redis keys */
706
- keyPrefix?: string;
707
- };
708
- }
709
666
  /**
710
667
  * Observability initialization configuration
711
668
  */
@@ -5,6 +5,27 @@
5
5
  import type { DrizzleConfig, SupabaseConfig, SqlConfig, SoftDeleteConfig, DBCacheConfig, AuditConfig, DBEncryptionConfig } from '../../db';
6
6
  import type { ReactNode } from 'react';
7
7
  import type { ApiClientOptions } from '../../api/client';
8
+ import type { StorageServiceConfig } from '../../storage';
9
+ import type { NotificationServiceConfig } from '../../notifications';
10
+ import type { CacheStrategyType } from '../../features';
11
+ import type { BackendErrorStore, BackendErrorStoreConfig, HttpErrorHandlerConfig } from '../../errors/middleware';
12
+ export interface CoreCacheConfig {
13
+ strategy: CacheStrategyType;
14
+ isEnabled: boolean;
15
+ ttl?: number;
16
+ prefix?: string;
17
+ redis?: {
18
+ url?: string;
19
+ host?: string;
20
+ port?: number;
21
+ password?: string;
22
+ db?: number;
23
+ connectTimeout?: number;
24
+ keyPrefix?: string;
25
+ };
26
+ }
27
+ export type CoreStorageConfig = StorageServiceConfig;
28
+ export type CoreNotificationConfig = NotificationServiceConfig;
8
29
  /**
9
30
 
10
31
  /**
@@ -518,11 +539,9 @@ export interface CoreDbServiceConfig {
518
539
  */
519
540
  export interface CoreDbServiceInstance {
520
541
  /** Get the underlying database instance */
521
- getDatabase(): CoreDatabaseInstance | undefined;
522
- /** Execute a raw SQL query */
523
- query<T = unknown>(sql: string, params?: unknown[]): Promise<T[]>;
524
- /** Begin a transaction */
525
- transaction<T>(fn: (tx: unknown) => Promise<T>): Promise<T>;
542
+ getDatabase(adapterName?: string): CoreDatabaseInstance | undefined;
543
+ /** Close all database connections */
544
+ close(): Promise<void>;
526
545
  }
527
546
  /** Core's database instance interface (from @plyaz/db) */
528
547
  export interface CoreDatabaseInstance {
@@ -569,60 +588,42 @@ export interface CoreNotificationServiceInstance {
569
588
  /** Close/cleanup the notification service */
570
589
  close(): Promise<void>;
571
590
  }
572
- /**
573
- * DbService class interface (static methods)
574
- * Describes the DbService class, not an instance
575
- */
576
- export interface CoreDbServiceClass {
577
- initialize(config: CoreDbServiceConfig): Promise<CoreDbServiceInstance>;
591
+ export interface CoreDbServiceStatic {
592
+ initialize(config?: CoreDbServiceConfig): Promise<CoreDbServiceInstance>;
578
593
  getInstance(): CoreDbServiceInstance;
579
- createInstance?(config: CoreDbServiceConfig): Promise<CoreDbServiceInstance>;
580
- reset?(): void;
594
+ createInstance?(config?: CoreDbServiceConfig): Promise<CoreDbServiceInstance>;
595
+ reset?(): Promise<void>;
581
596
  }
582
- /**
583
- * CacheService class interface (static methods)
584
- * Describes the CacheService class, not an instance
585
- * Note: config uses unknown to avoid circular imports with init/types.ts
586
- */
587
- export interface CoreCacheServiceClass {
588
- initialize(config: unknown): Promise<void>;
597
+ export interface CoreCacheServiceStatic<TConfig = CoreCacheConfig> {
598
+ initialize(config: TConfig): Promise<void>;
589
599
  getInstance(): CoreCacheServiceInstance;
590
600
  reset?(): void;
591
601
  }
592
- /**
593
- * StorageService class interface (static methods)
594
- * Describes the StorageService class, not an instance
595
- * Note: config uses unknown to avoid circular imports with init/types.ts
596
- */
597
- export interface CoreStorageServiceClass {
598
- initialize(config: unknown): Promise<void>;
602
+ export interface CoreStorageServiceStatic<TConfig = CoreStorageConfig> {
603
+ initialize(config: TConfig): Promise<CoreStorageServiceInstance>;
599
604
  getInstance(): CoreStorageServiceInstance;
600
- createInstance?(config: unknown): Promise<CoreStorageServiceInstance>;
605
+ createInstance?(config: TConfig): Promise<CoreStorageServiceInstance>;
601
606
  reset?(): Promise<void>;
602
607
  }
603
- /**
604
- * NotificationService class interface (static methods)
605
- * Describes the NotificationService class, not an instance
606
- * Note: config uses unknown to avoid circular imports with init/types.ts
607
- */
608
- export interface CoreNotificationServiceClass {
609
- initialize(config: unknown): Promise<void>;
608
+ export interface CoreNotificationServiceStatic<TConfig = CoreNotificationConfig> {
609
+ initialize(config: TConfig): Promise<CoreNotificationServiceInstance>;
610
610
  getInstance(): CoreNotificationServiceInstance;
611
- createInstance?(config: unknown): Promise<CoreNotificationServiceInstance>;
611
+ createInstance?(config: TConfig): Promise<CoreNotificationServiceInstance>;
612
612
  reset?(): Promise<void>;
613
613
  }
614
614
  /**
615
- * ServerErrorMiddleware module interface
616
- * Describes the exports from @plyaz/errors/middleware/backend
615
+ * Minimal interface compatible with Next.js NextRequest
616
+ * Used to type withErrorHandler without importing 'next/server'
617
617
  */
618
- export interface CoreServerErrorMiddlewareModule {
619
- createErrorStore(config: {
620
- packageName: string;
621
- serviceName?: string;
622
- }): unknown;
623
- createHttpErrorHandler(config: unknown): unknown;
624
- createNestJsExceptionFilter(config: unknown): unknown;
625
- withErrorHandler<T extends (...args: unknown[]) => unknown>(handler: T, config?: unknown): T;
626
- createNextApiErrorHandler(config: unknown): unknown;
627
- handleNodeError(error: unknown, req: unknown, res: unknown, config?: unknown): void;
618
+ export interface NextRequestLike extends Request {
619
+ nextUrl: URL;
620
+ }
621
+ export interface CoreServerErrorMiddlewareStatic {
622
+ createErrorStore(config?: BackendErrorStoreConfig): BackendErrorStore;
623
+ createHttpErrorHandler(config?: HttpErrorHandlerConfig): unknown;
624
+ createNestJsExceptionFilter(config?: Record<string, unknown>): unknown;
625
+ withErrorHandler: <TReq extends NextRequestLike>(handler: (req: TReq, context?: unknown) => Promise<Response>, config?: HttpErrorHandlerConfig) => (req: TReq, context?: unknown) => Promise<Response>;
626
+ createNextApiErrorHandler(config?: HttpErrorHandlerConfig): unknown;
627
+ handleNodeError(error: unknown, req: unknown, res: unknown, config?: HttpErrorHandlerConfig): void;
628
628
  }
629
+ export type { BackendErrorStore, BackendErrorStoreConfig, HttpErrorHandlerConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.27.13",
3
+ "version": "1.27.14",
4
4
  "author": "Redeemer Pace",
5
5
  "license": "ISC",
6
6
  "description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",