@xfcfam/xf-sql 0.1.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/dist/index.d.ts +26 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +27 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/api/A.d.ts +17 -0
  8. package/dist/src/api/A.d.ts.map +1 -0
  9. package/dist/src/api/A.js +17 -0
  10. package/dist/src/api/A.js.map +1 -0
  11. package/dist/src/business/B.d.ts +17 -0
  12. package/dist/src/business/B.d.ts.map +1 -0
  13. package/dist/src/business/B.js +17 -0
  14. package/dist/src/business/B.js.map +1 -0
  15. package/dist/src/repository/R.d.ts +17 -0
  16. package/dist/src/repository/R.d.ts.map +1 -0
  17. package/dist/src/repository/R.js +17 -0
  18. package/dist/src/repository/R.js.map +1 -0
  19. package/dist/src/repository/base/DatabaseRepository.d.ts +184 -0
  20. package/dist/src/repository/base/DatabaseRepository.d.ts.map +1 -0
  21. package/dist/src/repository/base/DatabaseRepository.js +216 -0
  22. package/dist/src/repository/base/DatabaseRepository.js.map +1 -0
  23. package/dist/src/repository/base/TransactionalDatabaseRepository.d.ts +86 -0
  24. package/dist/src/repository/base/TransactionalDatabaseRepository.d.ts.map +1 -0
  25. package/dist/src/repository/base/TransactionalDatabaseRepository.js +104 -0
  26. package/dist/src/repository/base/TransactionalDatabaseRepository.js.map +1 -0
  27. package/dist/src/repository/general/DatabaseRepository.d.ts +192 -0
  28. package/dist/src/repository/general/DatabaseRepository.d.ts.map +1 -0
  29. package/dist/src/repository/general/DatabaseRepository.js +224 -0
  30. package/dist/src/repository/general/DatabaseRepository.js.map +1 -0
  31. package/dist/src/repository/general/TransactionalDatabaseRepository.d.ts +91 -0
  32. package/dist/src/repository/general/TransactionalDatabaseRepository.d.ts.map +1 -0
  33. package/dist/src/repository/general/TransactionalDatabaseRepository.js +114 -0
  34. package/dist/src/repository/general/TransactionalDatabaseRepository.js.map +1 -0
  35. package/dist/src/repository/structs/CheckViolationException.d.ts +19 -0
  36. package/dist/src/repository/structs/CheckViolationException.d.ts.map +1 -0
  37. package/dist/src/repository/structs/CheckViolationException.js +22 -0
  38. package/dist/src/repository/structs/CheckViolationException.js.map +1 -0
  39. package/dist/src/repository/structs/ConnectionException.d.ts +15 -0
  40. package/dist/src/repository/structs/ConnectionException.d.ts.map +1 -0
  41. package/dist/src/repository/structs/ConnectionException.js +16 -0
  42. package/dist/src/repository/structs/ConnectionException.js.map +1 -0
  43. package/dist/src/repository/structs/DatabaseException.d.ts +14 -0
  44. package/dist/src/repository/structs/DatabaseException.d.ts.map +1 -0
  45. package/dist/src/repository/structs/DatabaseException.js +15 -0
  46. package/dist/src/repository/structs/DatabaseException.js.map +1 -0
  47. package/dist/src/repository/structs/DeadlockException.d.ts +16 -0
  48. package/dist/src/repository/structs/DeadlockException.d.ts.map +1 -0
  49. package/dist/src/repository/structs/DeadlockException.js +17 -0
  50. package/dist/src/repository/structs/DeadlockException.js.map +1 -0
  51. package/dist/src/repository/structs/ForeignKeyViolationException.d.ts +20 -0
  52. package/dist/src/repository/structs/ForeignKeyViolationException.d.ts.map +1 -0
  53. package/dist/src/repository/structs/ForeignKeyViolationException.js +23 -0
  54. package/dist/src/repository/structs/ForeignKeyViolationException.js.map +1 -0
  55. package/dist/src/repository/structs/NotNullViolationException.d.ts +20 -0
  56. package/dist/src/repository/structs/NotNullViolationException.d.ts.map +1 -0
  57. package/dist/src/repository/structs/NotNullViolationException.js +23 -0
  58. package/dist/src/repository/structs/NotNullViolationException.js.map +1 -0
  59. package/dist/src/repository/structs/UniqueViolationException.d.ts +36 -0
  60. package/dist/src/repository/structs/UniqueViolationException.d.ts.map +1 -0
  61. package/dist/src/repository/structs/UniqueViolationException.js +40 -0
  62. package/dist/src/repository/structs/UniqueViolationException.js.map +1 -0
  63. package/dist/src/repository/transfers/CheckViolationException.d.ts +19 -0
  64. package/dist/src/repository/transfers/CheckViolationException.d.ts.map +1 -0
  65. package/dist/src/repository/transfers/CheckViolationException.js +22 -0
  66. package/dist/src/repository/transfers/CheckViolationException.js.map +1 -0
  67. package/dist/src/repository/transfers/ConnectionException.d.ts +15 -0
  68. package/dist/src/repository/transfers/ConnectionException.d.ts.map +1 -0
  69. package/dist/src/repository/transfers/ConnectionException.js +16 -0
  70. package/dist/src/repository/transfers/ConnectionException.js.map +1 -0
  71. package/dist/src/repository/transfers/DatabaseException.d.ts +14 -0
  72. package/dist/src/repository/transfers/DatabaseException.d.ts.map +1 -0
  73. package/dist/src/repository/transfers/DatabaseException.js +15 -0
  74. package/dist/src/repository/transfers/DatabaseException.js.map +1 -0
  75. package/dist/src/repository/transfers/DeadlockException.d.ts +16 -0
  76. package/dist/src/repository/transfers/DeadlockException.d.ts.map +1 -0
  77. package/dist/src/repository/transfers/DeadlockException.js +17 -0
  78. package/dist/src/repository/transfers/DeadlockException.js.map +1 -0
  79. package/dist/src/repository/transfers/ForeignKeyViolationException.d.ts +20 -0
  80. package/dist/src/repository/transfers/ForeignKeyViolationException.d.ts.map +1 -0
  81. package/dist/src/repository/transfers/ForeignKeyViolationException.js +23 -0
  82. package/dist/src/repository/transfers/ForeignKeyViolationException.js.map +1 -0
  83. package/dist/src/repository/transfers/NotNullViolationException.d.ts +20 -0
  84. package/dist/src/repository/transfers/NotNullViolationException.d.ts.map +1 -0
  85. package/dist/src/repository/transfers/NotNullViolationException.js +23 -0
  86. package/dist/src/repository/transfers/NotNullViolationException.js.map +1 -0
  87. package/dist/src/repository/transfers/UniqueViolationException.d.ts +36 -0
  88. package/dist/src/repository/transfers/UniqueViolationException.d.ts.map +1 -0
  89. package/dist/src/repository/transfers/UniqueViolationException.js +40 -0
  90. package/dist/src/repository/transfers/UniqueViolationException.js.map +1 -0
  91. package/package.json +52 -0
@@ -0,0 +1,23 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT, UPDATE or DELETE violates a FOREIGN KEY
4
+ * constraint.
5
+ *
6
+ * Common scenarios: inserting a row that references a non-existent
7
+ * parent; deleting a row that is still referenced by children.
8
+ */
9
+ export class ForeignKeyViolationException extends DatabaseException {
10
+ /** Name of the violated foreign-key constraint, if known. */
11
+ constraint;
12
+ /** Table where the violation occurred, if known. */
13
+ table;
14
+ constructor(message, details = {}) {
15
+ super(message, { cause: details.cause });
16
+ this.name = 'ForeignKeyViolationException';
17
+ if (details.constraint !== undefined)
18
+ this.constraint = details.constraint;
19
+ if (details.table !== undefined)
20
+ this.table = details.table;
21
+ }
22
+ }
23
+ //# sourceMappingURL=ForeignKeyViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForeignKeyViolationException.js","sourceRoot":"","sources":["../../../../src/repository/structs/ForeignKeyViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,OAAO,4BAA6B,SAAQ,iBAAiB;IACjE,6DAA6D;IACpD,UAAU,CAAS;IAC5B,oDAAoD;IAC3C,KAAK,CAAS;IAEvB,YACE,OAAe,EACf,UAAoE,EAAE;QAEtE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;QAC1C,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QAC1E,IAAI,OAAO,CAAC,KAAK,KAAU,SAAS;YAAE,IAAI,CAAC,KAAK,GAAQ,OAAO,CAAC,KAAK,CAAA;IACvE,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE attempts to set a NOT NULL column
4
+ * to NULL.
5
+ *
6
+ * Almost always indicates a bug in the Repository or a missing input
7
+ * validation at the Business Layer.
8
+ */
9
+ export declare class NotNullViolationException extends DatabaseException {
10
+ /** Table where the violation occurred, if known. */
11
+ readonly table?: string;
12
+ /** Column that was set to NULL, if known. */
13
+ readonly column?: string;
14
+ constructor(message: string, details?: {
15
+ table?: string;
16
+ column?: string;
17
+ cause?: unknown;
18
+ });
19
+ }
20
+ //# sourceMappingURL=NotNullViolationException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotNullViolationException.d.ts","sourceRoot":"","sources":["../../../../src/repository/structs/NotNullViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,qBAAa,yBAA0B,SAAQ,iBAAiB;IAC9D,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAOrE"}
@@ -0,0 +1,23 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE attempts to set a NOT NULL column
4
+ * to NULL.
5
+ *
6
+ * Almost always indicates a bug in the Repository or a missing input
7
+ * validation at the Business Layer.
8
+ */
9
+ export class NotNullViolationException extends DatabaseException {
10
+ /** Table where the violation occurred, if known. */
11
+ table;
12
+ /** Column that was set to NULL, if known. */
13
+ column;
14
+ constructor(message, details = {}) {
15
+ super(message, { cause: details.cause });
16
+ this.name = 'NotNullViolationException';
17
+ if (details.table !== undefined)
18
+ this.table = details.table;
19
+ if (details.column !== undefined)
20
+ this.column = details.column;
21
+ }
22
+ }
23
+ //# sourceMappingURL=NotNullViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotNullViolationException.js","sourceRoot":"","sources":["../../../../src/repository/structs/NotNullViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,OAAO,yBAA0B,SAAQ,iBAAiB;IAC9D,oDAAoD;IAC3C,KAAK,CAAS;IACvB,6CAA6C;IACpC,MAAM,CAAS;IAExB,YACE,OAAe,EACf,UAAgE,EAAE;QAElE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;QACvC,IAAI,OAAO,CAAC,KAAK,KAAM,SAAS;YAAE,IAAI,CAAC,KAAK,GAAI,OAAO,CAAC,KAAK,CAAA;QAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAChE,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE violates a UNIQUE / PRIMARY KEY
4
+ * constraint.
5
+ *
6
+ * Carries the violated constraint name plus the table / column when
7
+ * the underlying driver exposes them, so the Business Layer can
8
+ * surface a domain-meaningful error without parsing strings.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * try {
13
+ * await this.usersDb.createUser({ email: 'a@b.c', ... })
14
+ * } catch (err) {
15
+ * if (err instanceof UniqueViolationException && err.column === 'email') {
16
+ * throw new DomainError('Email already registered')
17
+ * }
18
+ * throw err
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class UniqueViolationException extends DatabaseException {
23
+ /** Name of the violated unique / primary-key constraint, if known. */
24
+ readonly constraint?: string;
25
+ /** Table where the violation occurred, if known. */
26
+ readonly table?: string;
27
+ /** Column involved in the violation, if known. */
28
+ readonly column?: string;
29
+ constructor(message: string, details?: {
30
+ constraint?: string;
31
+ table?: string;
32
+ column?: string;
33
+ cause?: unknown;
34
+ });
35
+ }
36
+ //# sourceMappingURL=UniqueViolationException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniqueViolationException.d.ts","sourceRoot":"","sources":["../../../../src/repository/structs/UniqueViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAQ1F"}
@@ -0,0 +1,40 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE violates a UNIQUE / PRIMARY KEY
4
+ * constraint.
5
+ *
6
+ * Carries the violated constraint name plus the table / column when
7
+ * the underlying driver exposes them, so the Business Layer can
8
+ * surface a domain-meaningful error without parsing strings.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * try {
13
+ * await this.usersDb.createUser({ email: 'a@b.c', ... })
14
+ * } catch (err) {
15
+ * if (err instanceof UniqueViolationException && err.column === 'email') {
16
+ * throw new DomainError('Email already registered')
17
+ * }
18
+ * throw err
19
+ * }
20
+ * ```
21
+ */
22
+ export class UniqueViolationException extends DatabaseException {
23
+ /** Name of the violated unique / primary-key constraint, if known. */
24
+ constraint;
25
+ /** Table where the violation occurred, if known. */
26
+ table;
27
+ /** Column involved in the violation, if known. */
28
+ column;
29
+ constructor(message, details = {}) {
30
+ super(message, { cause: details.cause });
31
+ this.name = 'UniqueViolationException';
32
+ if (details.constraint !== undefined)
33
+ this.constraint = details.constraint;
34
+ if (details.table !== undefined)
35
+ this.table = details.table;
36
+ if (details.column !== undefined)
37
+ this.column = details.column;
38
+ }
39
+ }
40
+ //# sourceMappingURL=UniqueViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniqueViolationException.js","sourceRoot":"","sources":["../../../../src/repository/structs/UniqueViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC7D,sEAAsE;IAC7D,UAAU,CAAS;IAC5B,oDAAoD;IAC3C,KAAK,CAAS;IACvB,kDAAkD;IACzC,MAAM,CAAS;IAExB,YACE,OAAe,EACf,UAAqF,EAAE;QAEvF,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;QACtC,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QAC1E,IAAI,OAAO,CAAC,KAAK,KAAU,SAAS;YAAE,IAAI,CAAC,KAAK,GAAQ,OAAO,CAAC,KAAK,CAAA;QACrE,IAAI,OAAO,CAAC,MAAM,KAAS,SAAS;YAAE,IAAI,CAAC,MAAM,GAAO,OAAO,CAAC,MAAM,CAAA;IACxE,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE violates a CHECK constraint.
4
+ *
5
+ * The constraint name (when exposed by the driver) often matches the
6
+ * named CHECK in the schema, e.g. `users_age_positive_check`.
7
+ */
8
+ export declare class CheckViolationException extends DatabaseException {
9
+ /** Name of the violated CHECK constraint, if known. */
10
+ readonly constraint?: string;
11
+ /** Table where the violation occurred, if known. */
12
+ readonly table?: string;
13
+ constructor(message: string, details?: {
14
+ constraint?: string;
15
+ table?: string;
16
+ cause?: unknown;
17
+ });
18
+ }
19
+ //# sourceMappingURL=CheckViolationException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckViolationException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/CheckViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,iBAAiB;IAC5D,uDAAuD;IACvD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;gBAGrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAOzE"}
@@ -0,0 +1,22 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE violates a CHECK constraint.
4
+ *
5
+ * The constraint name (when exposed by the driver) often matches the
6
+ * named CHECK in the schema, e.g. `users_age_positive_check`.
7
+ */
8
+ export class CheckViolationException extends DatabaseException {
9
+ /** Name of the violated CHECK constraint, if known. */
10
+ constraint;
11
+ /** Table where the violation occurred, if known. */
12
+ table;
13
+ constructor(message, details = {}) {
14
+ super(message, { cause: details.cause });
15
+ this.name = 'CheckViolationException';
16
+ if (details.constraint !== undefined)
17
+ this.constraint = details.constraint;
18
+ if (details.table !== undefined)
19
+ this.table = details.table;
20
+ }
21
+ }
22
+ //# sourceMappingURL=CheckViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckViolationException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/CheckViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IAC5D,uDAAuD;IAC9C,UAAU,CAAS;IAC5B,oDAAoD;IAC3C,KAAK,CAAS;IAEvB,YACE,OAAe,EACf,UAAoE,EAAE;QAEtE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;QACrC,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QAC1E,IAAI,OAAO,CAAC,KAAK,KAAU,SAAS;YAAE,IAAI,CAAC,KAAK,GAAQ,OAAO,CAAC,KAAK,CAAA;IACvE,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when the database is unreachable — DNS failure, TCP refused,
4
+ * TLS handshake failure, statement / connection timeout, etc.
5
+ *
6
+ * The original transport error is preserved as the standard
7
+ * `Error.cause`. Use this alongside `RetryableRepository.withRetry`
8
+ * to back off and retry on transient transport failures.
9
+ */
10
+ export declare class ConnectionException extends DatabaseException {
11
+ constructor(message: string, options?: {
12
+ cause?: unknown;
13
+ });
14
+ }
15
+ //# sourceMappingURL=ConnectionException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/ConnectionException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,iBAAiB;gBAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D"}
@@ -0,0 +1,16 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when the database is unreachable — DNS failure, TCP refused,
4
+ * TLS handshake failure, statement / connection timeout, etc.
5
+ *
6
+ * The original transport error is preserved as the standard
7
+ * `Error.cause`. Use this alongside `RetryableRepository.withRetry`
8
+ * to back off and retry on transient transport failures.
9
+ */
10
+ export class ConnectionException extends DatabaseException {
11
+ constructor(message, options) {
12
+ super(message, options);
13
+ this.name = 'ConnectionException';
14
+ }
15
+ }
16
+ //# sourceMappingURL=ConnectionException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/ConnectionException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACxD,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Base type for every database-related error raised through xf-sql.
3
+ *
4
+ * Every concrete dialect-specific Exception in `@xfcfam/xf-sql` is a
5
+ * subclass of `DatabaseException`. Consumers can branch on the
6
+ * specific subclass (e.g. `UniqueViolationException`) or fall back to
7
+ * `instanceof DatabaseException` to catch any DB-originated error.
8
+ */
9
+ export declare class DatabaseException extends Error {
10
+ constructor(message: string, options?: {
11
+ cause?: unknown;
12
+ });
13
+ }
14
+ //# sourceMappingURL=DatabaseException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/DatabaseException.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Base type for every database-related error raised through xf-sql.
3
+ *
4
+ * Every concrete dialect-specific Exception in `@xfcfam/xf-sql` is a
5
+ * subclass of `DatabaseException`. Consumers can branch on the
6
+ * specific subclass (e.g. `UniqueViolationException`) or fall back to
7
+ * `instanceof DatabaseException` to catch any DB-originated error.
8
+ */
9
+ export class DatabaseException extends Error {
10
+ constructor(message, options) {
11
+ super(message, options);
12
+ this.name = 'DatabaseException';
13
+ }
14
+ }
15
+ //# sourceMappingURL=DatabaseException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/DatabaseException.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when the database detects a deadlock and aborts one of the
4
+ * conflicting transactions.
5
+ *
6
+ * Deadlocks are typically retryable — the transaction can be re-run
7
+ * and will usually succeed once the conflicting party has finished.
8
+ * Pair with `RetryableRepository.withRetry` or
9
+ * `RetryRestRepository`-style policies in your Logical.
10
+ */
11
+ export declare class DeadlockException extends DatabaseException {
12
+ constructor(message: string, options?: {
13
+ cause?: unknown;
14
+ });
15
+ }
16
+ //# sourceMappingURL=DeadlockException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeadlockException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/DeadlockException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,SAAQ,iBAAiB;gBAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D"}
@@ -0,0 +1,17 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when the database detects a deadlock and aborts one of the
4
+ * conflicting transactions.
5
+ *
6
+ * Deadlocks are typically retryable — the transaction can be re-run
7
+ * and will usually succeed once the conflicting party has finished.
8
+ * Pair with `RetryableRepository.withRetry` or
9
+ * `RetryRestRepository`-style policies in your Logical.
10
+ */
11
+ export class DeadlockException extends DatabaseException {
12
+ constructor(message, options) {
13
+ super(message, options);
14
+ this.name = 'DeadlockException';
15
+ }
16
+ }
17
+ //# sourceMappingURL=DeadlockException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeadlockException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/DeadlockException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IACtD,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT, UPDATE or DELETE violates a FOREIGN KEY
4
+ * constraint.
5
+ *
6
+ * Common scenarios: inserting a row that references a non-existent
7
+ * parent; deleting a row that is still referenced by children.
8
+ */
9
+ export declare class ForeignKeyViolationException extends DatabaseException {
10
+ /** Name of the violated foreign-key constraint, if known. */
11
+ readonly constraint?: string;
12
+ /** Table where the violation occurred, if known. */
13
+ readonly table?: string;
14
+ constructor(message: string, details?: {
15
+ constraint?: string;
16
+ table?: string;
17
+ cause?: unknown;
18
+ });
19
+ }
20
+ //# sourceMappingURL=ForeignKeyViolationException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForeignKeyViolationException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/ForeignKeyViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,qBAAa,4BAA6B,SAAQ,iBAAiB;IACjE,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;gBAGrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAOzE"}
@@ -0,0 +1,23 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT, UPDATE or DELETE violates a FOREIGN KEY
4
+ * constraint.
5
+ *
6
+ * Common scenarios: inserting a row that references a non-existent
7
+ * parent; deleting a row that is still referenced by children.
8
+ */
9
+ export class ForeignKeyViolationException extends DatabaseException {
10
+ /** Name of the violated foreign-key constraint, if known. */
11
+ constraint;
12
+ /** Table where the violation occurred, if known. */
13
+ table;
14
+ constructor(message, details = {}) {
15
+ super(message, { cause: details.cause });
16
+ this.name = 'ForeignKeyViolationException';
17
+ if (details.constraint !== undefined)
18
+ this.constraint = details.constraint;
19
+ if (details.table !== undefined)
20
+ this.table = details.table;
21
+ }
22
+ }
23
+ //# sourceMappingURL=ForeignKeyViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForeignKeyViolationException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/ForeignKeyViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,OAAO,4BAA6B,SAAQ,iBAAiB;IACjE,6DAA6D;IACpD,UAAU,CAAS;IAC5B,oDAAoD;IAC3C,KAAK,CAAS;IAEvB,YACE,OAAe,EACf,UAAoE,EAAE;QAEtE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;QAC1C,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QAC1E,IAAI,OAAO,CAAC,KAAK,KAAU,SAAS;YAAE,IAAI,CAAC,KAAK,GAAQ,OAAO,CAAC,KAAK,CAAA;IACvE,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE attempts to set a NOT NULL column
4
+ * to NULL.
5
+ *
6
+ * Almost always indicates a bug in the Repository or a missing input
7
+ * validation at the Business Layer.
8
+ */
9
+ export declare class NotNullViolationException extends DatabaseException {
10
+ /** Table where the violation occurred, if known. */
11
+ readonly table?: string;
12
+ /** Column that was set to NULL, if known. */
13
+ readonly column?: string;
14
+ constructor(message: string, details?: {
15
+ table?: string;
16
+ column?: string;
17
+ cause?: unknown;
18
+ });
19
+ }
20
+ //# sourceMappingURL=NotNullViolationException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotNullViolationException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/NotNullViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,qBAAa,yBAA0B,SAAQ,iBAAiB;IAC9D,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAOrE"}
@@ -0,0 +1,23 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE attempts to set a NOT NULL column
4
+ * to NULL.
5
+ *
6
+ * Almost always indicates a bug in the Repository or a missing input
7
+ * validation at the Business Layer.
8
+ */
9
+ export class NotNullViolationException extends DatabaseException {
10
+ /** Table where the violation occurred, if known. */
11
+ table;
12
+ /** Column that was set to NULL, if known. */
13
+ column;
14
+ constructor(message, details = {}) {
15
+ super(message, { cause: details.cause });
16
+ this.name = 'NotNullViolationException';
17
+ if (details.table !== undefined)
18
+ this.table = details.table;
19
+ if (details.column !== undefined)
20
+ this.column = details.column;
21
+ }
22
+ }
23
+ //# sourceMappingURL=NotNullViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotNullViolationException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/NotNullViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,OAAO,yBAA0B,SAAQ,iBAAiB;IAC9D,oDAAoD;IAC3C,KAAK,CAAS;IACvB,6CAA6C;IACpC,MAAM,CAAS;IAExB,YACE,OAAe,EACf,UAAgE,EAAE;QAElE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;QACvC,IAAI,OAAO,CAAC,KAAK,KAAM,SAAS;YAAE,IAAI,CAAC,KAAK,GAAI,OAAO,CAAC,KAAK,CAAA;QAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAChE,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE violates a UNIQUE / PRIMARY KEY
4
+ * constraint.
5
+ *
6
+ * Carries the violated constraint name plus the table / column when
7
+ * the underlying driver exposes them, so the Business Layer can
8
+ * surface a domain-meaningful error without parsing strings.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * try {
13
+ * await this.usersDb.createUser({ email: 'a@b.c', ... })
14
+ * } catch (err) {
15
+ * if (err instanceof UniqueViolationException && err.column === 'email') {
16
+ * throw new DomainError('Email already registered')
17
+ * }
18
+ * throw err
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class UniqueViolationException extends DatabaseException {
23
+ /** Name of the violated unique / primary-key constraint, if known. */
24
+ readonly constraint?: string;
25
+ /** Table where the violation occurred, if known. */
26
+ readonly table?: string;
27
+ /** Column involved in the violation, if known. */
28
+ readonly column?: string;
29
+ constructor(message: string, details?: {
30
+ constraint?: string;
31
+ table?: string;
32
+ column?: string;
33
+ cause?: unknown;
34
+ });
35
+ }
36
+ //# sourceMappingURL=UniqueViolationException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniqueViolationException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/UniqueViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAQ1F"}
@@ -0,0 +1,40 @@
1
+ import { DatabaseException } from './DatabaseException.js';
2
+ /**
3
+ * Thrown when an INSERT or UPDATE violates a UNIQUE / PRIMARY KEY
4
+ * constraint.
5
+ *
6
+ * Carries the violated constraint name plus the table / column when
7
+ * the underlying driver exposes them, so the Business Layer can
8
+ * surface a domain-meaningful error without parsing strings.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * try {
13
+ * await this.usersDb.createUser({ email: 'a@b.c', ... })
14
+ * } catch (err) {
15
+ * if (err instanceof UniqueViolationException && err.column === 'email') {
16
+ * throw new DomainError('Email already registered')
17
+ * }
18
+ * throw err
19
+ * }
20
+ * ```
21
+ */
22
+ export class UniqueViolationException extends DatabaseException {
23
+ /** Name of the violated unique / primary-key constraint, if known. */
24
+ constraint;
25
+ /** Table where the violation occurred, if known. */
26
+ table;
27
+ /** Column involved in the violation, if known. */
28
+ column;
29
+ constructor(message, details = {}) {
30
+ super(message, { cause: details.cause });
31
+ this.name = 'UniqueViolationException';
32
+ if (details.constraint !== undefined)
33
+ this.constraint = details.constraint;
34
+ if (details.table !== undefined)
35
+ this.table = details.table;
36
+ if (details.column !== undefined)
37
+ this.column = details.column;
38
+ }
39
+ }
40
+ //# sourceMappingURL=UniqueViolationException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniqueViolationException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/UniqueViolationException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC7D,sEAAsE;IAC7D,UAAU,CAAS;IAC5B,oDAAoD;IAC3C,KAAK,CAAS;IACvB,kDAAkD;IACzC,MAAM,CAAS;IAExB,YACE,OAAe,EACf,UAAqF,EAAE;QAEvF,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;QACtC,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QAC1E,IAAI,OAAO,CAAC,KAAK,KAAU,SAAS;YAAE,IAAI,CAAC,KAAK,GAAQ,OAAO,CAAC,KAAK,CAAA;QACrE,IAAI,OAAO,CAAC,MAAM,KAAS,SAAS;YAAE,IAAI,CAAC,MAAM,GAAO,OAAO,CAAC,MAAM,CAAA;IACxE,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@xfcfam/xf-sql",
3
+ "version": "0.1.0",
4
+ "description": "SQL Access Layer Generalization for the XF Architecture Model — encapsulates the Kysely query builder. Dialect-agnostic; pair with @xfcfam/xf-sql-postgres / @xfcfam/xf-sql-mysql / etc.",
5
+ "author": "XF Contributors",
6
+ "license": "MIT",
7
+ "homepage": "https://xfcfam.org",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/xfcfam/lib-npm",
11
+ "directory": "packages/xf-sql"
12
+ },
13
+ "keywords": [
14
+ "xf",
15
+ "cfam",
16
+ "sql",
17
+ "kysely",
18
+ "database"
19
+ ],
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./dist/index.js",
26
+ "types": "./dist/index.d.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "kysely": "^0.27.0"
37
+ },
38
+ "peerDependencies": {
39
+ "@xfcfam/xf": "^0.2.0"
40
+ },
41
+ "devDependencies": {
42
+ "typescript": "^5.4.0",
43
+ "vitest": "^2.0.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc",
47
+ "typecheck": "tsc --noEmit",
48
+ "clean": "rm -rf dist",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest"
51
+ }
52
+ }