@plyaz/types 1.27.12 → 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.
@@ -890,7 +890,7 @@ export declare const OAUTH_PROVIDERS: {
890
890
  /**
891
891
  * Type for OAuth provider names
892
892
  */
893
- export type OAuthProvider = typeof OAUTH_PROVIDERS[keyof typeof OAUTH_PROVIDERS];
893
+ export type OAuthProvider = (typeof OAUTH_PROVIDERS)[keyof typeof OAUTH_PROVIDERS];
894
894
  /**
895
895
  * OAuth provider configuration interface
896
896
  */
@@ -2,4 +2,4 @@
2
2
  * Core Init Types
3
3
  * Service registry and initialization type definitions
4
4
  */
5
- export type { CoreDomainServiceInstance, CoreServiceInitConfig, CoreServiceCreateOptions, CoreInitializableDomainService, CoreServiceEntry, CoreServiceRegistryConfig, CoreExtractServiceConfig, CoreExtractServiceInstance, CoreFeatureFlagInitConfig, CoreErrorHandlerInitConfig, CoreCacheConfig, CoreObservabilityConfig, CoreStorageConfig, CoreNotificationConfig, CoreInitOptionsBase, CoreServicesResultBase, } from './types';
5
+ export type { CoreDomainServiceInstance, CoreServiceInitConfig, CoreServiceCreateOptions, CoreInitializableDomainService, CoreServiceEntry, CoreServiceRegistryConfig, CoreExtractServiceConfig, CoreExtractServiceInstance, CoreFeatureFlagInitConfig, CoreErrorHandlerInitConfig, CoreCacheConfig, CoreStorageConfig, CoreNotificationConfig, CoreObservabilityConfig, CoreInitOptionsBase, CoreServicesResultBase, } from './types';
@@ -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
15
  import type { MonitoringObservabilityAdapter, MonitoringAdapterWithPriority } from '../../observability';
16
- import type { StorageServiceConfig } from '../../storage';
17
- import type { NotificationServiceConfig } from '../../notifications';
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,3 +588,42 @@ export interface CoreNotificationServiceInstance {
569
588
  /** Close/cleanup the notification service */
570
589
  close(): Promise<void>;
571
590
  }
591
+ export interface CoreDbServiceStatic {
592
+ initialize(config?: CoreDbServiceConfig): Promise<CoreDbServiceInstance>;
593
+ getInstance(): CoreDbServiceInstance;
594
+ createInstance?(config?: CoreDbServiceConfig): Promise<CoreDbServiceInstance>;
595
+ reset?(): Promise<void>;
596
+ }
597
+ export interface CoreCacheServiceStatic<TConfig = CoreCacheConfig> {
598
+ initialize(config: TConfig): Promise<void>;
599
+ getInstance(): CoreCacheServiceInstance;
600
+ reset?(): void;
601
+ }
602
+ export interface CoreStorageServiceStatic<TConfig = CoreStorageConfig> {
603
+ initialize(config: TConfig): Promise<CoreStorageServiceInstance>;
604
+ getInstance(): CoreStorageServiceInstance;
605
+ createInstance?(config: TConfig): Promise<CoreStorageServiceInstance>;
606
+ reset?(): Promise<void>;
607
+ }
608
+ export interface CoreNotificationServiceStatic<TConfig = CoreNotificationConfig> {
609
+ initialize(config: TConfig): Promise<CoreNotificationServiceInstance>;
610
+ getInstance(): CoreNotificationServiceInstance;
611
+ createInstance?(config: TConfig): Promise<CoreNotificationServiceInstance>;
612
+ reset?(): Promise<void>;
613
+ }
614
+ /**
615
+ * Minimal interface compatible with Next.js NextRequest
616
+ * Used to type withErrorHandler without importing 'next/server'
617
+ */
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
+ }
629
+ export type { BackendErrorStore, BackendErrorStoreConfig, HttpErrorHandlerConfig };