postgrelize 0.0.0-stage → 1.0.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.
- package/CHANGELOG.md +269 -0
- package/LICENSE +21 -0
- package/README.md +131 -2
- package/dist/associations/association-accessors.d.ts +21 -0
- package/dist/associations/association-key-types.d.ts +44 -0
- package/dist/associations/association-keys.d.ts +98 -0
- package/dist/associations/association-lookup.d.ts +26 -0
- package/dist/associations/association-shape.d.ts +25 -0
- package/dist/associations/association.d.ts +95 -0
- package/dist/associations/belongs-to-many.d.ts +86 -0
- package/dist/associations/belongs-to.d.ts +45 -0
- package/dist/associations/has-many.d.ts +79 -0
- package/dist/associations/has-one.d.ts +44 -0
- package/dist/associations/include-assembler.d.ts +21 -0
- package/dist/associations/include-columns.d.ts +24 -0
- package/dist/associations/include-joins.d.ts +17 -0
- package/dist/associations/include-loader.d.ts +48 -0
- package/dist/associations/include-order.d.ts +22 -0
- package/dist/associations/include-query-builder.d.ts +54 -0
- package/dist/associations/include-resolver.d.ts +29 -0
- package/dist/associations/include-rows.d.ts +47 -0
- package/dist/associations/include-sub-query.d.ts +35 -0
- package/dist/associations/include.d.ts +112 -0
- package/dist/associations/junction-keys.d.ts +23 -0
- package/dist/associations/nested-creator.d.ts +44 -0
- package/dist/associations/nested-saver.d.ts +30 -0
- package/dist/associations/owner-keys.d.ts +34 -0
- package/dist/associations/separate-include-loader.d.ts +24 -0
- package/dist/associations/types.d.ts +139 -0
- package/dist/connection/connection-config.d.ts +33 -0
- package/dist/connection/connection-manager.d.ts +65 -0
- package/dist/connection/connection-types.d.ts +21 -0
- package/dist/connection/copy-from-stdin.d.ts +52 -0
- package/dist/connection/copy-runner.d.ts +30 -0
- package/dist/connection/copy-to-stdout.d.ts +49 -0
- package/dist/connection/copy.d.ts +22 -0
- package/dist/connection/notifications.d.ts +28 -0
- package/dist/connection/options.d.ts +158 -0
- package/dist/connection/query-logger.d.ts +41 -0
- package/dist/connection/replica-router.d.ts +20 -0
- package/dist/connection/statement-cache.d.ts +36 -0
- package/dist/connection/statement-timeout.d.ts +22 -0
- package/dist/data-types/abstract-data-type.d.ts +58 -0
- package/dist/data-types/array-literal-parser.d.ts +17 -0
- package/dist/data-types/array-type.d.ts +18 -0
- package/dist/data-types/bit-type.d.ts +14 -0
- package/dist/data-types/blob-type.d.ts +12 -0
- package/dist/data-types/char-type.d.ts +12 -0
- package/dist/data-types/composite-fields.d.ts +26 -0
- package/dist/data-types/composite-type.d.ts +32 -0
- package/dist/data-types/data-types.d.ts +172 -0
- package/dist/data-types/date-type.d.ts +14 -0
- package/dist/data-types/decimal-type.d.ts +13 -0
- package/dist/data-types/default-value-generator.d.ts +15 -0
- package/dist/data-types/enum-type.d.ts +19 -0
- package/dist/data-types/ewkb-reader.d.ts +18 -0
- package/dist/data-types/ewkb-writer.d.ts +17 -0
- package/dist/data-types/float-type.d.ts +12 -0
- package/dist/data-types/geometric-text.d.ts +65 -0
- package/dist/data-types/geometric-type.d.ts +46 -0
- package/dist/data-types/hstore-type.d.ts +16 -0
- package/dist/data-types/integer-type.d.ts +24 -0
- package/dist/data-types/json-type.d.ts +16 -0
- package/dist/data-types/multirange-type.d.ts +19 -0
- package/dist/data-types/range-type.d.ts +28 -0
- package/dist/data-types/record-text.d.ts +29 -0
- package/dist/data-types/scalar-type.d.ts +13 -0
- package/dist/data-types/spatial-type.d.ts +20 -0
- package/dist/data-types/string-type.d.ts +12 -0
- package/dist/data-types/text-type.d.ts +12 -0
- package/dist/data-types/timestamp-type.d.ts +15 -0
- package/dist/data-types/virtual-type.d.ts +15 -0
- package/dist/data-types/wall-clock.d.ts +14 -0
- package/dist/ddl/column-ddl.d.ts +73 -0
- package/dist/ddl/constraint-ddl.d.ts +30 -0
- package/dist/ddl/ddl-generator.d.ts +181 -0
- package/dist/ddl/ddl-guards.d.ts +60 -0
- package/dist/ddl/ddl-types.d.ts +193 -0
- package/dist/ddl/enum-ddl.d.ts +42 -0
- package/dist/ddl/extension-ddl.d.ts +57 -0
- package/dist/ddl/function-ddl.d.ts +98 -0
- package/dist/ddl/index-ddl.d.ts +29 -0
- package/dist/ddl/index-element-ddl.d.ts +19 -0
- package/dist/ddl/partition-ddl.d.ts +88 -0
- package/dist/ddl/partition-types.d.ts +94 -0
- package/dist/ddl/policy-ddl.d.ts +137 -0
- package/dist/ddl/routine-guards.d.ts +63 -0
- package/dist/ddl/sequence-ddl.d.ts +103 -0
- package/dist/ddl/sql-literal.d.ts +61 -0
- package/dist/ddl/table-ddl.d.ts +35 -0
- package/dist/ddl/trigger-ddl.d.ts +81 -0
- package/dist/ddl/view-ddl.d.ts +122 -0
- package/dist/decorators/association-applier.d.ts +18 -0
- package/dist/decorators/association-decorators.d.ts +72 -0
- package/dist/decorators/column-decorators.d.ts +147 -0
- package/dist/decorators/decorator-factory.d.ts +45 -0
- package/dist/decorators/decorator-signature.d.ts +26 -0
- package/dist/decorators/decorator-types.d.ts +24 -0
- package/dist/decorators/foreign-key-decorator.d.ts +21 -0
- package/dist/decorators/hook-decorators.d.ts +393 -0
- package/dist/decorators/init-arguments.d.ts +29 -0
- package/dist/decorators/model-decorators.d.ts +18 -0
- package/dist/decorators/model-metadata.d.ts +70 -0
- package/dist/decorators/table-decorators.d.ts +43 -0
- package/dist/decorators/timestamp-decorators.d.ts +38 -0
- package/dist/errors/base-error.d.ts +40 -0
- package/dist/errors/connection-errors.d.ts +152 -0
- package/dist/errors/database-errors.d.ts +152 -0
- package/dist/errors/errors.d.ts +5 -0
- package/dist/errors/map-pg-error.d.ts +27 -0
- package/dist/errors/misc-errors.d.ts +188 -0
- package/dist/errors/validation-errors.d.ts +117 -0
- package/dist/exports-core.d.ts +15 -0
- package/dist/exports-decorators.d.ts +8 -0
- package/dist/exports-errors.d.ts +2 -0
- package/dist/exports-model.d.ts +21 -0
- package/dist/exports-schema.d.ts +19 -0
- package/dist/expressions/call-expressions.d.ts +54 -0
- package/dist/expressions/condition-expressions.d.ts +51 -0
- package/dist/expressions/expression.d.ts +52 -0
- package/dist/expressions/jsonpath-helpers.d.ts +37 -0
- package/dist/expressions/methods.d.ts +188 -0
- package/dist/expressions/op.d.ts +182 -0
- package/dist/expressions/query-expressions.d.ts +110 -0
- package/dist/expressions/row-expressions.d.ts +35 -0
- package/dist/expressions/search-helpers.d.ts +138 -0
- package/dist/expressions/trigram-helpers.d.ts +40 -0
- package/dist/hooks/hooks.d.ts +125 -0
- package/dist/index.cjs +20461 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +20332 -0
- package/dist/index.js.map +1 -0
- package/dist/model/attribute-columns.d.ts +85 -0
- package/dist/model/attribute-normalizer.d.ts +42 -0
- package/dist/model/attribute-options.d.ts +121 -0
- package/dist/model/bulk-insert-builder.d.ts +24 -0
- package/dist/model/bulk-options.d.ts +173 -0
- package/dist/model/copy-options.d.ts +51 -0
- package/dist/model/cte-builder.d.ts +134 -0
- package/dist/model/definition-normalizer.d.ts +26 -0
- package/dist/model/delete-query-builder.d.ts +42 -0
- package/dist/model/find-options.d.ts +144 -0
- package/dist/model/find-query-builder.d.ts +38 -0
- package/dist/model/insert-query-builder.d.ts +41 -0
- package/dist/model/instance-destroyer.d.ts +44 -0
- package/dist/model/instance-lifecycle-services.d.ts +61 -0
- package/dist/model/instance-lifecycle.d.ts +128 -0
- package/dist/model/instance-saver.d.ts +25 -0
- package/dist/model/instance-state.d.ts +48 -0
- package/dist/model/instance-validation.d.ts +35 -0
- package/dist/model/instance-values.d.ts +80 -0
- package/dist/model/instance-writer.d.ts +59 -0
- package/dist/model/join-source-builder.d.ts +25 -0
- package/dist/model/lateral-keys-builder.d.ts +25 -0
- package/dist/model/merge-action-builder.d.ts +31 -0
- package/dist/model/merge-options.d.ts +72 -0
- package/dist/model/merge-query-builder.d.ts +29 -0
- package/dist/model/merge-source-builder.d.ts +22 -0
- package/dist/model/mixins/model-aggregates.d.ts +69 -0
- package/dist/model/mixins/model-associations.d.ts +73 -0
- package/dist/model/mixins/model-constructor.d.ts +7 -0
- package/dist/model/mixins/model-finders.d.ts +124 -0
- package/dist/model/mixins/model-hooks.d.ts +138 -0
- package/dist/model/mixins/model-postgres.d.ts +198 -0
- package/dist/model/mixins/model-schema-binding.d.ts +36 -0
- package/dist/model/mixins/model-schema.d.ts +55 -0
- package/dist/model/mixins/model-scopes.d.ts +57 -0
- package/dist/model/mixins/model-writers.d.ts +175 -0
- package/dist/model/mixins/named-hooks.d.ts +28 -0
- package/dist/model/model-accessors.d.ts +22 -0
- package/dist/model/model-base.d.ts +83 -0
- package/dist/model/model-definition.d.ts +130 -0
- package/dist/model/model-instance-persistence.d.ts +132 -0
- package/dist/model/model-instance-values.d.ts +154 -0
- package/dist/model/model-operations.d.ts +22 -0
- package/dist/model/model-registry.d.ts +139 -0
- package/dist/model/model-services.d.ts +46 -0
- package/dist/model/model-state.d.ts +60 -0
- package/dist/model/model-values.d.ts +86 -0
- package/dist/model/model.d.ts +560 -0
- package/dist/model/on-conflict-builder.d.ts +111 -0
- package/dist/model/operations/bulk-create-operation.d.ts +40 -0
- package/dist/model/operations/copy-from-source.d.ts +51 -0
- package/dist/model/operations/copy-operation.d.ts +54 -0
- package/dist/model/operations/count-operation.d.ts +52 -0
- package/dist/model/operations/create-operation.d.ts +31 -0
- package/dist/model/operations/destroy-operation.d.ts +65 -0
- package/dist/model/operations/find-cursor.d.ts +23 -0
- package/dist/model/operations/find-lookups.d.ts +89 -0
- package/dist/model/operations/find-operation.d.ts +47 -0
- package/dist/model/operations/increment-operation.d.ts +40 -0
- package/dist/model/operations/insert-operation.d.ts +71 -0
- package/dist/model/operations/merge-operation.d.ts +56 -0
- package/dist/model/operations/model-operation.d.ts +33 -0
- package/dist/model/operations/update-operation.d.ts +45 -0
- package/dist/model/operations/upsert-operation.d.ts +39 -0
- package/dist/model/options.d.ts +103 -0
- package/dist/model/returning-old.d.ts +52 -0
- package/dist/model/row-mapper.d.ts +78 -0
- package/dist/model/row-plan.d.ts +31 -0
- package/dist/model/runtime.d.ts +54 -0
- package/dist/model/scope-registry.d.ts +81 -0
- package/dist/model/select-aggregates.d.ts +37 -0
- package/dist/model/select-lock.d.ts +13 -0
- package/dist/model/select-options.d.ts +92 -0
- package/dist/model/select-query-builder.d.ts +73 -0
- package/dist/model/select-targets.d.ts +77 -0
- package/dist/model/source-option-builder.d.ts +23 -0
- package/dist/model/source-options.d.ts +108 -0
- package/dist/model/statement-builder.d.ts +77 -0
- package/dist/model/statement-services.d.ts +2 -0
- package/dist/model/sync-hooks.d.ts +18 -0
- package/dist/model/table-sample-builder.d.ts +13 -0
- package/dist/model/types.d.ts +85 -0
- package/dist/model/unnest-insert-builder.d.ts +24 -0
- package/dist/model/update-query-builder.d.ts +39 -0
- package/dist/model/v6-conflict-builder.d.ts +37 -0
- package/dist/model/value-cloner.d.ts +17 -0
- package/dist/model/values-writer.d.ts +12 -0
- package/dist/model/where-options.d.ts +164 -0
- package/dist/model/write-options.d.ts +160 -0
- package/dist/model/written-rows.d.ts +56 -0
- package/dist/query/query-result-shaper.d.ts +91 -0
- package/dist/query/raw-query.d.ts +27 -0
- package/dist/query-interface/alter-planner.d.ts +40 -0
- package/dist/query-interface/bulk-data.d.ts +44 -0
- package/dist/query-interface/column-commands.d.ts +52 -0
- package/dist/query-interface/column-describer.d.ts +17 -0
- package/dist/query-interface/enum-commands.d.ts +36 -0
- package/dist/query-interface/index-commands.d.ts +57 -0
- package/dist/query-interface/model-tables.d.ts +58 -0
- package/dist/query-interface/object-commands.d.ts +71 -0
- package/dist/query-interface/partition-commands.d.ts +43 -0
- package/dist/query-interface/policy-commands.d.ts +54 -0
- package/dist/query-interface/query-interface-objects.d.ts +108 -0
- package/dist/query-interface/query-interface-partitions.d.ts +66 -0
- package/dist/query-interface/query-interface-policies.d.ts +86 -0
- package/dist/query-interface/query-interface-routines.d.ts +120 -0
- package/dist/query-interface/query-interface-tables.d.ts +179 -0
- package/dist/query-interface/query-interface-types.d.ts +62 -0
- package/dist/query-interface/query-interface-views.d.ts +84 -0
- package/dist/query-interface/query-interface.d.ts +256 -0
- package/dist/query-interface/routine-commands.d.ts +71 -0
- package/dist/query-interface/schema-synchronizer.d.ts +99 -0
- package/dist/query-interface/statement-runner.d.ts +40 -0
- package/dist/query-interface/sync-planner.d.ts +26 -0
- package/dist/query-interface/table-commands.d.ts +63 -0
- package/dist/query-interface/table-introspector.d.ts +58 -0
- package/dist/query-interface/view-commands.d.ts +47 -0
- package/dist/sequelize/sequelize-base.d.ts +196 -0
- package/dist/sequelize/sequelize-constructor.d.ts +7 -0
- package/dist/sequelize/sequelize-hooks.d.ts +86 -0
- package/dist/sequelize/sequelize-internals.d.ts +87 -0
- package/dist/sequelize/sequelize-notifications.d.ts +66 -0
- package/dist/sequelize/sequelize-schema.d.ts +106 -0
- package/dist/sequelize/sequelize-transactions.d.ts +96 -0
- package/dist/sequelize.d.ts +790 -0
- package/dist/sql/ast-clauses.d.ts +137 -0
- package/dist/sql/ast-expressions.d.ts +88 -0
- package/dist/sql/ast-statements.d.ts +80 -0
- package/dist/sql/ast.d.ts +21 -0
- package/dist/sql/compile.d.ts +21 -0
- package/dist/sql/dml-compiler.d.ts +54 -0
- package/dist/sql/expression-compiler.d.ts +56 -0
- package/dist/sql/from-compiler.d.ts +39 -0
- package/dist/sql/identifier-quoter.d.ts +15 -0
- package/dist/sql/merge-compiler.d.ts +20 -0
- package/dist/sql/order.d.ts +15 -0
- package/dist/sql/query-compiler.d.ts +45 -0
- package/dist/sql/sql-chunks.d.ts +50 -0
- package/dist/sql/with-compiler.d.ts +19 -0
- package/dist/transaction/advisory-locks.d.ts +28 -0
- package/dist/transaction/transaction-constants.d.ts +35 -0
- package/dist/transaction/transaction-runner.d.ts +60 -0
- package/dist/transaction/transaction-starter.d.ts +25 -0
- package/dist/transaction/transaction-statements.d.ts +28 -0
- package/dist/transaction/transaction.d.ts +198 -0
- package/dist/validation/attribute-validators.d.ts +23 -0
- package/dist/validation/builtin-attribute-validator.d.ts +19 -0
- package/dist/validation/builtin-validators.d.ts +16 -0
- package/dist/validation/core-validator.d.ts +16 -0
- package/dist/validation/custom-validators.d.ts +13 -0
- package/dist/validation/instance-validator.d.ts +25 -0
- package/dist/validation/schema-items.d.ts +22 -0
- package/dist/validation/standard-schema-validator.d.ts +30 -0
- package/dist/validation/standard-schema.d.ts +39 -0
- package/dist/validation/types.d.ts +36 -0
- package/dist/validation/validation-target.d.ts +13 -0
- package/dist/where/comparison-compiler.d.ts +27 -0
- package/dist/where/condition-compiler.d.ts +18 -0
- package/dist/where/operand-resolver.d.ts +10 -0
- package/dist/where/operator-allowlist.d.ts +14 -0
- package/dist/where/where-support.d.ts +52 -0
- package/dist/where/where.d.ts +46 -0
- package/dist/where/window-compiler.d.ts +14 -0
- package/llm/USAGE.md +423 -0
- package/package.json +102 -4
- package/skills/postgrelize/SKILL.md +57 -0
- package/skills/postgrelize/reference/associations.md +108 -0
- package/skills/postgrelize/reference/errors.md +37 -0
- package/skills/postgrelize/reference/migrating-from-sequelize.md +15 -0
- package/skills/postgrelize/reference/postgresql-features.md +157 -0
- package/skills/postgrelize/reference/querying.md +111 -0
- package/skills/postgrelize/reference/schema.md +135 -0
- package/skills/postgrelize/reference/security.md +34 -0
- package/skills/postgrelize/reference/transactions-and-sessions.md +122 -0
- package/skills/postgrelize/reference/writing.md +198 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { BaseError } from './base-error.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Failure to reach or authenticate against PostgreSQL (Sequelize v6 `ConnectionError`).
|
|
4
|
+
*
|
|
5
|
+
* Thrown when connecting fails and for driver errors with an unmapped `08xxx` SQLSTATE. The subclasses below narrow the cause; `parent` and `original` hold the driver error.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* try {
|
|
10
|
+
* await sequelize.authenticate();
|
|
11
|
+
* } catch (e) {
|
|
12
|
+
* if (e instanceof ConnectionError) {
|
|
13
|
+
* console.error('cannot connect:', e.parent.message);
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class ConnectionError extends BaseError {
|
|
19
|
+
/** Original driver error. */
|
|
20
|
+
readonly parent: Error;
|
|
21
|
+
/** Original driver error (alias of `parent`). */
|
|
22
|
+
readonly original: Error;
|
|
23
|
+
/**
|
|
24
|
+
* Wraps a driver error; the message and `cause` are taken from it.
|
|
25
|
+
*
|
|
26
|
+
* @param parent - Original driver error.
|
|
27
|
+
*/
|
|
28
|
+
constructor(parent: Error);
|
|
29
|
+
}
|
|
30
|
+
declare const ConnectionRefusedError_base: typeof ConnectionError;
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when the server refuses the connection (`ECONNREFUSED`), typically because PostgreSQL is not running on that host and port.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* try {
|
|
37
|
+
* await sequelize.authenticate();
|
|
38
|
+
* } catch (e) {
|
|
39
|
+
* if (e instanceof ConnectionRefusedError) {
|
|
40
|
+
* console.error('database is down');
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class ConnectionRefusedError extends ConnectionRefusedError_base {
|
|
46
|
+
}
|
|
47
|
+
declare const AccessDeniedError_base: typeof ConnectionError;
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when PostgreSQL rejects the credentials (SQLSTATE `28P01` or `28000`).
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* try {
|
|
54
|
+
* await sequelize.authenticate();
|
|
55
|
+
* } catch (e) {
|
|
56
|
+
* if (e instanceof AccessDeniedError) {
|
|
57
|
+
* console.error('check username and password');
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare class AccessDeniedError extends AccessDeniedError_base {
|
|
63
|
+
}
|
|
64
|
+
declare const HostNotFoundError_base: typeof ConnectionError;
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when the host name cannot be resolved (`ENOTFOUND` or `EAI_AGAIN`).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* try {
|
|
71
|
+
* await sequelize.authenticate();
|
|
72
|
+
* } catch (e) {
|
|
73
|
+
* if (e instanceof HostNotFoundError) {
|
|
74
|
+
* console.error('unknown database host');
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare class HostNotFoundError extends HostNotFoundError_base {
|
|
80
|
+
}
|
|
81
|
+
declare const HostNotReachableError_base: typeof ConnectionError;
|
|
82
|
+
/**
|
|
83
|
+
* Thrown when no route to the host exists (`EHOSTUNREACH`).
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* try {
|
|
88
|
+
* await sequelize.authenticate();
|
|
89
|
+
* } catch (e) {
|
|
90
|
+
* if (e instanceof HostNotReachableError) {
|
|
91
|
+
* console.error('database host is unreachable');
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare class HostNotReachableError extends HostNotReachableError_base {
|
|
97
|
+
}
|
|
98
|
+
declare const InvalidConnectionError_base: typeof ConnectionError;
|
|
99
|
+
/**
|
|
100
|
+
* Thrown when the connection parameters are rejected by the network layer (`EINVAL`).
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* try {
|
|
105
|
+
* await sequelize.authenticate();
|
|
106
|
+
* } catch (e) {
|
|
107
|
+
* if (e instanceof InvalidConnectionError) {
|
|
108
|
+
* console.error('check host and port settings');
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare class InvalidConnectionError extends InvalidConnectionError_base {
|
|
114
|
+
}
|
|
115
|
+
declare const ConnectionTimedOutError_base: typeof ConnectionError;
|
|
116
|
+
/**
|
|
117
|
+
* Thrown when the TCP connection to the server times out (`ETIMEDOUT`).
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* try {
|
|
122
|
+
* await sequelize.authenticate();
|
|
123
|
+
* } catch (e) {
|
|
124
|
+
* if (e instanceof ConnectionTimedOutError) {
|
|
125
|
+
* console.error('database did not answer in time');
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare class ConnectionTimedOutError extends ConnectionTimedOutError_base {
|
|
131
|
+
}
|
|
132
|
+
declare const ConnectionAcquireTimeoutError_base: typeof ConnectionError;
|
|
133
|
+
/**
|
|
134
|
+
* Thrown when no pooled connection became free within `pool.acquire` milliseconds (default 60000).
|
|
135
|
+
*
|
|
136
|
+
* Raise `pool.max` or shorten the transactions that hold connections.
|
|
137
|
+
* See {@link PoolOptions}.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* try {
|
|
142
|
+
* await User.findAll();
|
|
143
|
+
* } catch (e) {
|
|
144
|
+
* if (e instanceof ConnectionAcquireTimeoutError) {
|
|
145
|
+
* console.error('pool exhausted');
|
|
146
|
+
* }
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare class ConnectionAcquireTimeoutError extends ConnectionAcquireTimeoutError_base {
|
|
151
|
+
}
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { BaseError, DriverError } from './base-error.ts';
|
|
2
|
+
/** Context attached to errors raised while executing SQL. */
|
|
3
|
+
export type QueryErrorContext = Readonly<{
|
|
4
|
+
/** Executed SQL text. */
|
|
5
|
+
sql?: string;
|
|
6
|
+
/** Bound parameter values. */
|
|
7
|
+
parameters?: readonly unknown[];
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Error returned by PostgreSQL while executing a query (Sequelize v6 `DatabaseError`).
|
|
11
|
+
*
|
|
12
|
+
* Any driver error without a more specific mapping becomes a `DatabaseError`; `sql` and `parameters` describe the failed statement and `parent.code` holds the SQLSTATE.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* try {
|
|
17
|
+
* await sequelize.query('SELECT * FROM missing_table');
|
|
18
|
+
* } catch (e) {
|
|
19
|
+
* if (e instanceof DatabaseError) {
|
|
20
|
+
* console.error(e.parent.code, e.sql, e.parameters);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class DatabaseError extends BaseError {
|
|
26
|
+
/** Original driver error. */
|
|
27
|
+
readonly parent: DriverError;
|
|
28
|
+
/** Original driver error (alias of `parent`). */
|
|
29
|
+
readonly original: DriverError;
|
|
30
|
+
/** Executed SQL text. */
|
|
31
|
+
readonly sql: string;
|
|
32
|
+
/** Bound parameter values. */
|
|
33
|
+
readonly parameters: readonly unknown[];
|
|
34
|
+
/**
|
|
35
|
+
* Wraps a driver error together with the statement that failed.
|
|
36
|
+
*
|
|
37
|
+
* @param parent - Original driver error.
|
|
38
|
+
* @param context - Executed SQL and parameters; `sql` defaults to `''` and `parameters` to `[]`.
|
|
39
|
+
*/
|
|
40
|
+
constructor(parent: DriverError, context?: QueryErrorContext);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Query cancelled by PostgreSQL, e.g. because `statement_timeout` elapsed (SQLSTATE `57014`).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* try {
|
|
48
|
+
* await sequelize.query('SELECT pg_sleep(10)');
|
|
49
|
+
* } catch (e) {
|
|
50
|
+
* if (e instanceof TimeoutError) {
|
|
51
|
+
* console.error('query was cancelled:', e.sql);
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare class TimeoutError extends DatabaseError {
|
|
57
|
+
/**
|
|
58
|
+
* Wraps a driver error together with the statement that failed.
|
|
59
|
+
*
|
|
60
|
+
* @param parent - Original driver error.
|
|
61
|
+
* @param context - Executed SQL and parameters.
|
|
62
|
+
*/
|
|
63
|
+
constructor(parent: DriverError, context?: QueryErrorContext);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Input of the constraint error constructors: the driver error plus what PostgreSQL reported about the constraint.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const options: ConstraintErrorOptions = {
|
|
71
|
+
* parent: Object.assign(new Error('violates foreign key constraint'), { code: '23503' }),
|
|
72
|
+
* fields: ['userId'],
|
|
73
|
+
* table: 'posts',
|
|
74
|
+
* constraint: 'posts_userId_fkey',
|
|
75
|
+
* sql: 'INSERT INTO "posts" ("userId") VALUES ($1)',
|
|
76
|
+
* parameters: [42],
|
|
77
|
+
* };
|
|
78
|
+
* const error = new ForeignKeyConstraintError(options);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export type ConstraintErrorOptions = QueryErrorContext & Readonly<{
|
|
82
|
+
/** Original driver error. */
|
|
83
|
+
parent: DriverError;
|
|
84
|
+
/** Constraint columns mapped to offending values. */
|
|
85
|
+
fields?: Readonly<Record<string, string>> | readonly string[];
|
|
86
|
+
/** Table name. */
|
|
87
|
+
table?: string;
|
|
88
|
+
/** Constraint name. */
|
|
89
|
+
constraint?: string;
|
|
90
|
+
/** Error message, defaults to the driver message. */
|
|
91
|
+
message?: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Thrown when a write references a missing row or removes a row that is still referenced (SQLSTATE `23503`).
|
|
95
|
+
*
|
|
96
|
+
* `fields` lists the referencing columns (parsed from the PostgreSQL detail), `table` the table and `index` the constraint name.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* try {
|
|
101
|
+
* await Post.create({ title: 'Hello', userId: 999999 });
|
|
102
|
+
* } catch (e) {
|
|
103
|
+
* if (e instanceof ForeignKeyConstraintError) {
|
|
104
|
+
* console.error(e.table, e.fields, e.index);
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare class ForeignKeyConstraintError extends DatabaseError {
|
|
110
|
+
/** Referencing columns. */
|
|
111
|
+
readonly fields: readonly string[];
|
|
112
|
+
/** Table name. */
|
|
113
|
+
readonly table: string | undefined;
|
|
114
|
+
/** Constraint name. */
|
|
115
|
+
readonly index: string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Builds the error from the constraint details; an object `fields` is reduced to its keys.
|
|
118
|
+
*
|
|
119
|
+
* @param options - Driver error, fields and context.
|
|
120
|
+
*/
|
|
121
|
+
constructor(options: ConstraintErrorOptions);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Thrown when a row conflicts with an exclusion constraint, e.g. overlapping ranges (SQLSTATE `23P01`). PostgreSQL-specific; v6 has no such class.
|
|
125
|
+
*
|
|
126
|
+
* `constraint` is the constraint name, `fields` the columns parsed from the PostgreSQL detail and `table` the table.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* try {
|
|
131
|
+
* await Task.create({ room: 'A', during: [new Date('2026-01-01'), new Date('2026-01-02')] });
|
|
132
|
+
* } catch (e) {
|
|
133
|
+
* if (e instanceof ExclusionConstraintError) {
|
|
134
|
+
* console.error(e.constraint, e.fields);
|
|
135
|
+
* }
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare class ExclusionConstraintError extends DatabaseError {
|
|
140
|
+
/** Constraint name. */
|
|
141
|
+
readonly constraint: string | undefined;
|
|
142
|
+
/** Constraint columns. */
|
|
143
|
+
readonly fields: readonly string[];
|
|
144
|
+
/** Table name. */
|
|
145
|
+
readonly table: string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Builds the error from the constraint details; an object `fields` is reduced to its keys.
|
|
148
|
+
*
|
|
149
|
+
* @param options - Driver error, fields and context.
|
|
150
|
+
*/
|
|
151
|
+
constructor(options: ConstraintErrorOptions);
|
|
152
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseError, ConnectionError, QueryErrorContext } from './errors.ts';
|
|
2
|
+
/** Maps `pg` driver errors to the matching Sequelize v6 error classes. */
|
|
3
|
+
export declare class PgErrorMapper {
|
|
4
|
+
#private;
|
|
5
|
+
/**
|
|
6
|
+
* Parses `Key (a, b)=(1, 2)` from a PostgreSQL error detail into `{ a: '1', b: '2' }`.
|
|
7
|
+
*
|
|
8
|
+
* @param detail - `detail` of the driver error.
|
|
9
|
+
* @returns Key values by column, or `undefined` when the detail has no key.
|
|
10
|
+
*/
|
|
11
|
+
parseKeyDetail(detail: string | undefined): Readonly<Record<string, string>> | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Maps a `pg` error raised by a query to the matching Sequelize v6 error class.
|
|
14
|
+
*
|
|
15
|
+
* @param error - Error thrown by the driver.
|
|
16
|
+
* @param context - SQL and parameters of the failed query.
|
|
17
|
+
* @returns Sequelize error (the error itself when it already is one).
|
|
18
|
+
*/
|
|
19
|
+
mapQueryError(error: unknown, context?: QueryErrorContext): BaseError;
|
|
20
|
+
/**
|
|
21
|
+
* Maps an error raised while connecting to the matching Sequelize v6 connection error class.
|
|
22
|
+
*
|
|
23
|
+
* @param error - Error thrown by the driver.
|
|
24
|
+
* @returns Connection error (the error itself when it already is one).
|
|
25
|
+
*/
|
|
26
|
+
mapConnectionError(error: unknown): ConnectionError;
|
|
27
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { BaseError } from './base-error.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when saving an instance of a model with `version: true` updates no row because another writer changed it first (optimistic locking).
|
|
4
|
+
*
|
|
5
|
+
* The failed update is not retried; reload the instance and apply the change again.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const user = await User.findByPk(1);
|
|
10
|
+
* try {
|
|
11
|
+
* await user!.update({ name: 'New name' });
|
|
12
|
+
* } catch (e) {
|
|
13
|
+
* if (e instanceof OptimisticLockError) {
|
|
14
|
+
* console.error(e.modelName, e.where);
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class OptimisticLockError extends BaseError {
|
|
20
|
+
/** Name of the model whose row was stale; `undefined` when not given. */
|
|
21
|
+
readonly modelName: string | undefined;
|
|
22
|
+
/** Primary key values of the row. */
|
|
23
|
+
readonly where: unknown;
|
|
24
|
+
/** Expected version values. */
|
|
25
|
+
readonly values: unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Builds the error; the message defaults to `Attempting to update a stale model instance: <modelName>`.
|
|
28
|
+
*
|
|
29
|
+
* @param options - Model name, values and where of the failed update.
|
|
30
|
+
*/
|
|
31
|
+
constructor(options?: Readonly<{
|
|
32
|
+
message?: string;
|
|
33
|
+
modelName?: string;
|
|
34
|
+
values?: unknown;
|
|
35
|
+
where?: unknown;
|
|
36
|
+
}>);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Failure of one record in a bulk operation, carrying the offending record.
|
|
40
|
+
*
|
|
41
|
+
* Collected into an {@link AggregateError} by `bulkCreate` with `validate: true`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* try {
|
|
46
|
+
* await User.bulkCreate([{ email: 'not-an-email' }], { validate: true });
|
|
47
|
+
* } catch (e) {
|
|
48
|
+
* if (e instanceof AggregateError) {
|
|
49
|
+
* for (const item of e.errors) {
|
|
50
|
+
* if (item instanceof BulkRecordError) {
|
|
51
|
+
* console.error(item.record, item.errors.message);
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare class BulkRecordError extends BaseError {
|
|
59
|
+
/** Underlying error. */
|
|
60
|
+
readonly errors: Error;
|
|
61
|
+
/** Record that failed. */
|
|
62
|
+
readonly record: object;
|
|
63
|
+
/**
|
|
64
|
+
* Wraps the validation error of one record; the message is copied from it.
|
|
65
|
+
*
|
|
66
|
+
* @param error - Underlying error.
|
|
67
|
+
* @param record - Record that failed.
|
|
68
|
+
*/
|
|
69
|
+
constructor(error: Error, record: object);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Bundles the errors of one bulk operation into a single error (Sequelize v6 `AggregateError`).
|
|
73
|
+
*
|
|
74
|
+
* `bulkCreate` with `validate: true` validates every record and throws this error with one {@link BulkRecordError} per invalid record. The message joins the messages of all errors with newlines.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* try {
|
|
79
|
+
* await User.bulkCreate([{ email: 'a' }, { email: 'b' }], { validate: true });
|
|
80
|
+
* } catch (e) {
|
|
81
|
+
* if (e instanceof AggregateError) {
|
|
82
|
+
* console.error(`${e.errors.length} records failed`);
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare class AggregateError extends BaseError {
|
|
88
|
+
/** Collected errors. */
|
|
89
|
+
readonly errors: readonly Error[];
|
|
90
|
+
/**
|
|
91
|
+
* Creates the error from the collected errors.
|
|
92
|
+
*
|
|
93
|
+
* @param errors - Collected errors.
|
|
94
|
+
*/
|
|
95
|
+
constructor(errors: readonly Error[]);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Thrown by finders called with `rejectOnEmpty: true` when no row matches.
|
|
99
|
+
*
|
|
100
|
+
* Pass an `Error` instance as `rejectOnEmpty` to throw it instead of this class.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* try {
|
|
105
|
+
* await User.findOne({ where: { email: 'nobody@example.com' }, rejectOnEmpty: true });
|
|
106
|
+
* } catch (e) {
|
|
107
|
+
* if (e instanceof EmptyResultError) {
|
|
108
|
+
* console.error('no such user');
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare class EmptyResultError extends BaseError {
|
|
114
|
+
/**
|
|
115
|
+
* Creates the error.
|
|
116
|
+
*
|
|
117
|
+
* @param message - Error message.
|
|
118
|
+
*/
|
|
119
|
+
constructor(message?: string);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Thrown when an instance method is used on an instance in the wrong state, e.g. `reload()` for a row that no longer exists.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* try {
|
|
127
|
+
* await user.destroy();
|
|
128
|
+
* await user.reload();
|
|
129
|
+
* } catch (e) {
|
|
130
|
+
* if (e instanceof InstanceError) {
|
|
131
|
+
* console.error(e.message);
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare class InstanceError extends BaseError {
|
|
137
|
+
/**
|
|
138
|
+
* Creates the error.
|
|
139
|
+
*
|
|
140
|
+
* @param message - Error message.
|
|
141
|
+
*/
|
|
142
|
+
constructor(message: string);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Thrown when an `include` names a model that is not associated with the queried model.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* try {
|
|
150
|
+
* await User.findAll({ include: [Tag] });
|
|
151
|
+
* } catch (e) {
|
|
152
|
+
* if (e instanceof EagerLoadingError) {
|
|
153
|
+
* console.error(e.message);
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare class EagerLoadingError extends BaseError {
|
|
159
|
+
/**
|
|
160
|
+
* Creates the error.
|
|
161
|
+
*
|
|
162
|
+
* @param message - Error message.
|
|
163
|
+
*/
|
|
164
|
+
constructor(message: string);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Thrown when an association is defined incorrectly, e.g. two associations of one model share an alias.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* try {
|
|
172
|
+
* User.hasMany(Post, { as: 'items' });
|
|
173
|
+
* User.hasMany(Task, { as: 'items' });
|
|
174
|
+
* } catch (e) {
|
|
175
|
+
* if (e instanceof AssociationError) {
|
|
176
|
+
* console.error(e.message);
|
|
177
|
+
* }
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare class AssociationError extends BaseError {
|
|
182
|
+
/**
|
|
183
|
+
* Creates the error.
|
|
184
|
+
*
|
|
185
|
+
* @param message - Error message.
|
|
186
|
+
*/
|
|
187
|
+
constructor(message: string);
|
|
188
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { BaseError, DriverError } from './base-error.ts';
|
|
2
|
+
import { ConstraintErrorOptions } from './database-errors.ts';
|
|
3
|
+
/** Origin of a validation error item. */
|
|
4
|
+
export type ValidationErrorItemOrigin = 'CORE' | 'DB' | 'FUNCTION';
|
|
5
|
+
/**
|
|
6
|
+
* Describes a single failed validation: which attribute, which value and which validator (Sequelize v6 `ValidationErrorItem`).
|
|
7
|
+
*
|
|
8
|
+
* `origin` is derived from `type`: `'CORE'` for not-null and string violations, `'DB'` for unique violations, `'FUNCTION'` for custom validators.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* try {
|
|
13
|
+
* await User.create({ email: 'not-an-email' });
|
|
14
|
+
* } catch (e) {
|
|
15
|
+
* if (e instanceof ValidationError) {
|
|
16
|
+
* for (const item of e.errors) {
|
|
17
|
+
* console.error(item.path, item.validatorKey, item.value, item.origin);
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class ValidationErrorItem {
|
|
24
|
+
/** Human-readable message. */
|
|
25
|
+
readonly message: string;
|
|
26
|
+
/** Validation type, e.g. `'unique violation'`, `'notNull Violation'`, `'Validation error'`. */
|
|
27
|
+
readonly type: string | null;
|
|
28
|
+
/** Attribute name (or model validator name). */
|
|
29
|
+
readonly path: string | null;
|
|
30
|
+
/** Offending value. */
|
|
31
|
+
readonly value: unknown;
|
|
32
|
+
/** Where the error was raised, derived from `type`. */
|
|
33
|
+
readonly origin: ValidationErrorItemOrigin | null;
|
|
34
|
+
/** Instance being validated. */
|
|
35
|
+
readonly instance: object | null;
|
|
36
|
+
/** Validator key, e.g. `'not_unique'`, `'is_null'`, `'isEmail'`. */
|
|
37
|
+
readonly validatorKey: string | null;
|
|
38
|
+
/** Built-in validator name. */
|
|
39
|
+
readonly validatorName: string | null;
|
|
40
|
+
/** Built-in validator arguments. */
|
|
41
|
+
readonly validatorArgs: readonly unknown[];
|
|
42
|
+
/**
|
|
43
|
+
* Creates an item; `path`, `instance`, `validatorKey` and `validatorName` default to `null`, `validatorArgs` to `[]`, and `value` to `null` when `undefined`.
|
|
44
|
+
*
|
|
45
|
+
* @param message - Human-readable message.
|
|
46
|
+
* @param type - Validation type or origin.
|
|
47
|
+
* @param path - Attribute name.
|
|
48
|
+
* @param value - Offending value.
|
|
49
|
+
* @param instance - Instance being validated.
|
|
50
|
+
* @param validatorKey - Validator key.
|
|
51
|
+
* @param validatorName - Built-in validator name.
|
|
52
|
+
* @param validatorArgs - Built-in validator arguments.
|
|
53
|
+
*/
|
|
54
|
+
constructor(message: string, type?: string | null, path?: string | null, value?: unknown, instance?: object | null, validatorKey?: string | null, validatorName?: string | null, validatorArgs?: readonly unknown[]);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when a model instance fails validation, carrying one item per failed rule (Sequelize v6 `ValidationError`).
|
|
58
|
+
*
|
|
59
|
+
* Raised by `create`, `save`, `update`, `build(...).validate()` and similar before any SQL is sent. Not-null, unique and validator failures all end up in `errors`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* try {
|
|
64
|
+
* await User.create({ email: 'not-an-email' });
|
|
65
|
+
* } catch (e) {
|
|
66
|
+
* if (e instanceof ValidationError) {
|
|
67
|
+
* console.error(e.errors.map((item) => `${item.path}: ${item.message}`));
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class ValidationError extends BaseError {
|
|
73
|
+
/** Individual validation failures. */
|
|
74
|
+
readonly errors: readonly ValidationErrorItem[];
|
|
75
|
+
/**
|
|
76
|
+
* Creates the error from a message and its items.
|
|
77
|
+
*
|
|
78
|
+
* @param message - Error message; when empty it is built from the items like Sequelize v6.
|
|
79
|
+
* @param errors - Individual validation failures.
|
|
80
|
+
*/
|
|
81
|
+
constructor(message: string | null | undefined, errors?: readonly ValidationErrorItem[]);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Thrown when PostgreSQL reports a unique violation (SQLSTATE `23505`); a {@link ValidationError} subclass like in Sequelize v6.
|
|
85
|
+
*
|
|
86
|
+
* `fields` maps the unique columns to the offending values (parsed from the PostgreSQL detail) and `errors` has one `not_unique` item per column.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* try {
|
|
91
|
+
* await User.create({ email: 'taken@example.com' });
|
|
92
|
+
* } catch (e) {
|
|
93
|
+
* if (e instanceof UniqueConstraintError) {
|
|
94
|
+
* console.error(e.fields, e.errors[0]?.message);
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare class UniqueConstraintError extends ValidationError {
|
|
100
|
+
/** Original driver error. */
|
|
101
|
+
readonly parent: DriverError;
|
|
102
|
+
/** Original driver error (alias of `parent`). */
|
|
103
|
+
readonly original: DriverError;
|
|
104
|
+
/** Executed SQL text. */
|
|
105
|
+
readonly sql: string;
|
|
106
|
+
/** Unique columns mapped to offending values. */
|
|
107
|
+
readonly fields: Readonly<Record<string, string>>;
|
|
108
|
+
/**
|
|
109
|
+
* Builds the error; the message defaults to `Validation error`.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Driver error, fields and validation items.
|
|
112
|
+
*/
|
|
113
|
+
constructor(options: Omit<ConstraintErrorOptions, 'fields'> & Readonly<{
|
|
114
|
+
fields?: Readonly<Record<string, string>>;
|
|
115
|
+
errors?: readonly ValidationErrorItem[];
|
|
116
|
+
}>);
|
|
117
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { DataTypes } from './data-types/data-types.ts';
|
|
2
|
+
export type { CompositeValue, DataType, DataTypeInput, DefaultValueGenerator, GeoCircle, GeoLine, GeoPath, GeoPoint, IntegerDataType, RangeBound, } from './data-types/data-types.ts';
|
|
3
|
+
export { Op } from './expressions/op.ts';
|
|
4
|
+
export type { OpSymbol } from './expressions/op.ts';
|
|
5
|
+
export { jsonbPath } from './expressions/jsonpath-helpers.ts';
|
|
6
|
+
export type { JsonbPathKind, JsonbPathOptions } from './expressions/jsonpath-helpers.ts';
|
|
7
|
+
export { plainToTsQuery, phraseToTsQuery, setWeight, toTsQuery, toTsVector, tsHeadline, tsRank, websearchToTsQuery, } from './expressions/search-helpers.ts';
|
|
8
|
+
export type { TsHeadlineOptions, TsRankOptions } from './expressions/search-helpers.ts';
|
|
9
|
+
export { trigramDistance, trigramSimilarity, trigramWordSimilarity, } from './expressions/trigram-helpers.ts';
|
|
10
|
+
export { cast, col, excluded, exists, fn, json, literal, notExists, over, tuple, where, } from './expressions/methods.ts';
|
|
11
|
+
export type { Cast, Col, Excluded, Exists, Fn, Json, Literal, Over, SqlExpression, SetOperationOptions, Subquery, WriteStatement, Tuple, Where, WhereFactory, WindowOptions, } from './expressions/methods.ts';
|
|
12
|
+
export { Transaction, ISOLATION_LEVELS, LOCK, TRANSACTION_TYPES, } from './transaction/transaction.ts';
|
|
13
|
+
export type { AdvisoryLockKey, IsolationLevel, LockStrength, TransactionOptions, } from './transaction/transaction.ts';
|
|
14
|
+
export type { ConnectionConfig, LoggingFunction, ModelDefaults, PoolOptions, StatementCacheOptions, ReplicationMember, ReplicationOptions, SequelizeOptions, } from './connection/options.ts';
|
|
15
|
+
export type { Replacements, BindParameters } from './query/raw-query.ts';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './decorators/association-decorators.ts';
|
|
2
|
+
export * from './decorators/column-decorators.ts';
|
|
3
|
+
export * from './decorators/foreign-key-decorator.ts';
|
|
4
|
+
export * from './decorators/hook-decorators.ts';
|
|
5
|
+
export * from './decorators/table-decorators.ts';
|
|
6
|
+
export * from './decorators/timestamp-decorators.ts';
|
|
7
|
+
export type { ModelClassDecorator, ModelPropertyDecorator, ModelStaticMethodDecorator, } from './decorators/decorator-types.ts';
|
|
8
|
+
export type { ModelGetter, ScopesInput, TableOptions } from './decorators/model-metadata.ts';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AccessDeniedError, AggregateError, AssociationError, BaseError, BulkRecordError, ConnectionAcquireTimeoutError, ConnectionError, ConnectionRefusedError, ConnectionTimedOutError, DatabaseError, EagerLoadingError, EmptyResultError, ExclusionConstraintError, ForeignKeyConstraintError, HostNotFoundError, HostNotReachableError, InstanceError, InvalidConnectionError, OptimisticLockError, TimeoutError, UniqueConstraintError, ValidationError, ValidationErrorItem, } from './errors/errors.ts';
|
|
2
|
+
export type { ConstraintErrorOptions, DriverError, QueryErrorContext, ValidationErrorItemOrigin, } from './errors/errors.ts';
|