@nextlyhq/adapter-drizzle 0.0.2-alpha.48 → 0.0.2-alpha.50

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.
@@ -2,7 +2,7 @@ import { a as SqlParam } from '../core-CVO7WYDj.cjs';
2
2
  export { J as JsonArray, b as JsonObject, c as JsonValue, S as SupportedDialect, T as TableResolver } from '../core-CVO7WYDj.cjs';
3
3
  export { D as DatabaseCapabilities, f as DeleteOptions, I as InsertOptions, J as JoinSpec, a as Migration, c as MigrationOptions, M as MigrationRecord, d as MigrationResult, b as MigrationStatus, O as OrderBySpec, P as PoolStats, S as SelectOptions, T as TransactionContext, h as TransactionIsolationLevel, e as TransactionOptions, U as UpdateOptions, g as UpsertOptions, W as WhereClause, i as WhereCondition, j as WhereOperator } from '../migration-BUc56kip.cjs';
4
4
  export { A as AlterTableOperation, a as AlterTableOptions, b as ColumnDefinition, C as CreateTableOptions, D as DropTableOptions, I as IndexDefinition, c as TableConstraint, T as TableDefinition } from '../schema-BDn8WfSL.cjs';
5
- export { a as DatabaseError, D as DatabaseErrorKind, b as DatabaseErrorOptions, c as createDatabaseError, i as isDatabaseError } from '../error-um1d_3Uo.cjs';
5
+ export { a as DatabaseError, D as DatabaseErrorKind, b as DatabaseErrorOptions, c as createDatabaseError, i as isApplicationError, d as isDatabaseError } from '../error-BrdknH2s.cjs';
6
6
  import 'drizzle-orm';
7
7
 
8
8
  /**
@@ -2,7 +2,7 @@ import { a as SqlParam } from '../core-CVO7WYDj.js';
2
2
  export { J as JsonArray, b as JsonObject, c as JsonValue, S as SupportedDialect, T as TableResolver } from '../core-CVO7WYDj.js';
3
3
  export { D as DatabaseCapabilities, f as DeleteOptions, I as InsertOptions, J as JoinSpec, a as Migration, c as MigrationOptions, M as MigrationRecord, d as MigrationResult, b as MigrationStatus, O as OrderBySpec, P as PoolStats, S as SelectOptions, T as TransactionContext, h as TransactionIsolationLevel, e as TransactionOptions, U as UpdateOptions, g as UpsertOptions, W as WhereClause, i as WhereCondition, j as WhereOperator } from '../migration-Bj84e15B.js';
4
4
  export { A as AlterTableOperation, a as AlterTableOptions, b as ColumnDefinition, C as CreateTableOptions, D as DropTableOptions, I as IndexDefinition, c as TableConstraint, T as TableDefinition } from '../schema-BIQ0YQZ_.js';
5
- export { a as DatabaseError, D as DatabaseErrorKind, b as DatabaseErrorOptions, c as createDatabaseError, i as isDatabaseError } from '../error-um1d_3Uo.js';
5
+ export { a as DatabaseError, D as DatabaseErrorKind, b as DatabaseErrorOptions, c as createDatabaseError, i as isApplicationError, d as isDatabaseError } from '../error-BrdknH2s.js';
6
6
  import 'drizzle-orm';
7
7
 
8
8
  /**
@@ -2,6 +2,13 @@
2
2
  function isDatabaseError(error) {
3
3
  return typeof error === "object" && error !== null && "kind" in error && typeof error.kind === "string";
4
4
  }
5
+ var APPLICATION_ERROR_BRAND = Symbol.for("nextly/NextlyError");
6
+ function isApplicationError(error) {
7
+ if (error === null || typeof error !== "object" && typeof error !== "function") {
8
+ return false;
9
+ }
10
+ return error[APPLICATION_ERROR_BRAND] === true;
11
+ }
5
12
  function createDatabaseError(options) {
6
13
  const error = new Error(options.message);
7
14
  error.name = "DatabaseError";
@@ -16,6 +23,6 @@ function createDatabaseError(options) {
16
23
  return error;
17
24
  }
18
25
 
19
- export { createDatabaseError, isDatabaseError };
26
+ export { createDatabaseError, isApplicationError, isDatabaseError };
20
27
  //# sourceMappingURL=index.mjs.map
21
28
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/error.ts"],"names":[],"mappings":";AAuFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAwB,IAAA,KAAS,QAAA;AAE7C;AA+CO,SAAS,oBACd,OAAA,EACe;AACf,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACvC,EAAA,KAAA,CAAM,IAAA,GAAO,eAAA;AACb,EAAA,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AAErB,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,UAAA,KAAe,MAAA,EAAW,KAAA,CAAM,aAAa,OAAA,CAAQ,UAAA;AACjE,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AACvD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AAEvD,EAAA,OAAO,KAAA;AACT","file":"index.mjs","sourcesContent":["/**\n * Database error type definitions.\n *\n * @packageDocumentation\n */\n\n/**\n * Database error classification.\n *\n * @remarks\n * Categorizes database errors for consistent error handling across adapters.\n * Each adapter translates database-specific error codes to these kinds.\n *\n * @public\n */\nexport type DatabaseErrorKind =\n | \"connection\" // Connection/network errors\n | \"query\" // Syntax or execution errors\n | \"constraint\" // Generic constraint violation\n | \"unique_violation\" // Unique constraint violation\n | \"foreign_key_violation\" // Foreign key constraint violation\n | \"check_violation\" // Check constraint violation\n | \"not_null_violation\" // NOT NULL constraint violation\n | \"deadlock\" // Transaction deadlock\n | \"timeout\" // Query or connection timeout\n | \"serialization_failure\" // Serializable transaction conflict\n | \"unsupported_version\" // F17: DB version below minimum or unparseable at connect\n | \"unknown\"; // Unclassified error\n\n/**\n * Enhanced database error interface.\n *\n * @remarks\n * Extends the standard Error interface with database-specific context.\n * Adapters should throw errors implementing this interface for consistent\n * error handling.\n *\n * @example\n * ```typescript\n * try {\n * await adapter.insert('users', { email: 'duplicate@example.com' });\n * } catch (error) {\n * if (isDatabaseError(error) && error.kind === 'unique_violation') {\n * console.log(`Duplicate ${error.column} in ${error.table}`);\n * }\n * }\n * ```\n *\n * @public\n */\nexport interface DatabaseError extends Error {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Database-specific error code (e.g., \"23505\" for PostgreSQL unique violation) */\n code?: string;\n\n /** Constraint name that was violated (if applicable) */\n constraint?: string;\n\n /** Table name involved in the error */\n table?: string;\n\n /** Column name involved in the error */\n column?: string;\n\n /** Detailed error description from the database */\n detail?: string;\n\n /** Hint for resolving the error */\n hint?: string;\n\n /** Original error from the database driver */\n cause?: Error;\n}\n\n/**\n * Type guard for DatabaseError.\n *\n * @remarks\n * Checks if an error is a DatabaseError with proper typing.\n *\n * @param error - Error to check\n * @returns True if error is a DatabaseError\n *\n * @public\n */\nexport function isDatabaseError(error: unknown): error is DatabaseError {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"kind\" in error &&\n typeof (error as DatabaseError).kind === \"string\"\n );\n}\n\n/**\n * Database error constructor options.\n *\n * @public\n */\nexport interface DatabaseErrorOptions {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Error message */\n message: string;\n\n /** Database-specific error code */\n code?: string;\n\n /** Constraint name */\n constraint?: string;\n\n /** Table name */\n table?: string;\n\n /** Column name */\n column?: string;\n\n /** Detailed description */\n detail?: string;\n\n /** Resolution hint */\n hint?: string;\n\n /** Original error */\n cause?: Error;\n}\n\n/**\n * Create a DatabaseError instance.\n *\n * @remarks\n * Helper function to create properly structured DatabaseError objects.\n *\n * @param options - Error options\n * @returns DatabaseError instance\n *\n * @public\n */\nexport function createDatabaseError(\n options: DatabaseErrorOptions\n): DatabaseError {\n const error = new Error(options.message) as DatabaseError;\n error.name = \"DatabaseError\";\n error.kind = options.kind;\n\n if (options.code !== undefined) error.code = options.code;\n if (options.constraint !== undefined) error.constraint = options.constraint;\n if (options.table !== undefined) error.table = options.table;\n if (options.column !== undefined) error.column = options.column;\n if (options.detail !== undefined) error.detail = options.detail;\n if (options.hint !== undefined) error.hint = options.hint;\n if (options.cause !== undefined) error.cause = options.cause;\n\n return error;\n}\n"]}
1
+ {"version":3,"sources":["../../src/types/error.ts"],"names":[],"mappings":";AAuFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAwB,IAAA,KAAS,QAAA;AAE7C;AAYA,IAAM,uBAAA,GAAyC,MAAA,CAAO,GAAA,CAAI,oBAAoB,CAAA;AAkBvE,SAAS,mBAAmB,KAAA,EAAyB;AAC1D,EAAA,IACE,UAAU,IAAA,IACT,OAAO,UAAU,QAAA,IAAY,OAAO,UAAU,UAAA,EAC/C;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAQ,KAAA,CAAkC,uBAAuB,CAAA,KAAM,IAAA;AACzE;AA+CO,SAAS,oBACd,OAAA,EACe;AACf,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACvC,EAAA,KAAA,CAAM,IAAA,GAAO,eAAA;AACb,EAAA,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AAErB,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,UAAA,KAAe,MAAA,EAAW,KAAA,CAAM,aAAa,OAAA,CAAQ,UAAA;AACjE,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AACvD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AAEvD,EAAA,OAAO,KAAA;AACT","file":"index.mjs","sourcesContent":["/**\n * Database error type definitions.\n *\n * @packageDocumentation\n */\n\n/**\n * Database error classification.\n *\n * @remarks\n * Categorizes database errors for consistent error handling across adapters.\n * Each adapter translates database-specific error codes to these kinds.\n *\n * @public\n */\nexport type DatabaseErrorKind =\n | \"connection\" // Connection/network errors\n | \"query\" // Syntax or execution errors\n | \"constraint\" // Generic constraint violation\n | \"unique_violation\" // Unique constraint violation\n | \"foreign_key_violation\" // Foreign key constraint violation\n | \"check_violation\" // Check constraint violation\n | \"not_null_violation\" // NOT NULL constraint violation\n | \"deadlock\" // Transaction deadlock\n | \"timeout\" // Query or connection timeout\n | \"serialization_failure\" // Serializable transaction conflict\n | \"unsupported_version\" // F17: DB version below minimum or unparseable at connect\n | \"unknown\"; // Unclassified error\n\n/**\n * Enhanced database error interface.\n *\n * @remarks\n * Extends the standard Error interface with database-specific context.\n * Adapters should throw errors implementing this interface for consistent\n * error handling.\n *\n * @example\n * ```typescript\n * try {\n * await adapter.insert('users', { email: 'duplicate@example.com' });\n * } catch (error) {\n * if (isDatabaseError(error) && error.kind === 'unique_violation') {\n * console.log(`Duplicate ${error.column} in ${error.table}`);\n * }\n * }\n * ```\n *\n * @public\n */\nexport interface DatabaseError extends Error {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Database-specific error code (e.g., \"23505\" for PostgreSQL unique violation) */\n code?: string;\n\n /** Constraint name that was violated (if applicable) */\n constraint?: string;\n\n /** Table name involved in the error */\n table?: string;\n\n /** Column name involved in the error */\n column?: string;\n\n /** Detailed error description from the database */\n detail?: string;\n\n /** Hint for resolving the error */\n hint?: string;\n\n /** Original error from the database driver */\n cause?: Error;\n}\n\n/**\n * Type guard for DatabaseError.\n *\n * @remarks\n * Checks if an error is a DatabaseError with proper typing.\n *\n * @param error - Error to check\n * @returns True if error is a DatabaseError\n *\n * @public\n */\nexport function isDatabaseError(error: unknown): error is DatabaseError {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"kind\" in error &&\n typeof (error as DatabaseError).kind === \"string\"\n );\n}\n\n/**\n * The brand every Nextly application error carries.\n *\n * Read through the global symbol registry rather than imported, because the\n * adapters must not depend on the package that defines the error: `Symbol.for`\n * resolves to the same symbol in every module instance, which is why the brand\n * exists in that form to begin with.\n *\n * @internal\n */\nconst APPLICATION_ERROR_BRAND: unique symbol = Symbol.for(\"nextly/NextlyError\");\n\n/**\n * Whether an error is the application's verdict rather than the database's\n * failure.\n *\n * Work running inside a transaction may throw to roll the write back — a\n * refused value, a permission denial — and such an error is not something the\n * driver produced. Classifying it as a database error replaces its code and its\n * payload with a generic one, so a caller that asked for a refusal is handed an\n * unexplained failure instead, and per-field validation detail is lost on the\n * way out.\n *\n * @param error - Error to check\n * @returns True if the error was raised by application code\n *\n * @public\n */\nexport function isApplicationError(error: unknown): boolean {\n if (\n error === null ||\n (typeof error !== \"object\" && typeof error !== \"function\")\n ) {\n return false;\n }\n return (error as Record<symbol, unknown>)[APPLICATION_ERROR_BRAND] === true;\n}\n\n/**\n * Database error constructor options.\n *\n * @public\n */\nexport interface DatabaseErrorOptions {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Error message */\n message: string;\n\n /** Database-specific error code */\n code?: string;\n\n /** Constraint name */\n constraint?: string;\n\n /** Table name */\n table?: string;\n\n /** Column name */\n column?: string;\n\n /** Detailed description */\n detail?: string;\n\n /** Resolution hint */\n hint?: string;\n\n /** Original error */\n cause?: Error;\n}\n\n/**\n * Create a DatabaseError instance.\n *\n * @remarks\n * Helper function to create properly structured DatabaseError objects.\n *\n * @param options - Error options\n * @returns DatabaseError instance\n *\n * @public\n */\nexport function createDatabaseError(\n options: DatabaseErrorOptions\n): DatabaseError {\n const error = new Error(options.message) as DatabaseError;\n error.name = \"DatabaseError\";\n error.kind = options.kind;\n\n if (options.code !== undefined) error.code = options.code;\n if (options.constraint !== undefined) error.constraint = options.constraint;\n if (options.table !== undefined) error.table = options.table;\n if (options.column !== undefined) error.column = options.column;\n if (options.detail !== undefined) error.detail = options.detail;\n if (options.hint !== undefined) error.hint = options.hint;\n if (options.cause !== undefined) error.cause = options.cause;\n\n return error;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { S as SupportedDialect } from './core-CVO7WYDj.cjs';
2
- import { a as DatabaseError } from './error-um1d_3Uo.cjs';
2
+ import { a as DatabaseError } from './error-BrdknH2s.cjs';
3
3
 
4
4
  declare const NEXTLY_MIN_DB_VERSIONS: {
5
5
  readonly postgresql: {
@@ -1,5 +1,5 @@
1
1
  import { S as SupportedDialect } from './core-CVO7WYDj.js';
2
- import { a as DatabaseError } from './error-um1d_3Uo.js';
2
+ import { a as DatabaseError } from './error-BrdknH2s.js';
3
3
 
4
4
  declare const NEXTLY_MIN_DB_VERSIONS: {
5
5
  readonly postgresql: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextlyhq/adapter-drizzle",
3
- "version": "0.0.2-alpha.48",
3
+ "version": "0.0.2-alpha.50",
4
4
  "description": "Shared Drizzle ORM adapter logic for Nextly database adapters",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,8 +52,8 @@
52
52
  "typescript": "^5.9.3",
53
53
  "vite-tsconfig-paths": "^5.1.4",
54
54
  "vitest": "^4.1.0",
55
- "@nextlyhq/eslint-config": "0.0.2-alpha.48",
56
- "@nextlyhq/tsconfig": "0.0.2-alpha.48"
55
+ "@nextlyhq/eslint-config": "0.0.2-alpha.50",
56
+ "@nextlyhq/tsconfig": "0.0.2-alpha.50"
57
57
  },
58
58
  "repository": {
59
59
  "type": "git",