@plyaz/types 1.13.1 → 1.13.3
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/db/DatabaseService.d.ts +2 -2
- package/dist/db/EventEmitter.d.ts +5 -1
- package/dist/db/database.types.d.ts +0 -24
- package/dist/db/index.cjs +12 -0
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +11 -0
- package/dist/db/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -89,7 +89,7 @@ export interface ServiceStatus {
|
|
|
89
89
|
* });
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
export interface
|
|
92
|
+
export interface DatabaseServiceInterface {
|
|
93
93
|
/**
|
|
94
94
|
* Get a single record by ID
|
|
95
95
|
* @param table - Table name
|
|
@@ -231,7 +231,7 @@ export interface DatabaseService {
|
|
|
231
231
|
* Legacy interface for backward compatibility
|
|
232
232
|
* @deprecated Use DatabaseService instead
|
|
233
233
|
*/
|
|
234
|
-
export interface DatabaseServiceType extends
|
|
234
|
+
export interface DatabaseServiceType extends DatabaseServiceInterface {
|
|
235
235
|
/**
|
|
236
236
|
* @deprecated Use get() instead
|
|
237
237
|
*/
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Defines the contract for database event emission
|
|
4
4
|
*/
|
|
5
5
|
import type { DatabaseEvent, DBEventHandler, DatabaseOperationType } from './event.types';
|
|
6
|
-
import type { DatabaseError } from './database.types';
|
|
7
6
|
import type { ContextType } from '@nestjs/common';
|
|
8
7
|
/**
|
|
9
8
|
* Emit a query error event
|
|
@@ -15,6 +14,11 @@ interface EmitQueryErrorOptions {
|
|
|
15
14
|
params?: Record<string, object>;
|
|
16
15
|
context?: ContextType;
|
|
17
16
|
}
|
|
17
|
+
export interface DatabaseError extends Error {
|
|
18
|
+
code?: string;
|
|
19
|
+
status?: number;
|
|
20
|
+
cause?: Error;
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* Interface for database event emission
|
|
20
24
|
*/
|
|
@@ -160,27 +160,3 @@ export interface DatabaseResult<T> {
|
|
|
160
160
|
/** The error if unsuccessful */
|
|
161
161
|
error?: Error;
|
|
162
162
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Helper function to create a successful database result
|
|
165
|
-
*/
|
|
166
|
-
export declare function success<T>(value: T): DatabaseResult<T>;
|
|
167
|
-
/**
|
|
168
|
-
* Helper function to create a failed database result
|
|
169
|
-
*/
|
|
170
|
-
export declare function failure<T>(error: Error): DatabaseResult<T>;
|
|
171
|
-
export declare class DatabaseError extends Error {
|
|
172
|
-
code?: string;
|
|
173
|
-
status?: number;
|
|
174
|
-
cause?: Error;
|
|
175
|
-
constructor(message: string, cause?: Error);
|
|
176
|
-
}
|
|
177
|
-
export declare class BaseError extends DatabaseError {
|
|
178
|
-
code: string;
|
|
179
|
-
status: number;
|
|
180
|
-
constructor(code: string, status: number, message: string);
|
|
181
|
-
}
|
|
182
|
-
export declare class ValidationError extends DatabaseError {
|
|
183
|
-
code: string;
|
|
184
|
-
status: number;
|
|
185
|
-
constructor(code: string, status: number, message: string);
|
|
186
|
-
}
|
package/dist/db/index.cjs
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// @plyaz package - Built with tsup
|
|
4
|
+
|
|
5
|
+
// src/db/adapter.ts
|
|
6
|
+
var ADAPTERS = /* @__PURE__ */ ((ADAPTERS2) => {
|
|
7
|
+
ADAPTERS2["DATABASE"] = "database";
|
|
8
|
+
ADAPTERS2["DRIZZLE"] = "drizzle";
|
|
9
|
+
ADAPTERS2["SUPABASE"] = "supabase";
|
|
10
|
+
ADAPTERS2["SQL"] = "sql";
|
|
11
|
+
return ADAPTERS2;
|
|
12
|
+
})(ADAPTERS || {});
|
|
13
|
+
|
|
14
|
+
exports.ADAPTERS = ADAPTERS;
|
|
3
15
|
//# sourceMappingURL=index.cjs.map
|
|
4
16
|
//# sourceMappingURL=index.cjs.map
|
package/dist/db/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
1
|
+
{"version":3,"sources":["../../src/db/adapter.ts"],"names":["ADAPTERS"],"mappings":";;;;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAXI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA","file":"index.cjs","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n * \n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n * \n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n * \n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n * \n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n * \n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n * \n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n * \n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n * \n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n * \n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n * \n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n * \n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n}\n"]}
|
package/dist/db/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export type * from './config.types';
|
|
|
4
4
|
export type * from './DatabaseAdapter';
|
|
5
5
|
export type * from './enhanced-config.types';
|
|
6
6
|
export type * from './database.types';
|
|
7
|
-
export
|
|
7
|
+
export * from './adapter';
|
|
8
8
|
export type * from './Transaction';
|
|
9
9
|
export type * from './event.types';
|
package/dist/db/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
// @plyaz package - Built with tsup
|
|
1
2
|
|
|
3
|
+
// src/db/adapter.ts
|
|
4
|
+
var ADAPTERS = /* @__PURE__ */ ((ADAPTERS2) => {
|
|
5
|
+
ADAPTERS2["DATABASE"] = "database";
|
|
6
|
+
ADAPTERS2["DRIZZLE"] = "drizzle";
|
|
7
|
+
ADAPTERS2["SUPABASE"] = "supabase";
|
|
8
|
+
ADAPTERS2["SQL"] = "sql";
|
|
9
|
+
return ADAPTERS2;
|
|
10
|
+
})(ADAPTERS || {});
|
|
11
|
+
|
|
12
|
+
export { ADAPTERS };
|
|
2
13
|
//# sourceMappingURL=index.js.map
|
|
3
14
|
//# sourceMappingURL=index.js.map
|
package/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/db/adapter.ts"],"names":["ADAPTERS"],"mappings":";;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAXI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA","file":"index.js","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n * \n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n * \n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n * \n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n * \n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n * \n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n * \n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n * \n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n * \n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n * \n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n * \n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n * \n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n}\n"]}
|
package/package.json
CHANGED