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,393 @@
|
|
|
1
|
+
import { ModelStaticMethodDecorator } from './decorator-types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the decorated static method as a `beforeValidate` hook of the model (like `Model.beforeValidate`).
|
|
4
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
5
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* class User extends Model {
|
|
10
|
+
* @BeforeValidate
|
|
11
|
+
* static async onBeforeValidate(user: User, options: unknown) {}
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const BeforeValidate: ModelStaticMethodDecorator;
|
|
16
|
+
/**
|
|
17
|
+
* Registers the decorated static method as an `afterValidate` hook of the model (like `Model.afterValidate`).
|
|
18
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
19
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* class User extends Model {
|
|
24
|
+
* @AfterValidate
|
|
25
|
+
* static async onAfterValidate(user: User, options: unknown) {}
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const AfterValidate: ModelStaticMethodDecorator;
|
|
30
|
+
/**
|
|
31
|
+
* Registers the decorated static method as a `validationFailed` hook of the model (like `Model.validationFailed`).
|
|
32
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
33
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* class User extends Model {
|
|
38
|
+
* @ValidationFailed
|
|
39
|
+
* static async onValidationFailed(user: User, options: unknown, error: unknown) {}
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const ValidationFailed: ModelStaticMethodDecorator;
|
|
44
|
+
/**
|
|
45
|
+
* Registers the decorated static method as a `beforeCreate` hook of the model (like `Model.beforeCreate`).
|
|
46
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
47
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* class User extends Model {
|
|
52
|
+
* @BeforeCreate
|
|
53
|
+
* static async onBeforeCreate(user: User, options: unknown) {}
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const BeforeCreate: ModelStaticMethodDecorator;
|
|
58
|
+
/**
|
|
59
|
+
* Registers the decorated static method as an `afterCreate` hook of the model (like `Model.afterCreate`).
|
|
60
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
61
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* class User extends Model {
|
|
66
|
+
* @AfterCreate
|
|
67
|
+
* static async onAfterCreate(user: User, options: unknown) {}
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const AfterCreate: ModelStaticMethodDecorator;
|
|
72
|
+
/**
|
|
73
|
+
* Registers the decorated static method as a `beforeUpdate` hook of the model (like `Model.beforeUpdate`).
|
|
74
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
75
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* class User extends Model {
|
|
80
|
+
* @BeforeUpdate
|
|
81
|
+
* static async onBeforeUpdate(user: User, options: unknown) {}
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const BeforeUpdate: ModelStaticMethodDecorator;
|
|
86
|
+
/**
|
|
87
|
+
* Registers the decorated static method as an `afterUpdate` hook of the model (like `Model.afterUpdate`).
|
|
88
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
89
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* class User extends Model {
|
|
94
|
+
* @AfterUpdate
|
|
95
|
+
* static async onAfterUpdate(user: User, options: unknown) {}
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const AfterUpdate: ModelStaticMethodDecorator;
|
|
100
|
+
/**
|
|
101
|
+
* Registers the decorated static method as a `beforeSave` hook of the model (like `Model.beforeSave`).
|
|
102
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
103
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* class User extends Model {
|
|
108
|
+
* @BeforeSave
|
|
109
|
+
* static async onBeforeSave(user: User, options: unknown) {}
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const BeforeSave: ModelStaticMethodDecorator;
|
|
114
|
+
/**
|
|
115
|
+
* Registers the decorated static method as an `afterSave` hook of the model (like `Model.afterSave`).
|
|
116
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
117
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* class User extends Model {
|
|
122
|
+
* @AfterSave
|
|
123
|
+
* static async onAfterSave(user: User, options: unknown) {}
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare const AfterSave: ModelStaticMethodDecorator;
|
|
128
|
+
/**
|
|
129
|
+
* Registers the decorated static method as a `beforeDestroy` hook of the model (like `Model.beforeDestroy`).
|
|
130
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
131
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* class User extends Model {
|
|
136
|
+
* @BeforeDestroy
|
|
137
|
+
* static async onBeforeDestroy(user: User, options: unknown) {}
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare const BeforeDestroy: ModelStaticMethodDecorator;
|
|
142
|
+
/**
|
|
143
|
+
* Registers the decorated static method as an `afterDestroy` hook of the model (like `Model.afterDestroy`).
|
|
144
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
145
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* class User extends Model {
|
|
150
|
+
* @AfterDestroy
|
|
151
|
+
* static async onAfterDestroy(user: User, options: unknown) {}
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare const AfterDestroy: ModelStaticMethodDecorator;
|
|
156
|
+
/**
|
|
157
|
+
* Registers the decorated static method as a `beforeRestore` hook of the model (like `Model.beforeRestore`).
|
|
158
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
159
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* class User extends Model {
|
|
164
|
+
* @BeforeRestore
|
|
165
|
+
* static async onBeforeRestore(user: User, options: unknown) {}
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare const BeforeRestore: ModelStaticMethodDecorator;
|
|
170
|
+
/**
|
|
171
|
+
* Registers the decorated static method as an `afterRestore` hook of the model (like `Model.afterRestore`).
|
|
172
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
173
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* class User extends Model {
|
|
178
|
+
* @AfterRestore
|
|
179
|
+
* static async onAfterRestore(user: User, options: unknown) {}
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare const AfterRestore: ModelStaticMethodDecorator;
|
|
184
|
+
/**
|
|
185
|
+
* Registers the decorated static method as a `beforeUpsert` hook of the model (like `Model.beforeUpsert`).
|
|
186
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
187
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* class User extends Model {
|
|
192
|
+
* @BeforeUpsert
|
|
193
|
+
* static async onBeforeUpsert(values: unknown, options: unknown) {}
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare const BeforeUpsert: ModelStaticMethodDecorator;
|
|
198
|
+
/**
|
|
199
|
+
* Registers the decorated static method as an `afterUpsert` hook of the model (like `Model.afterUpsert`).
|
|
200
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
201
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* class User extends Model {
|
|
206
|
+
* @AfterUpsert
|
|
207
|
+
* static async onAfterUpsert(result: unknown, options: unknown) {}
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export declare const AfterUpsert: ModelStaticMethodDecorator;
|
|
212
|
+
/**
|
|
213
|
+
* Registers the decorated static method as a `beforeBulkCreate` hook of the model (like `Model.beforeBulkCreate`).
|
|
214
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
215
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* class User extends Model {
|
|
220
|
+
* @BeforeBulkCreate
|
|
221
|
+
* static async onBeforeBulkCreate(users: User[], options: unknown) {}
|
|
222
|
+
* }
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
export declare const BeforeBulkCreate: ModelStaticMethodDecorator;
|
|
226
|
+
/**
|
|
227
|
+
* Registers the decorated static method as an `afterBulkCreate` hook of the model (like `Model.afterBulkCreate`).
|
|
228
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
229
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* class User extends Model {
|
|
234
|
+
* @AfterBulkCreate
|
|
235
|
+
* static async onAfterBulkCreate(users: User[], options: unknown) {}
|
|
236
|
+
* }
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
export declare const AfterBulkCreate: ModelStaticMethodDecorator;
|
|
240
|
+
/**
|
|
241
|
+
* Registers the decorated static method as a `beforeBulkUpdate` hook of the model (like `Model.beforeBulkUpdate`).
|
|
242
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
243
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* class User extends Model {
|
|
248
|
+
* @BeforeBulkUpdate
|
|
249
|
+
* static async onBeforeBulkUpdate(options: unknown) {}
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export declare const BeforeBulkUpdate: ModelStaticMethodDecorator;
|
|
254
|
+
/**
|
|
255
|
+
* Registers the decorated static method as an `afterBulkUpdate` hook of the model (like `Model.afterBulkUpdate`).
|
|
256
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
257
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* class User extends Model {
|
|
262
|
+
* @AfterBulkUpdate
|
|
263
|
+
* static async onAfterBulkUpdate(options: unknown) {}
|
|
264
|
+
* }
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare const AfterBulkUpdate: ModelStaticMethodDecorator;
|
|
268
|
+
/**
|
|
269
|
+
* Registers the decorated static method as a `beforeBulkDestroy` hook of the model (like `Model.beforeBulkDestroy`).
|
|
270
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
271
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* class User extends Model {
|
|
276
|
+
* @BeforeBulkDestroy
|
|
277
|
+
* static async onBeforeBulkDestroy(options: unknown) {}
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare const BeforeBulkDestroy: ModelStaticMethodDecorator;
|
|
282
|
+
/**
|
|
283
|
+
* Registers the decorated static method as an `afterBulkDestroy` hook of the model (like `Model.afterBulkDestroy`).
|
|
284
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
285
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* class User extends Model {
|
|
290
|
+
* @AfterBulkDestroy
|
|
291
|
+
* static async onAfterBulkDestroy(options: unknown) {}
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
export declare const AfterBulkDestroy: ModelStaticMethodDecorator;
|
|
296
|
+
/**
|
|
297
|
+
* Registers the decorated static method as a `beforeBulkRestore` hook of the model (like `Model.beforeBulkRestore`).
|
|
298
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
299
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* class User extends Model {
|
|
304
|
+
* @BeforeBulkRestore
|
|
305
|
+
* static async onBeforeBulkRestore(options: unknown) {}
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
export declare const BeforeBulkRestore: ModelStaticMethodDecorator;
|
|
310
|
+
/**
|
|
311
|
+
* Registers the decorated static method as an `afterBulkRestore` hook of the model (like `Model.afterBulkRestore`).
|
|
312
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
313
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* class User extends Model {
|
|
318
|
+
* @AfterBulkRestore
|
|
319
|
+
* static async onAfterBulkRestore(options: unknown) {}
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
export declare const AfterBulkRestore: ModelStaticMethodDecorator;
|
|
324
|
+
/**
|
|
325
|
+
* Registers the decorated static method as a `beforeFind` hook of the model (like `Model.beforeFind`).
|
|
326
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
327
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* class User extends Model {
|
|
332
|
+
* @BeforeFind
|
|
333
|
+
* static async onBeforeFind(options: unknown) {}
|
|
334
|
+
* }
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
export declare const BeforeFind: ModelStaticMethodDecorator;
|
|
338
|
+
/**
|
|
339
|
+
* Registers the decorated static method as a `beforeFindAfterExpandIncludeAll` hook of the model (like `Model.beforeFindAfterExpandIncludeAll`).
|
|
340
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
341
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* class User extends Model {
|
|
346
|
+
* @BeforeFindAfterExpandIncludeAll
|
|
347
|
+
* static async onBeforeFindAfterExpandIncludeAll(options: unknown) {}
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
export declare const BeforeFindAfterExpandIncludeAll: ModelStaticMethodDecorator;
|
|
352
|
+
/**
|
|
353
|
+
* Registers the decorated static method as a `beforeFindAfterOptions` hook of the model (like `Model.beforeFindAfterOptions`).
|
|
354
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
355
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* class User extends Model {
|
|
360
|
+
* @BeforeFindAfterOptions
|
|
361
|
+
* static async onBeforeFindAfterOptions(options: unknown) {}
|
|
362
|
+
* }
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
export declare const BeforeFindAfterOptions: ModelStaticMethodDecorator;
|
|
366
|
+
/**
|
|
367
|
+
* Registers the decorated static method as an `afterFind` hook of the model (like `Model.afterFind`).
|
|
368
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
369
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* class User extends Model {
|
|
374
|
+
* @AfterFind
|
|
375
|
+
* static async onAfterFind(result: unknown, options: unknown) {}
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
export declare const AfterFind: ModelStaticMethodDecorator;
|
|
380
|
+
/**
|
|
381
|
+
* Registers the decorated static method as a `beforeCount` hook of the model (like `Model.beforeCount`).
|
|
382
|
+
* The method receives the hook arguments; static methods only. Registered when `sequelize.addModels` applies the class.
|
|
383
|
+
* Accepts the TC39 and the legacy `experimentalDecorators` call signature.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts
|
|
387
|
+
* class User extends Model {
|
|
388
|
+
* @BeforeCount
|
|
389
|
+
* static async onBeforeCount(options: unknown) {}
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export declare const BeforeCount: ModelStaticMethodDecorator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ModelAttributes } from '../model/model-definition.ts';
|
|
2
|
+
import { AnyModel, InitOptions, ModelStatic } from '../model/options.ts';
|
|
3
|
+
import { RuntimeOwner } from '../model/runtime.ts';
|
|
4
|
+
import { ModelMetadata } from './model-metadata.ts';
|
|
5
|
+
type Model = ModelStatic<AnyModel>;
|
|
6
|
+
/**
|
|
7
|
+
* Turns the metadata collected for a class into the arguments of `Model.init`, so a decorated
|
|
8
|
+
* model is initialized exactly like a hand-written `init` call.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class InitArguments {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* @param model - Decorated class.
|
|
16
|
+
* @param meta - Metadata collected for it.
|
|
17
|
+
* @returns Attributes for `Model.init`.
|
|
18
|
+
* @throws Error when an attribute has no type.
|
|
19
|
+
*/
|
|
20
|
+
attributes(model: Model, meta: ModelMetadata): ModelAttributes;
|
|
21
|
+
/**
|
|
22
|
+
* @param model - Decorated class.
|
|
23
|
+
* @param meta - Metadata collected for it.
|
|
24
|
+
* @param sequelize - Owning instance.
|
|
25
|
+
* @returns Options for `Model.init`.
|
|
26
|
+
*/
|
|
27
|
+
options(model: Model, meta: ModelMetadata, sequelize: RuntimeOwner): InitOptions;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyModel, ModelStatic } from '../model/options.ts';
|
|
2
|
+
import { RuntimeOwner } from '../model/runtime.ts';
|
|
3
|
+
type Model = ModelStatic<AnyModel>;
|
|
4
|
+
/**
|
|
5
|
+
* Registers decorated model classes: initializes every class with `Model.init`, then adds the
|
|
6
|
+
* declared associations, so classes may refer to each other regardless of their order.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ModelDecorators {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* @param sequelize - Instance the models are registered with.
|
|
14
|
+
* @param models - Decorated model classes.
|
|
15
|
+
*/
|
|
16
|
+
register(sequelize: RuntimeOwner, models: readonly Model[]): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AssociationOptions, ThroughOptions } from '../associations/types.ts';
|
|
2
|
+
import { IndexOptions } from '../ddl/ddl-generator.ts';
|
|
3
|
+
import { HookType } from '../hooks/hooks.ts';
|
|
4
|
+
import { AttributeOptions } from '../model/attribute-options.ts';
|
|
5
|
+
import { AnyModel, InitOptions, ModelStatic } from '../model/options.ts';
|
|
6
|
+
import { ScopeDefinition, ScopeOptions } from '../model/scope-registry.ts';
|
|
7
|
+
import { DecoratorTarget } from './decorator-signature.ts';
|
|
8
|
+
/** Lazily resolved model class, so decorators can refer to classes defined later in the file. */
|
|
9
|
+
export type ModelGetter = () => ModelStatic<AnyModel>;
|
|
10
|
+
/**
|
|
11
|
+
* Table options of `@Table`: the `Model.init` options without the `sequelize` instance.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const options: TableOptions = { tableName: 'users', schema: 'app', paranoid: true, timestamps: true };
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type TableOptions = Omit<InitOptions, 'sequelize'>;
|
|
19
|
+
/** Named scopes given to `@Scopes`. */
|
|
20
|
+
export type ScopesInput = Readonly<Record<string, ScopeDefinition>>;
|
|
21
|
+
/** Association collected from `@HasOne`, `@HasMany`, `@BelongsTo` or `@BelongsToMany`. */
|
|
22
|
+
export type AssociationSpec = Readonly<{
|
|
23
|
+
kind: 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany';
|
|
24
|
+
key: string;
|
|
25
|
+
target: ModelGetter;
|
|
26
|
+
options: AssociationOptions;
|
|
27
|
+
through?: string | ModelGetter | ThroughOptions;
|
|
28
|
+
}>;
|
|
29
|
+
/** Index collected from `@Index` on an attribute. */
|
|
30
|
+
export type IndexSpec = Readonly<{
|
|
31
|
+
key: string;
|
|
32
|
+
options: IndexOptions;
|
|
33
|
+
}>;
|
|
34
|
+
/** Everything the decorators collected for one class. */
|
|
35
|
+
export type ModelMetadata = {
|
|
36
|
+
table: TableOptions;
|
|
37
|
+
defaultScope?: ScopeOptions | (() => ScopeOptions);
|
|
38
|
+
scopes?: ScopesInput | (() => ScopesInput);
|
|
39
|
+
columns: Record<string, Partial<AttributeOptions>>;
|
|
40
|
+
timestamps: Partial<Record<'createdAt' | 'updatedAt' | 'deletedAt', string>>;
|
|
41
|
+
foreignKeys: Record<string, ModelGetter>;
|
|
42
|
+
indexes: IndexSpec[];
|
|
43
|
+
associations: AssociationSpec[];
|
|
44
|
+
hooks: {
|
|
45
|
+
type: HookType;
|
|
46
|
+
key: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Metadata that decorators collect, kept outside the decorated classes (no `reflect-metadata`).
|
|
51
|
+
* Decorated classes are looked up by the class itself (legacy decorators) or by their TC39
|
|
52
|
+
* `Symbol.metadata` bag; base classes contribute first.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export declare class MetadataStore {
|
|
57
|
+
#private;
|
|
58
|
+
/**
|
|
59
|
+
* @param target - What the running decorator decorates.
|
|
60
|
+
* @returns The metadata bag of its class, created on first use.
|
|
61
|
+
*/
|
|
62
|
+
of(target: DecoratorTarget): ModelMetadata;
|
|
63
|
+
/**
|
|
64
|
+
* @param model - Decorated class.
|
|
65
|
+
* @returns Metadata of the class merged with its base classes' (derived classes win).
|
|
66
|
+
*/
|
|
67
|
+
collect(model: object): ModelMetadata;
|
|
68
|
+
}
|
|
69
|
+
/** @internal Shared metadata store of all decorators. */
|
|
70
|
+
export declare const metadata: MetadataStore;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ScopeOptions } from '../model/scope-registry.ts';
|
|
2
|
+
import { ModelClassDecorator } from './decorator-types.ts';
|
|
3
|
+
import { ScopesInput, TableOptions } from './model-metadata.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Marks a class as a model and sets its table options: everything `Model.init` accepts except
|
|
6
|
+
* `sequelize`. Optional; a decorated class without `@Table` gets the `Model.init` defaults.
|
|
7
|
+
*
|
|
8
|
+
* Use it bare (`@Table`) or called. The class must be registered with `sequelize.addModels`.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Table options (`tableName`, `schema`, `timestamps`, `paranoid`, `indexes`, `hooks`, …).
|
|
11
|
+
* @returns A class decorator.
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* @Table({ tableName: 'users', paranoid: true })
|
|
15
|
+
* class User extends Model {}
|
|
16
|
+
* ```
|
|
17
|
+
* @see {@link Sequelize.addModels}
|
|
18
|
+
*/
|
|
19
|
+
export declare const Table: ModelClassDecorator & ((argument?: TableOptions | undefined) => ModelClassDecorator);
|
|
20
|
+
/**
|
|
21
|
+
* Sets the default scope of a model (`defaultScope` of `Model.init`).
|
|
22
|
+
*
|
|
23
|
+
* @param scope - Scope options, or a function returning them (evaluated by `addModels`, so it may refer to other models).
|
|
24
|
+
* @returns A class decorator.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* @DefaultScope(() => ({ where: { active: true } }))
|
|
28
|
+
* class User extends Model {}
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const DefaultScope: (scope: ScopeOptions | (() => ScopeOptions)) => ModelClassDecorator;
|
|
32
|
+
/**
|
|
33
|
+
* Defines the named scopes of a model (`scopes` of `Model.init`).
|
|
34
|
+
*
|
|
35
|
+
* @param scopes - Scopes by name (options or functions returning options), or a function returning them.
|
|
36
|
+
* @returns A class decorator.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* @Scopes({ recent: { order: [['createdAt', 'DESC']] }, named: (name: string) => ({ where: { name } }) })
|
|
40
|
+
* class User extends Model {}
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const Scopes: (scopes: ScopesInput | (() => ScopesInput)) => ModelClassDecorator;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ModelPropertyDecorator } from './decorator-types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Names the attribute that holds the creation time (`createdAt: '<attribute>'`).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* class User extends Model {
|
|
8
|
+
* @CreatedAt
|
|
9
|
+
* creationDate!: Date;
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const CreatedAt: ModelPropertyDecorator;
|
|
14
|
+
/**
|
|
15
|
+
* Names the attribute that holds the last update time (`updatedAt: '<attribute>'`).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* class User extends Model {
|
|
20
|
+
* @UpdatedAt
|
|
21
|
+
* updatedOn!: Date;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const UpdatedAt: ModelPropertyDecorator;
|
|
26
|
+
/**
|
|
27
|
+
* Names the attribute that holds the deletion time (`deletedAt: '<attribute>'`) and makes the
|
|
28
|
+
* model paranoid unless `@Table` sets `paranoid` explicitly.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* class User extends Model {
|
|
33
|
+
* @DeletedAt
|
|
34
|
+
* removedAt!: Date | null;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const DeletedAt: ModelPropertyDecorator;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Driver error object as produced by `pg` (a subset of its fields). */
|
|
2
|
+
export type DriverError = Error & Readonly<{
|
|
3
|
+
/** SQLSTATE or Node.js error code. */
|
|
4
|
+
code?: string;
|
|
5
|
+
/** Error detail reported by PostgreSQL. */
|
|
6
|
+
detail?: string;
|
|
7
|
+
/** Table the error refers to. */
|
|
8
|
+
table?: string;
|
|
9
|
+
/** Constraint the error refers to. */
|
|
10
|
+
constraint?: string;
|
|
11
|
+
/** Schema the error refers to. */
|
|
12
|
+
schema?: string;
|
|
13
|
+
/** Column the error refers to. */
|
|
14
|
+
column?: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Root of the error hierarchy, so one `instanceof` check catches every error postgrelize throws (Sequelize v6 `BaseError`).
|
|
18
|
+
*
|
|
19
|
+
* Programmer mistakes (such as committing a finished transaction) still throw a plain `Error`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* try {
|
|
24
|
+
* await User.findOne({ where: { id: 1 }, rejectOnEmpty: true });
|
|
25
|
+
* } catch (e) {
|
|
26
|
+
* if (e instanceof BaseError) {
|
|
27
|
+
* console.error(e.name, e.message);
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class BaseError extends Error {
|
|
33
|
+
/**
|
|
34
|
+
* Creates the error and sets `name` to `'SequelizeBaseError'`.
|
|
35
|
+
*
|
|
36
|
+
* @param message - Error message.
|
|
37
|
+
* @param options - Standard error options (`cause`).
|
|
38
|
+
*/
|
|
39
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
40
|
+
}
|