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,12 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* `BYTEA` (`DataTypes.BLOB`).
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class BlobType extends AbstractDataType {
|
|
8
|
+
/**
|
|
9
|
+
* @param _size - MySQL size; accepted for compatibility and ignored.
|
|
10
|
+
*/
|
|
11
|
+
constructor(_size?: 'tiny' | 'medium' | 'long');
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* `CHAR(length)` (`DataTypes.CHAR`).
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class CharType extends AbstractDataType {
|
|
8
|
+
/**
|
|
9
|
+
* @param length - Fixed length; default 255.
|
|
10
|
+
*/
|
|
11
|
+
constructor(length?: number);
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Converts single composite fields between JavaScript values and field text.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class CompositeFields {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* Converts field text read from a record into the field's value.
|
|
11
|
+
*
|
|
12
|
+
* @param field - Field type.
|
|
13
|
+
* @param text - Field text, or `null` for NULL.
|
|
14
|
+
* @returns The value.
|
|
15
|
+
*/
|
|
16
|
+
fromText(field: DataType, text: string | null): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Converts a field value into field text.
|
|
19
|
+
*
|
|
20
|
+
* @param field - Field type.
|
|
21
|
+
* @param value - Value; `null` / `undefined` are NULL.
|
|
22
|
+
* @returns Field text, or `null` for NULL.
|
|
23
|
+
* @throws Error for array values (not supported inside composites).
|
|
24
|
+
*/
|
|
25
|
+
toText(field: DataType, value: unknown): string | null;
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AbstractDataType, DataType, DataTypeInput } from './abstract-data-type.ts';
|
|
2
|
+
/** Value of a composite column: an object keyed by field name. */
|
|
3
|
+
export type CompositeValue = Readonly<Record<string, unknown>>;
|
|
4
|
+
/**
|
|
5
|
+
* Composite type (`DataTypes.COMPOSITE('address', { street: DataTypes.TEXT, zip: DataTypes.INTEGER })`);
|
|
6
|
+
* values are objects keyed by field name.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class CompositeType extends AbstractDataType {
|
|
11
|
+
#private;
|
|
12
|
+
/** SQL type that `where` parameters are cast to. */
|
|
13
|
+
readonly bindCast: string;
|
|
14
|
+
/** Field types by name, in declaration order. */
|
|
15
|
+
readonly fields: Readonly<Record<string, DataType>>;
|
|
16
|
+
/** Converts driver record text into an object. */
|
|
17
|
+
readonly parse: (value: unknown) => unknown;
|
|
18
|
+
/** Converts an object into record text bound as one parameter. */
|
|
19
|
+
readonly serialize: (value: unknown) => unknown;
|
|
20
|
+
/**
|
|
21
|
+
* @param name - Name of the composite type (quoted as one identifier).
|
|
22
|
+
* @param fields - Field types by field name.
|
|
23
|
+
* @throws Error when there are no fields.
|
|
24
|
+
*/
|
|
25
|
+
constructor(name: string, fields: Readonly<Record<string, DataTypeInput>>);
|
|
26
|
+
/**
|
|
27
|
+
* SQL that creates the type; run it once with `sequelize.query()` before `sync()`.
|
|
28
|
+
*
|
|
29
|
+
* @returns `CREATE TYPE "name" AS ("field" TYPE, …)` with quoted names.
|
|
30
|
+
*/
|
|
31
|
+
createSql(): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { DataTypeInput } from './abstract-data-type.ts';
|
|
2
|
+
import { ArrayType } from './array-type.ts';
|
|
3
|
+
import { BitType } from './bit-type.ts';
|
|
4
|
+
import { BlobType } from './blob-type.ts';
|
|
5
|
+
import { CharType } from './char-type.ts';
|
|
6
|
+
import { CompositeType } from './composite-type.ts';
|
|
7
|
+
import { DateType } from './date-type.ts';
|
|
8
|
+
import { DecimalType } from './decimal-type.ts';
|
|
9
|
+
import { DefaultValueGenerator } from './default-value-generator.ts';
|
|
10
|
+
import { EnumType } from './enum-type.ts';
|
|
11
|
+
import { FloatType } from './float-type.ts';
|
|
12
|
+
import { GeometricType } from './geometric-type.ts';
|
|
13
|
+
import { HstoreType } from './hstore-type.ts';
|
|
14
|
+
import { IntegerType } from './integer-type.ts';
|
|
15
|
+
import { JsonType } from './json-type.ts';
|
|
16
|
+
import { MultirangeType } from './multirange-type.ts';
|
|
17
|
+
import { RangeType } from './range-type.ts';
|
|
18
|
+
import { ScalarType } from './scalar-type.ts';
|
|
19
|
+
import { SpatialType } from './spatial-type.ts';
|
|
20
|
+
import { StringType } from './string-type.ts';
|
|
21
|
+
import { TextType } from './text-type.ts';
|
|
22
|
+
import { TimestampType } from './timestamp-type.ts';
|
|
23
|
+
import { VirtualType } from './virtual-type.ts';
|
|
24
|
+
export type { DataType, DataTypeInput } from './abstract-data-type.ts';
|
|
25
|
+
export type { GeoCircle, GeoLine, GeoPath } from './geometric-type.ts';
|
|
26
|
+
export type { GeoPoint } from './geometric-text.ts';
|
|
27
|
+
export type { CompositeValue } from './composite-type.ts';
|
|
28
|
+
export type { HstoreValue } from './hstore-type.ts';
|
|
29
|
+
export type { IntegerDataType } from './integer-type.ts';
|
|
30
|
+
export type { RangeBound } from './range-type.ts';
|
|
31
|
+
export type { DefaultValueGenerator } from './default-value-generator.ts';
|
|
32
|
+
/**
|
|
33
|
+
* Column types, API-compatible with Sequelize v6 `DataTypes` for PostgreSQL.
|
|
34
|
+
*
|
|
35
|
+
* `BIGINT` and `DECIMAL` values are returned as strings (like Sequelize v6) to avoid precision loss.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* User.init({ id: { type: DataTypes.BIGINT, primaryKey: true }, name: DataTypes.STRING(64) }, { sequelize });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const DataTypes: {
|
|
43
|
+
/** `VARCHAR(length)`, default length 255. */
|
|
44
|
+
readonly STRING: ((length?: number | undefined) => StringType) & StringType;
|
|
45
|
+
/** `CHAR(length)`, default length 255. */
|
|
46
|
+
readonly CHAR: ((length?: number | undefined) => CharType) & CharType;
|
|
47
|
+
/** `TEXT`. The size argument is accepted for compatibility and ignored. */
|
|
48
|
+
readonly TEXT: ((size?: "tiny" | "medium" | "long" | undefined) => TextType) & TextType;
|
|
49
|
+
/** `CITEXT` (case-insensitive text, requires the `citext` extension). */
|
|
50
|
+
readonly CITEXT: ScalarType;
|
|
51
|
+
/** `INTEGER`. */
|
|
52
|
+
readonly INTEGER: IntegerType;
|
|
53
|
+
/** `SMALLINT`. */
|
|
54
|
+
readonly SMALLINT: IntegerType;
|
|
55
|
+
/** Mapped to `SMALLINT` (PostgreSQL has no `TINYINT`). */
|
|
56
|
+
readonly TINYINT: IntegerType;
|
|
57
|
+
/** Mapped to `INTEGER` (PostgreSQL has no `MEDIUMINT`). */
|
|
58
|
+
readonly MEDIUMINT: IntegerType;
|
|
59
|
+
/** `BIGINT`; values are returned as strings. */
|
|
60
|
+
readonly BIGINT: IntegerType;
|
|
61
|
+
/** `FLOAT(precision)`. */
|
|
62
|
+
readonly FLOAT: ((digits?: number | undefined) => FloatType) & FloatType;
|
|
63
|
+
/** `REAL`. */
|
|
64
|
+
readonly REAL: ScalarType;
|
|
65
|
+
/** `DOUBLE PRECISION`. */
|
|
66
|
+
readonly DOUBLE: ScalarType;
|
|
67
|
+
/** `DECIMAL(precision, scale)`; values are returned as strings. */
|
|
68
|
+
readonly DECIMAL: ((digits?: number | undefined, scale?: number | undefined) => DecimalType) & DecimalType;
|
|
69
|
+
/** Alias of `DECIMAL`. */
|
|
70
|
+
readonly NUMBER: ((digits?: number | undefined, scale?: number | undefined) => DecimalType) & DecimalType;
|
|
71
|
+
/** Alias of `DECIMAL` (v6 `NUMERIC`). */
|
|
72
|
+
readonly NUMERIC: ((digits?: number | undefined, scale?: number | undefined) => DecimalType) & DecimalType;
|
|
73
|
+
/** `DOUBLE PRECISION` (v6 alias of `DOUBLE`). */
|
|
74
|
+
readonly 'DOUBLE PRECISION': ScalarType;
|
|
75
|
+
/** `BOOLEAN`. */
|
|
76
|
+
readonly BOOLEAN: ScalarType;
|
|
77
|
+
/** `TIMESTAMP WITH TIME ZONE`; values are `Date` objects. */
|
|
78
|
+
readonly DATE: ((fsp?: number | undefined) => DateType) & DateType;
|
|
79
|
+
/**
|
|
80
|
+
* `TIMESTAMP WITHOUT TIME ZONE`; values are `Date` objects whose local wall-clock time is the
|
|
81
|
+
* stored time. PostgreSQL extension.
|
|
82
|
+
*/
|
|
83
|
+
readonly TIMESTAMP: ((fsp?: number | undefined) => TimestampType) & TimestampType;
|
|
84
|
+
/** `DATE`; values are `'YYYY-MM-DD'` strings. */
|
|
85
|
+
readonly DATEONLY: ScalarType;
|
|
86
|
+
/** `TIME`. */
|
|
87
|
+
readonly TIME: ScalarType;
|
|
88
|
+
/** `INTERVAL`; values are PostgreSQL interval strings (e.g. `'1 day 02:00:00'`). PostgreSQL extension. */
|
|
89
|
+
readonly INTERVAL: ScalarType;
|
|
90
|
+
/** `JSON`. */
|
|
91
|
+
readonly JSON: JsonType;
|
|
92
|
+
/** `JSONB`. */
|
|
93
|
+
readonly JSONB: JsonType;
|
|
94
|
+
/** `BYTEA`; values are `Buffer`s. */
|
|
95
|
+
readonly BLOB: ((size?: "tiny" | "medium" | "long" | undefined) => BlobType) & BlobType;
|
|
96
|
+
/** `UUID`. */
|
|
97
|
+
readonly UUID: ScalarType;
|
|
98
|
+
/**
|
|
99
|
+
* `HSTORE` (requires the `hstore` extension); values are objects of string (or `null`) values,
|
|
100
|
+
* like Sequelize v6.
|
|
101
|
+
*/
|
|
102
|
+
readonly HSTORE: HstoreType;
|
|
103
|
+
/**
|
|
104
|
+
* `LTREE` label path (requires the `ltree` extension); values are strings like `'Top.Science'`.
|
|
105
|
+
* PostgreSQL extension.
|
|
106
|
+
*/
|
|
107
|
+
readonly LTREE: ScalarType;
|
|
108
|
+
/**
|
|
109
|
+
* `MONEY`; values are strings formatted by the server's `lc_monetary` (e.g. `'$12.50'`); numbers
|
|
110
|
+
* are accepted on write. PostgreSQL extension.
|
|
111
|
+
*/
|
|
112
|
+
readonly MONEY: ScalarType;
|
|
113
|
+
/** `XML`; values are XML text. PostgreSQL extension. */
|
|
114
|
+
readonly XML: ScalarType;
|
|
115
|
+
/** `BIT(length)`, default length 1; values are strings of `0` and `1`. PostgreSQL extension. */
|
|
116
|
+
readonly BIT: ((length?: number | undefined) => BitType) & BitType;
|
|
117
|
+
/**
|
|
118
|
+
* `BIT VARYING(length)`, unlimited without a length; values are strings of `0` and `1`.
|
|
119
|
+
* PostgreSQL extension.
|
|
120
|
+
*/
|
|
121
|
+
readonly VARBIT: ((length?: number | undefined) => BitType) & BitType;
|
|
122
|
+
/** `INET`. */
|
|
123
|
+
readonly INET: ScalarType;
|
|
124
|
+
/** `CIDR`. */
|
|
125
|
+
readonly CIDR: ScalarType;
|
|
126
|
+
/** `MACADDR`. */
|
|
127
|
+
readonly MACADDR: ScalarType;
|
|
128
|
+
/** `MACADDR8` (EUI-64 address). PostgreSQL extension. */
|
|
129
|
+
readonly MACADDR8: ScalarType;
|
|
130
|
+
/** `TSQUERY`; values are full-text query strings. PostgreSQL extension. */
|
|
131
|
+
readonly TSQUERY: ScalarType;
|
|
132
|
+
/** `TSVECTOR`. */
|
|
133
|
+
readonly TSVECTOR: ScalarType;
|
|
134
|
+
/** `POINT`; values are `{ x, y }`. PostgreSQL extension. */
|
|
135
|
+
readonly POINT: GeometricType;
|
|
136
|
+
/** `LINE` (`a·x + b·y + c = 0`); values are `{ a, b, c }`. PostgreSQL extension. */
|
|
137
|
+
readonly LINE: GeometricType;
|
|
138
|
+
/** `LSEG` line segment; values are `[start, end]` points. PostgreSQL extension. */
|
|
139
|
+
readonly LSEG: GeometricType;
|
|
140
|
+
/** `BOX`; values are `[corner, corner]` points (the server returns the upper right first). PostgreSQL extension. */
|
|
141
|
+
readonly BOX: GeometricType;
|
|
142
|
+
/** `PATH`; values are `{ points, closed }`. PostgreSQL extension. */
|
|
143
|
+
readonly PATH: GeometricType;
|
|
144
|
+
/** `POLYGON`; values are arrays of `{ x, y }` points. PostgreSQL extension. */
|
|
145
|
+
readonly POLYGON: GeometricType;
|
|
146
|
+
/** `CIRCLE`; values are `{ x, y, radius }`. PostgreSQL extension. */
|
|
147
|
+
readonly CIRCLE: GeometricType;
|
|
148
|
+
/** PostGIS `GEOMETRY(type, srid)`. */
|
|
149
|
+
readonly GEOMETRY: ((geometryType?: string | undefined, srid?: number | undefined) => SpatialType) & SpatialType;
|
|
150
|
+
/** PostGIS `GEOGRAPHY(type, srid)`. */
|
|
151
|
+
readonly GEOGRAPHY: ((geographyType?: string | undefined, srid?: number | undefined) => SpatialType) & SpatialType;
|
|
152
|
+
/** `type[]`, e.g. `DataTypes.ARRAY(DataTypes.TEXT)`. */
|
|
153
|
+
readonly ARRAY: (subtype: DataTypeInput) => ArrayType;
|
|
154
|
+
/** Range type, e.g. `DataTypes.RANGE(DataTypes.INTEGER)` → `INT4RANGE`. */
|
|
155
|
+
readonly RANGE: ((subtype?: DataTypeInput | undefined) => RangeType) & RangeType;
|
|
156
|
+
/**
|
|
157
|
+
* Multirange type (PostgreSQL 14+), e.g. `DataTypes.MULTIRANGE(DataTypes.INTEGER)` →
|
|
158
|
+
* `INT4MULTIRANGE`; values are arrays of `[lower, upper]` ranges. PostgreSQL extension.
|
|
159
|
+
*/
|
|
160
|
+
readonly MULTIRANGE: ((subtype?: DataTypeInput | undefined) => MultirangeType) & MultirangeType;
|
|
161
|
+
/**
|
|
162
|
+
* Composite type, e.g. `DataTypes.COMPOSITE('address', { street: DataTypes.TEXT, zip: DataTypes.INTEGER })`;
|
|
163
|
+
* values are objects keyed by field name. Create the type first with `createSql()`. PostgreSQL extension.
|
|
164
|
+
*/
|
|
165
|
+
readonly COMPOSITE: (name: string, fields: Readonly<Record<string, DataTypeInput>>) => CompositeType;
|
|
166
|
+
/** Enumerated values: `DataTypes.ENUM('a', 'b')` or `DataTypes.ENUM({ values: ['a', 'b'] })`. */
|
|
167
|
+
readonly ENUM: (...args: readonly (string | readonly string[] | Readonly<{
|
|
168
|
+
values: readonly string[];
|
|
169
|
+
}>)[]) => EnumType;
|
|
170
|
+
/** Attribute that is not stored in the database (computed by getters/setters). */
|
|
171
|
+
readonly VIRTUAL: ((returnType?: DataTypeInput | undefined, fields?: readonly string[] | undefined) => VirtualType) & VirtualType;
|
|
172
|
+
/** Default value: current timestamp. */
|
|
173
|
+
readonly NOW: DefaultValueGenerator;
|
|
174
|
+
/** Default value: random UUID v4 generated on the client. */
|
|
175
|
+
readonly UUIDV4: DefaultValueGenerator;
|
|
176
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* `TIMESTAMP WITH TIME ZONE` (`DataTypes.DATE`); values are `Date` objects.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class DateType extends AbstractDataType {
|
|
8
|
+
/** Converts a driver string into a `Date`. */
|
|
9
|
+
readonly parse: (value: unknown) => unknown;
|
|
10
|
+
/**
|
|
11
|
+
* @param fsp - Fractional seconds precision.
|
|
12
|
+
*/
|
|
13
|
+
constructor(fsp?: number);
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* `DECIMAL(precision, scale)` (`DataTypes.DECIMAL`, `DataTypes.NUMBER`); values are strings.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class DecimalType extends AbstractDataType {
|
|
8
|
+
/**
|
|
9
|
+
* @param digits - Precision.
|
|
10
|
+
* @param scale - Scale.
|
|
11
|
+
*/
|
|
12
|
+
constructor(digits?: number, scale?: number);
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default value marker (`DataTypes.NOW`, `DataTypes.UUIDV4`): generates a value on the client when a
|
|
3
|
+
* row is built.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DefaultValueGenerator {
|
|
6
|
+
/** Sequelize v6 type key, e.g. `'UUIDV4'`. */
|
|
7
|
+
readonly key: string;
|
|
8
|
+
/** Produces the default value. */
|
|
9
|
+
readonly generate: () => unknown;
|
|
10
|
+
/**
|
|
11
|
+
* @param key - Sequelize v6 type key.
|
|
12
|
+
* @param generate - Produces the default value.
|
|
13
|
+
*/
|
|
14
|
+
constructor(key: string, generate: () => unknown);
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/** Arguments of `DataTypes.ENUM`: values, arrays of values or `{ values }`. */
|
|
3
|
+
type EnumArgument = string | readonly string[] | Readonly<{
|
|
4
|
+
values: readonly string[];
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Enumerated values (`DataTypes.ENUM`).
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class EnumType extends AbstractDataType {
|
|
12
|
+
/** Allowed values. */
|
|
13
|
+
readonly values: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* @param args - Values, arrays of values or `{ values }`, in any combination.
|
|
16
|
+
*/
|
|
17
|
+
constructor(...args: readonly EnumArgument[]);
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** GeoJSON geometry as produced by the EWKB reader. */
|
|
2
|
+
export type GeoJsonGeometry = Readonly<Record<string, unknown>>;
|
|
3
|
+
/**
|
|
4
|
+
* Reads hex-encoded EWKB (what PostGIS sends for `geometry` and `geography`) into GeoJSON.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class EwkbReader {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Parses hex EWKB.
|
|
12
|
+
*
|
|
13
|
+
* @param hex - Hex string of an EWKB geometry.
|
|
14
|
+
* @returns GeoJSON geometry; `crs` is set (`EPSG:<srid>`) when the EWKB carries an SRID, like v6.
|
|
15
|
+
* @throws Error for a geometry type this reader does not support (curves, TIN, …).
|
|
16
|
+
*/
|
|
17
|
+
parse(hex: string): GeoJsonGeometry;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes GeoJSON as hex-encoded EWKB, which `geometry` and `geography` accept as text input, so a
|
|
3
|
+
* value is one bound parameter.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class EwkbWriter {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a GeoJSON geometry to hex EWKB.
|
|
11
|
+
*
|
|
12
|
+
* @param value - GeoJSON geometry object; `crs` (`EPSG:<srid>`) sets the SRID, default 4326.
|
|
13
|
+
* @returns Hex EWKB.
|
|
14
|
+
* @throws Error for an unknown geometry type or malformed coordinates.
|
|
15
|
+
*/
|
|
16
|
+
write(value: unknown): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* `FLOAT(precision)` (`DataTypes.FLOAT`).
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class FloatType extends AbstractDataType {
|
|
8
|
+
/**
|
|
9
|
+
* @param digits - Precision.
|
|
10
|
+
*/
|
|
11
|
+
constructor(digits?: number);
|
|
12
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** A `point` value. */
|
|
2
|
+
export type GeoPoint = Readonly<{
|
|
3
|
+
/** Horizontal coordinate. */
|
|
4
|
+
x: number;
|
|
5
|
+
/** Vertical coordinate. */
|
|
6
|
+
y: number;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Reads and writes the text form of geometric values.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare class GeometricText {
|
|
14
|
+
#private;
|
|
15
|
+
/**
|
|
16
|
+
* Extracts the numbers of a geometric literal, e.g. `((1,2),(3,4))` → `[1, 2, 3, 4]`.
|
|
17
|
+
*
|
|
18
|
+
* @param text - Literal returned by PostgreSQL.
|
|
19
|
+
* @returns Numbers in order of appearance.
|
|
20
|
+
*/
|
|
21
|
+
numbers(text: string): number[];
|
|
22
|
+
/**
|
|
23
|
+
* Groups numbers into points.
|
|
24
|
+
*
|
|
25
|
+
* @param values - Flat coordinates.
|
|
26
|
+
* @returns One point per pair.
|
|
27
|
+
*/
|
|
28
|
+
points(values: readonly number[]): GeoPoint[];
|
|
29
|
+
/**
|
|
30
|
+
* Validates a coordinate before it is formatted.
|
|
31
|
+
*
|
|
32
|
+
* @param value - Coordinate.
|
|
33
|
+
* @returns The value as text.
|
|
34
|
+
* @throws Error when the value is not a finite number.
|
|
35
|
+
*/
|
|
36
|
+
number(value: unknown): string;
|
|
37
|
+
/**
|
|
38
|
+
* Formats a point as `(x,y)`.
|
|
39
|
+
*
|
|
40
|
+
* @param value - Point-like value.
|
|
41
|
+
* @returns Point text.
|
|
42
|
+
*/
|
|
43
|
+
point(value: unknown): string;
|
|
44
|
+
/**
|
|
45
|
+
* Formats a list of points as `(x,y),(x,y)`.
|
|
46
|
+
*
|
|
47
|
+
* @param value - Array of points.
|
|
48
|
+
* @returns Comma-joined point text.
|
|
49
|
+
*/
|
|
50
|
+
list(value: unknown): string;
|
|
51
|
+
/**
|
|
52
|
+
* Formats a pair of points (`lseg`, `box`).
|
|
53
|
+
*
|
|
54
|
+
* @param value - Array of exactly two points.
|
|
55
|
+
* @returns Comma-joined point text.
|
|
56
|
+
*/
|
|
57
|
+
pair(value: unknown): string;
|
|
58
|
+
/**
|
|
59
|
+
* Narrows a value to an object for field access.
|
|
60
|
+
*
|
|
61
|
+
* @param value - Value to check.
|
|
62
|
+
* @returns The value as a record.
|
|
63
|
+
*/
|
|
64
|
+
fields(value: unknown): Record<string, unknown>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
import { GeoPoint } from './geometric-text.ts';
|
|
3
|
+
/** Keys of the geometric data types. */
|
|
4
|
+
export type GeometricKey = 'POINT' | 'LINE' | 'LSEG' | 'BOX' | 'PATH' | 'POLYGON' | 'CIRCLE';
|
|
5
|
+
/** `path` value: `closed` paths are written `( … )`, open ones `[ … ]`. */
|
|
6
|
+
export type GeoPath = Readonly<{
|
|
7
|
+
/** Vertices in order. */
|
|
8
|
+
points: readonly GeoPoint[];
|
|
9
|
+
/** True for a closed path. */
|
|
10
|
+
closed: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
/** `line` value: the line `a·x + b·y + c = 0`. */
|
|
13
|
+
export type GeoLine = Readonly<{
|
|
14
|
+
/** Coefficient of `x`. */
|
|
15
|
+
a: number;
|
|
16
|
+
/** Coefficient of `y`. */
|
|
17
|
+
b: number;
|
|
18
|
+
/** Constant term. */
|
|
19
|
+
c: number;
|
|
20
|
+
}>;
|
|
21
|
+
/** `circle` value: center and radius. */
|
|
22
|
+
export type GeoCircle = Readonly<{
|
|
23
|
+
/** Center x. */
|
|
24
|
+
x: number;
|
|
25
|
+
/** Center y. */
|
|
26
|
+
y: number;
|
|
27
|
+
/** Radius. */
|
|
28
|
+
radius: number;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Geometric types (`DataTypes.POINT`, `LINE`, `LSEG`, `BOX`, `PATH`, `POLYGON`, `CIRCLE`); values
|
|
32
|
+
* are plain objects and arrays of points.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare class GeometricType extends AbstractDataType {
|
|
37
|
+
#private;
|
|
38
|
+
/** Converts a driver literal into the value shape; non-text values are kept. */
|
|
39
|
+
readonly parse: (value: unknown) => unknown;
|
|
40
|
+
/** Converts a value into a literal bound as one parameter; text and `null` are kept. */
|
|
41
|
+
readonly serialize: (value: unknown) => unknown;
|
|
42
|
+
/**
|
|
43
|
+
* @param key - Geometric type key; also the SQL type name.
|
|
44
|
+
*/
|
|
45
|
+
constructor(key: GeometricKey);
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/** Key/value pairs of an `HSTORE` column: values are strings, or `null` for SQL `NULL`. */
|
|
3
|
+
export type HstoreValue = Readonly<Record<string, string | null>>;
|
|
4
|
+
/**
|
|
5
|
+
* `HSTORE` (`DataTypes.HSTORE`); values are plain objects, like Sequelize v6 with `pg-hstore`.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class HstoreType extends AbstractDataType {
|
|
10
|
+
#private;
|
|
11
|
+
/** Converts hstore text into an object; values are strings or `null`. */
|
|
12
|
+
readonly parse: (value: unknown) => unknown;
|
|
13
|
+
/** Converts an object into hstore text; non-object values (e.g. hstore text) are kept. */
|
|
14
|
+
readonly serialize: (value: unknown) => unknown;
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractDataType, DataType } from './abstract-data-type.ts';
|
|
2
|
+
/** Integer type with Sequelize v6 MySQL-only modifiers kept as no-ops for compatibility. */
|
|
3
|
+
export type IntegerDataType = DataType & Readonly<{
|
|
4
|
+
/** No-op in PostgreSQL, kept for Sequelize v6 compatibility. */
|
|
5
|
+
UNSIGNED: IntegerDataType;
|
|
6
|
+
/** No-op in PostgreSQL, kept for Sequelize v6 compatibility. */
|
|
7
|
+
ZEROFILL: IntegerDataType;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Integer types (`INTEGER`, `BIGINT`, `SMALLINT`, ...).
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare class IntegerType extends AbstractDataType implements IntegerDataType {
|
|
15
|
+
/**
|
|
16
|
+
* @param key - Sequelize v6 type key.
|
|
17
|
+
* @param sqlType - PostgreSQL column type.
|
|
18
|
+
*/
|
|
19
|
+
constructor(key: string, sqlType: string);
|
|
20
|
+
/** No-op in PostgreSQL, kept for Sequelize v6 compatibility. */
|
|
21
|
+
get UNSIGNED(): this;
|
|
22
|
+
/** No-op in PostgreSQL, kept for Sequelize v6 compatibility. */
|
|
23
|
+
get ZEROFILL(): this;
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* `JSON` / `JSONB`; values are serialized to JSON text.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class JsonType extends AbstractDataType {
|
|
8
|
+
/** Enables nested JSON where conditions. */
|
|
9
|
+
readonly isJson = true;
|
|
10
|
+
/** Converts a value into JSON text (`null` / `undefined` are kept). */
|
|
11
|
+
readonly serialize: (value: unknown) => unknown;
|
|
12
|
+
/**
|
|
13
|
+
* @param key - `'JSON'` or `'JSONB'` (also the SQL type).
|
|
14
|
+
*/
|
|
15
|
+
constructor(key: 'JSON' | 'JSONB');
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AbstractDataType, DataTypeInput } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Multirange type (`DataTypes.MULTIRANGE(DataTypes.INTEGER)` → `INT4MULTIRANGE`, PostgreSQL 14+);
|
|
4
|
+
* values are arrays of ranges, each a `[lower, upper]` pair like {@link RangeType} values.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class MultirangeType extends AbstractDataType {
|
|
9
|
+
#private;
|
|
10
|
+
/** Converts a driver multirange literal into an array of ranges (`[]` for `{}`). */
|
|
11
|
+
readonly parse: (value: unknown) => unknown;
|
|
12
|
+
/** Converts an array of ranges into a multirange literal. */
|
|
13
|
+
readonly serialize: (value: unknown) => unknown;
|
|
14
|
+
/**
|
|
15
|
+
* @param subtype - Element type: `INTEGER`, `BIGINT`, `DECIMAL`, `TIMESTAMP`, `DATE` or `DATEONLY`.
|
|
16
|
+
* @throws Error for any other element type.
|
|
17
|
+
*/
|
|
18
|
+
constructor(subtype: DataTypeInput);
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AbstractDataType, DataType, DataTypeInput } from './abstract-data-type.ts';
|
|
2
|
+
/** Range bound as returned by Sequelize v6 for `RANGE` attributes. */
|
|
3
|
+
export type RangeBound<T> = Readonly<{
|
|
4
|
+
/** Bound value; `null` for an unbounded side. */
|
|
5
|
+
value: T | null;
|
|
6
|
+
/** Whether the bound itself is part of the range. */
|
|
7
|
+
inclusive: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Range type (`DataTypes.RANGE(DataTypes.INTEGER)` → `INT4RANGE`); values are
|
|
11
|
+
* `[lower, upper]` pairs of {@link RangeBound}s, like Sequelize v6.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare class RangeType extends AbstractDataType {
|
|
16
|
+
#private;
|
|
17
|
+
/** Element type. */
|
|
18
|
+
readonly subtype: DataType;
|
|
19
|
+
/** Converts a driver range literal into a pair of bounds (`[]` for `empty`). */
|
|
20
|
+
readonly parse: (value: unknown) => unknown;
|
|
21
|
+
/** Converts a pair of values or bounds into a range literal. */
|
|
22
|
+
readonly serialize: (value: unknown) => unknown;
|
|
23
|
+
/**
|
|
24
|
+
* @param subtype - Element type: `INTEGER`, `BIGINT`, `DECIMAL`, `TIMESTAMP`, `DATE` or `DATEONLY`.
|
|
25
|
+
* @throws Error for any other element type.
|
|
26
|
+
*/
|
|
27
|
+
constructor(subtype: DataTypeInput);
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads and writes the text form of a composite value, `(1,"a b",)`.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class RecordText {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Splits record text into field texts.
|
|
10
|
+
*
|
|
11
|
+
* @param text - Record text, e.g. `(1,"say ""hi""",)`.
|
|
12
|
+
* @returns One entry per field; `null` for an empty (NULL) field.
|
|
13
|
+
*/
|
|
14
|
+
parse(text: string): (string | null)[];
|
|
15
|
+
/**
|
|
16
|
+
* Writes field texts as record text.
|
|
17
|
+
*
|
|
18
|
+
* @param fields - Field texts; `null` is written as an empty field.
|
|
19
|
+
* @returns Record text.
|
|
20
|
+
*/
|
|
21
|
+
format(fields: readonly (string | null)[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Quotes one field when it needs it.
|
|
24
|
+
*
|
|
25
|
+
* @param field - Field text or `null`.
|
|
26
|
+
* @returns Field text for use inside a record or array literal.
|
|
27
|
+
*/
|
|
28
|
+
quote(field: string | null): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractDataType } from './abstract-data-type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Type without parameters or value conversions (`BOOLEAN`, `UUID`, `INET`, ...).
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class ScalarType extends AbstractDataType {
|
|
8
|
+
/**
|
|
9
|
+
* @param key - Sequelize v6 type key.
|
|
10
|
+
* @param sqlType - PostgreSQL column type.
|
|
11
|
+
*/
|
|
12
|
+
constructor(key: string, sqlType: string);
|
|
13
|
+
}
|