postgrelize 0.0.0-stage → 1.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.
- package/CHANGELOG.md +289 -0
- package/LICENSE +21 -0
- package/README.md +131 -2
- package/dist/associations/alias-minifier.d.ts +43 -0
- 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/after-connect-hook.d.ts +24 -0
- package/dist/connection/connect-hooks.d.ts +26 -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 +165 -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 +176 -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 +204 -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 +186 -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 +232 -0
- package/dist/errors/validation-errors.d.ts +141 -0
- package/dist/exports-associations.d.ts +6 -0
- package/dist/exports-core.d.ts +95 -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/logic.d.ts +25 -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 +21864 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +21688 -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/inflector.d.ts +28 -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 +88 -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 +113 -0
- package/dist/model/mixins/model-constructor.d.ts +7 -0
- package/dist/model/mixins/model-finders.d.ts +140 -0
- package/dist/model/mixins/model-hooks.d.ts +142 -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 +100 -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 +197 -0
- package/dist/model/model-operations.d.ts +22 -0
- package/dist/model/model-registry.d.ts +152 -0
- package/dist/model/model-services.d.ts +46 -0
- package/dist/model/model-state.d.ts +68 -0
- package/dist/model/model-values.d.ts +86 -0
- package/dist/model/model.d.ts +629 -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 +99 -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 +56 -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/package-version.d.ts +8 -0
- package/dist/query/query-result-shaper.d.ts +93 -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-catalog.d.ts +180 -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 +110 -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/instance-hook-adders.d.ts +72 -0
- package/dist/sequelize/sequelize-base.d.ts +196 -0
- package/dist/sequelize/sequelize-constructor.d.ts +7 -0
- package/dist/sequelize/sequelize-helpers.d.ts +133 -0
- package/dist/sequelize/sequelize-hooks.d.ts +99 -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 +125 -0
- package/dist/sequelize/sequelize-transactions.d.ts +96 -0
- package/dist/sequelize.d.ts +1175 -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/cls-namespace.d.ts +44 -0
- package/dist/transaction/transaction-constants.d.ts +35 -0
- package/dist/transaction/transaction-runner.d.ts +78 -0
- package/dist/transaction/transaction-starter.d.ts +25 -0
- package/dist/transaction/transaction-statements.d.ts +29 -0
- package/dist/transaction/transaction.d.ts +201 -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 +103 -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,87 @@
|
|
|
1
|
+
import { ConnectionConfig } from '../connection/connection-config.ts';
|
|
2
|
+
import { ConnectionManager } from '../connection/connection-manager.ts';
|
|
3
|
+
import { ExecuteOptions, QueryResult } from '../connection/connection-types.ts';
|
|
4
|
+
import { NotificationHandler } from '../connection/notifications.ts';
|
|
5
|
+
import { ConnectionConfig as ConnectionSettings } from '../connection/options.ts';
|
|
6
|
+
import { HookRegistry } from '../hooks/hooks.ts';
|
|
7
|
+
import { ModelAttributes } from '../model/model-definition.ts';
|
|
8
|
+
import { AnyModel, ModelStatic } from '../model/options.ts';
|
|
9
|
+
import { ModelRuntime, QueryOptionsBase } from '../model/runtime.ts';
|
|
10
|
+
import { QueryInterface } from '../query-interface/query-interface.ts';
|
|
11
|
+
import { CompiledQuery } from '../sql/compile.ts';
|
|
12
|
+
import { Transaction, TransactionOptions } from '../transaction/transaction.ts';
|
|
13
|
+
/** What the internals need from the owning `Sequelize` instance. */
|
|
14
|
+
export type InternalsOwner = Readonly<{
|
|
15
|
+
models: Record<string, ModelStatic<AnyModel>>;
|
|
16
|
+
config: ConnectionSettings;
|
|
17
|
+
define: (name: string, attributes: ModelAttributes, options?: Record<string, unknown>) => object;
|
|
18
|
+
getQueryInterface: () => QueryInterface;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* State and services behind a `Sequelize` instance: hooks, connections, query execution,
|
|
22
|
+
* transactions, notifications and the runtime handed to models.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare class SequelizeInternals {
|
|
27
|
+
#private;
|
|
28
|
+
/** Hooks registered on the instance. */
|
|
29
|
+
hooks: HookRegistry;
|
|
30
|
+
/** Pools of the instance. */
|
|
31
|
+
readonly connections: ConnectionManager;
|
|
32
|
+
/** Schema API, created on first use. */
|
|
33
|
+
queryInterface: QueryInterface | undefined;
|
|
34
|
+
/** Services provided to models. */
|
|
35
|
+
readonly runtime: ModelRuntime;
|
|
36
|
+
/**
|
|
37
|
+
* @param owner - The `Sequelize` instance.
|
|
38
|
+
* @param connectionConfig - Normalized connection configuration.
|
|
39
|
+
*/
|
|
40
|
+
constructor(owner: InternalsOwner, connectionConfig: ConnectionConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Runs a compiled query on the pool or transaction the options select.
|
|
43
|
+
*
|
|
44
|
+
* @param query - Query text and values.
|
|
45
|
+
* @param options - Transaction, logging and routing options.
|
|
46
|
+
* @param kind - `'read'` queries may run on a replica.
|
|
47
|
+
* @returns Query result.
|
|
48
|
+
*/
|
|
49
|
+
execute(query: CompiledQuery, options: QueryOptionsBase, kind?: 'read' | 'write'): Promise<QueryResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the transaction, replica route and logging of one query.
|
|
52
|
+
*
|
|
53
|
+
* @param options - Query options.
|
|
54
|
+
* @param kind - `'read'` queries may run on a replica.
|
|
55
|
+
* @returns Connection manager execute options.
|
|
56
|
+
*/
|
|
57
|
+
executeOptions(options: QueryOptionsBase, kind?: 'read' | 'write'): ExecuteOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Starts an unmanaged transaction.
|
|
60
|
+
*
|
|
61
|
+
* @param options - Transaction options.
|
|
62
|
+
* @returns Started transaction.
|
|
63
|
+
*/
|
|
64
|
+
begin(options?: TransactionOptions): Promise<Transaction>;
|
|
65
|
+
/**
|
|
66
|
+
* Runs `run` in a managed transaction.
|
|
67
|
+
*
|
|
68
|
+
* @param options - Transaction options.
|
|
69
|
+
* @param run - Callback receiving the transaction.
|
|
70
|
+
* @returns Result of `run`.
|
|
71
|
+
*/
|
|
72
|
+
managed<T>(options: TransactionOptions, run: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Subscribes to a `NOTIFY` channel.
|
|
75
|
+
*
|
|
76
|
+
* @param channel - Channel name.
|
|
77
|
+
* @param handler - Notification handler.
|
|
78
|
+
* @returns Function that unsubscribes the handler.
|
|
79
|
+
*/
|
|
80
|
+
listen(channel: string, handler: NotificationHandler): Promise<() => Promise<void>>;
|
|
81
|
+
/**
|
|
82
|
+
* Closes the notification connection and all pools.
|
|
83
|
+
*
|
|
84
|
+
* @returns Resolves when closed.
|
|
85
|
+
*/
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { NotificationHandler } from '../connection/notifications.ts';
|
|
2
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
3
|
+
import { SequelizeConstructor } from './sequelize-constructor.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Notification methods of `Sequelize` (PostgreSQL extension): `listen` and `notify`.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const SequelizeNotifications: <TBase extends SequelizeConstructor>(Base: TBase) => {
|
|
10
|
+
new (...args: any[]): {
|
|
11
|
+
/**
|
|
12
|
+
* Subscribes a handler to `NOTIFY` messages on a channel over one dedicated connection per instance, which is
|
|
13
|
+
* re-subscribed after connection loss. PostgreSQL extension.
|
|
14
|
+
*
|
|
15
|
+
* @param channel - Channel name.
|
|
16
|
+
* @param handler - Called with the payload and the channel.
|
|
17
|
+
* @returns Function that unsubscribes the handler.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const stop = await sequelize.listen('jobs', (payload, channel) => {
|
|
22
|
+
* console.log(channel, payload);
|
|
23
|
+
* });
|
|
24
|
+
* await sequelize.notify('jobs', { id: 1 });
|
|
25
|
+
* await stop();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
listen(channel: string, handler: NotificationHandler): Promise<() => Promise<void>>;
|
|
29
|
+
/**
|
|
30
|
+
* Sends a notification to a channel with `pg_notify`. PostgreSQL extension.
|
|
31
|
+
*
|
|
32
|
+
* @param channel - Channel name.
|
|
33
|
+
* @param payload - Payload text (objects are sent as JSON).
|
|
34
|
+
* @param options - Query options (inside a transaction the notification is sent on commit).
|
|
35
|
+
* @returns Resolves when sent.
|
|
36
|
+
* @see {@link Sequelize.listen}
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* await sequelize.notify('jobs', 'refresh');
|
|
41
|
+
* await sequelize.notify('jobs', { id: 42 }, { transaction });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
notify(channel: string, payload?: unknown, options?: QueryOptionsBase): Promise<void>;
|
|
45
|
+
readonly options: import('../exports-core.ts').SequelizeOptions;
|
|
46
|
+
readonly config: import('../exports-core.ts').ConnectionConfig;
|
|
47
|
+
readonly models: Record<string, import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>>;
|
|
48
|
+
readonly literal: (val: string) => import('../exports-core.ts').Literal;
|
|
49
|
+
readonly fn: (name: string, ...args: readonly unknown[]) => import('../exports-core.ts').Fn;
|
|
50
|
+
readonly col: (name: string) => import('../exports-core.ts').Col;
|
|
51
|
+
readonly cast: (val: unknown, type: string) => import('../exports-core.ts').Cast;
|
|
52
|
+
readonly where: import('../exports-core.ts').WhereFactory;
|
|
53
|
+
readonly json: (conditionsOrPath: string | object, value?: unknown) => import('../exports-core.ts').Json;
|
|
54
|
+
readonly internals: import('./sequelize-internals.ts').SequelizeInternals;
|
|
55
|
+
getDialect(): "postgres";
|
|
56
|
+
define<M extends import('../exports-model.ts').AnyModel = import('../exports-model.ts').Model<import('../exports-model.ts').Values, import('../exports-model.ts').Values>>(modelName: string, attributes: import('../exports-model.ts').ModelAttributes, options?: import('./sequelize-base.ts').DefineOptions): import('../exports-model.ts').ModelStatic<M>;
|
|
57
|
+
addModels(models: readonly import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>[]): /*elided*/ any;
|
|
58
|
+
model(modelName: string): import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>;
|
|
59
|
+
isDefined(modelName: string): boolean;
|
|
60
|
+
query(sql: string | import('../exports-core.ts').Literal, options?: import('../sequelize.ts').QueryOptions): Promise<unknown>;
|
|
61
|
+
getQueryInterface(): import('../exports-schema.ts').QueryInterface;
|
|
62
|
+
authenticate(options?: QueryOptionsBase): Promise<void>;
|
|
63
|
+
databaseVersion(options?: QueryOptionsBase): Promise<string>;
|
|
64
|
+
close(): Promise<void>;
|
|
65
|
+
};
|
|
66
|
+
} & TBase;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
2
|
+
import { DropOptions, SyncOptions } from '../query-interface/schema-synchronizer.ts';
|
|
3
|
+
import { SequelizeConstructor } from './sequelize-constructor.ts';
|
|
4
|
+
type TruncateOptions = QueryOptionsBase & Readonly<{
|
|
5
|
+
cascade?: boolean;
|
|
6
|
+
restartIdentity?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Schema methods of `Sequelize`: schema management, `sync` and `drop`.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const SequelizeSchema: <TBase extends SequelizeConstructor>(Base: TBase) => {
|
|
14
|
+
new (...args: any[]): {
|
|
15
|
+
/**
|
|
16
|
+
* Runs `CREATE SCHEMA IF NOT EXISTS` for a schema.
|
|
17
|
+
*
|
|
18
|
+
* @param schema - Schema name.
|
|
19
|
+
* @param options - Query options.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* await sequelize.createSchema('tenant_1');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
createSchema(schema: string, options?: QueryOptionsBase): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Lists the schemas that belong to the application (without `public`, `information_schema` and `pg_*`).
|
|
29
|
+
*
|
|
30
|
+
* @param options - Query options.
|
|
31
|
+
* @returns Schema names.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const schemas = await sequelize.showAllSchemas(); // e.g. ['tenant_1']
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
showAllSchemas(options?: QueryOptionsBase): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Runs `DROP SCHEMA IF EXISTS ... CASCADE`, removing the schema and every object in it.
|
|
41
|
+
*
|
|
42
|
+
* @param schema - Schema name.
|
|
43
|
+
* @param options - Query options.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* await sequelize.dropSchema('tenant_1');
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
dropSchema(schema: string, options?: QueryOptionsBase): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Drops every schema returned by {@link Sequelize.showAllSchemas} with `CASCADE`. Destructive.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Query options.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* await sequelize.dropAllSchemas();
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
dropAllSchemas(options?: QueryOptionsBase): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Creates (or alters / re-creates) the tables of all defined models in foreign-key order. Reference cycles use deferred foreign keys.
|
|
64
|
+
*
|
|
65
|
+
* @param options - `force`, `alter`, `match` and query options.
|
|
66
|
+
* @returns This instance.
|
|
67
|
+
* @throws Error when `options.match` does not match the database name.
|
|
68
|
+
* @see {@link Model.sync}
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* await sequelize.sync({ alter: { drop: false } });
|
|
73
|
+
* await sequelize.sync({ force: true, match: /_test$/ });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
sync(options?: SyncOptions): Promise</*elided*/ any>;
|
|
77
|
+
/**
|
|
78
|
+
* Drops the tables of all defined models in reverse foreign-key order. Destructive.
|
|
79
|
+
*
|
|
80
|
+
* @param options - `cascade` and query options.
|
|
81
|
+
* @returns Resolves when done.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* await sequelize.drop({ cascade: true });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
drop(options?: DropOptions): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Empties the tables of all defined models (`TRUNCATE`), tables that reference others first. With
|
|
91
|
+
* `cascade` the tables are truncated one after the other, otherwise all at once. Destructive.
|
|
92
|
+
*
|
|
93
|
+
* @param options - `cascade`, `restartIdentity` and query options.
|
|
94
|
+
* @returns Resolves when done.
|
|
95
|
+
* @throws Error when foreign keys form a cycle and `cascade` is not set.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* await sequelize.truncate({ cascade: true });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
truncate(options?: TruncateOptions): Promise<void>;
|
|
103
|
+
readonly options: import('../exports-core.ts').SequelizeOptions;
|
|
104
|
+
readonly config: import('../exports-core.ts').ConnectionConfig;
|
|
105
|
+
readonly models: Record<string, import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>>;
|
|
106
|
+
readonly literal: (val: string) => import('../exports-core.ts').Literal;
|
|
107
|
+
readonly fn: (name: string, ...args: readonly unknown[]) => import('../exports-core.ts').Fn;
|
|
108
|
+
readonly col: (name: string) => import('../exports-core.ts').Col;
|
|
109
|
+
readonly cast: (val: unknown, type: string) => import('../exports-core.ts').Cast;
|
|
110
|
+
readonly where: import('../exports-core.ts').WhereFactory;
|
|
111
|
+
readonly json: (conditionsOrPath: string | object, value?: unknown) => import('../exports-core.ts').Json;
|
|
112
|
+
readonly internals: import('./sequelize-internals.ts').SequelizeInternals;
|
|
113
|
+
getDialect(): "postgres";
|
|
114
|
+
define<M extends import('../exports-model.ts').AnyModel = import('../exports-model.ts').Model<import('../exports-model.ts').Values, import('../exports-model.ts').Values>>(modelName: string, attributes: import('../exports-model.ts').ModelAttributes, options?: import('./sequelize-base.ts').DefineOptions): import('../exports-model.ts').ModelStatic<M>;
|
|
115
|
+
addModels(models: readonly import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>[]): /*elided*/ any;
|
|
116
|
+
model(modelName: string): import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>;
|
|
117
|
+
isDefined(modelName: string): boolean;
|
|
118
|
+
query(sql: string | import('../exports-core.ts').Literal, options?: import('../sequelize.ts').QueryOptions): Promise<unknown>;
|
|
119
|
+
getQueryInterface(): import('../exports-schema.ts').QueryInterface;
|
|
120
|
+
authenticate(options?: QueryOptionsBase): Promise<void>;
|
|
121
|
+
databaseVersion(options?: QueryOptionsBase): Promise<string>;
|
|
122
|
+
close(): Promise<void>;
|
|
123
|
+
};
|
|
124
|
+
} & TBase;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { AdvisoryLockKey, Transaction, TransactionOptions } from '../transaction/transaction.ts';
|
|
2
|
+
import { SequelizeConstructor } from './sequelize-constructor.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Transaction methods of `Sequelize`: `transaction` and `withAdvisoryLock`.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const SequelizeTransactions: <TBase extends SequelizeConstructor>(Base: TBase) => {
|
|
9
|
+
new (...args: any[]): {
|
|
10
|
+
/**
|
|
11
|
+
* Begins an unmanaged transaction that you must commit or roll back yourself. With `options.transaction` it becomes a savepoint inside that transaction.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Transaction options.
|
|
14
|
+
* @returns Started transaction.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const t = await sequelize.transaction({ isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE });
|
|
19
|
+
* try {
|
|
20
|
+
* await User.create({ name: 'Ada' }, { transaction: t });
|
|
21
|
+
* await t.commit();
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* await t.rollback();
|
|
24
|
+
* throw error;
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
transaction(options?: TransactionOptions): Promise<Transaction>;
|
|
29
|
+
/**
|
|
30
|
+
* Runs a callback in a managed transaction: committed when it resolves, rolled back when it throws. Queries must pass `{ transaction }` unless CLS is enabled with {@link Sequelize.useCLS}.
|
|
31
|
+
*
|
|
32
|
+
* @param run - Callback receiving the transaction.
|
|
33
|
+
* @returns Result of `run`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const created = await sequelize.transaction(async (t) => {
|
|
38
|
+
* const owner = await User.create({ name: 'Ada' }, { transaction: t });
|
|
39
|
+
* return Post.create({ title: 'Hello', userId: owner.id }, { transaction: t });
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
transaction<T>(run: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Runs a callback in a managed transaction started with the given options (isolation level, read only, settings, savepoint parent).
|
|
46
|
+
*
|
|
47
|
+
* @param options - Transaction options.
|
|
48
|
+
* @param run - Callback receiving the transaction.
|
|
49
|
+
* @returns Result of `run`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const count = await sequelize.transaction({ readOnly: true }, async (t) => {
|
|
54
|
+
* return User.count({ transaction: t });
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
transaction<T>(options: TransactionOptions, run: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Runs a callback in a managed transaction that first takes a transaction-level advisory lock, so concurrent callers with the same key run one at a time. The lock is released when the transaction ends. PostgreSQL extension.
|
|
61
|
+
*
|
|
62
|
+
* @param key - Lock key (integer or string).
|
|
63
|
+
* @param run - Callback receiving the transaction.
|
|
64
|
+
* @param options - Transaction options.
|
|
65
|
+
* @returns Result of `run`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* await sequelize.withAdvisoryLock('nightly-report', async (t) => {
|
|
70
|
+
* await Invoice.update({ status: 'sent' }, { where: { status: 'ready' }, transaction: t });
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
withAdvisoryLock<T>(key: AdvisoryLockKey, run: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
75
|
+
readonly options: import('../exports-core.ts').SequelizeOptions;
|
|
76
|
+
readonly config: import('../exports-core.ts').ConnectionConfig;
|
|
77
|
+
readonly models: Record<string, import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>>;
|
|
78
|
+
readonly literal: (val: string) => import('../exports-core.ts').Literal;
|
|
79
|
+
readonly fn: (name: string, ...args: readonly unknown[]) => import('../exports-core.ts').Fn;
|
|
80
|
+
readonly col: (name: string) => import('../exports-core.ts').Col;
|
|
81
|
+
readonly cast: (val: unknown, type: string) => import('../exports-core.ts').Cast;
|
|
82
|
+
readonly where: import('../exports-core.ts').WhereFactory;
|
|
83
|
+
readonly json: (conditionsOrPath: string | object, value?: unknown) => import('../exports-core.ts').Json;
|
|
84
|
+
readonly internals: import('./sequelize-internals.ts').SequelizeInternals;
|
|
85
|
+
getDialect(): "postgres";
|
|
86
|
+
define<M extends import('../exports-model.ts').AnyModel = import('../exports-model.ts').Model<import('../exports-model.ts').Values, import('../exports-model.ts').Values>>(modelName: string, attributes: import('../exports-model.ts').ModelAttributes, options?: import('./sequelize-base.ts').DefineOptions): import('../exports-model.ts').ModelStatic<M>;
|
|
87
|
+
addModels(models: readonly import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>[]): /*elided*/ any;
|
|
88
|
+
model(modelName: string): import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>;
|
|
89
|
+
isDefined(modelName: string): boolean;
|
|
90
|
+
query(sql: string | import('../exports-core.ts').Literal, options?: import('../sequelize.ts').QueryOptions): Promise<unknown>;
|
|
91
|
+
getQueryInterface(): import('../exports-schema.ts').QueryInterface;
|
|
92
|
+
authenticate(options?: import('../exports-model.ts').QueryOptionsBase): Promise<void>;
|
|
93
|
+
databaseVersion(options?: import('../exports-model.ts').QueryOptionsBase): Promise<string>;
|
|
94
|
+
close(): Promise<void>;
|
|
95
|
+
};
|
|
96
|
+
} & TBase;
|