ts-prorm-orm 1.1.0 → 1.2.1
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 +95 -0
- package/README.md +194 -72
- package/dist/audit/history-query.d.ts +35 -0
- package/dist/audit/index.d.ts +16 -0
- package/dist/audit/logger.d.ts +126 -0
- package/dist/cache/cache-manager.d.ts +341 -0
- package/dist/cache/index.d.ts +8 -0
- package/dist/cache/redis-cluster-cache.d.ts +164 -0
- package/dist/cache/redis-cluster-cache.js +19 -36
- package/dist/cli/cloud.d.ts +55 -0
- package/dist/cli/cloud.js +318 -0
- package/dist/cli/commands/auth.d.ts +2 -0
- package/dist/cli/commands/auth.js +345 -0
- package/dist/cli/commands/billing.d.ts +2 -0
- package/dist/cli/commands/billing.js +135 -0
- package/dist/cli/commands/code.d.ts +2 -0
- package/dist/cli/commands/code.js +168 -0
- package/dist/cli/commands/config.d.ts +2 -0
- package/dist/cli/commands/config.js +154 -0
- package/dist/cli/commands/db.d.ts +2 -0
- package/dist/cli/commands/db.js +189 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +22 -0
- package/dist/cli/commands/keys.d.ts +2 -0
- package/dist/cli/commands/keys.js +100 -0
- package/dist/cli/commands/misc.d.ts +2 -0
- package/dist/cli/commands/misc.js +282 -0
- package/dist/cli/commands/pull.d.ts +2 -0
- package/dist/cli/commands/pull.js +306 -0
- package/dist/cli/commands/runners.d.ts +2 -0
- package/dist/cli/commands/runners.js +218 -0
- package/dist/cli/commands/scaffold.d.ts +2 -0
- package/dist/cli/commands/scaffold.js +383 -0
- package/dist/cli/commands/secrets.d.ts +2 -0
- package/dist/cli/commands/secrets.js +162 -0
- package/dist/cli/commands/store.d.ts +2 -0
- package/dist/cli/commands/store.js +274 -0
- package/dist/cli/commands/system.d.ts +10 -0
- package/dist/cli/commands/system.js +169 -0
- package/dist/cli/commands/teams.d.ts +2 -0
- package/dist/cli/commands/teams.js +189 -0
- package/dist/cli/commands/user.d.ts +2 -0
- package/dist/cli/commands/user.js +171 -0
- package/dist/cli/framework.d.ts +103 -0
- package/dist/cli/framework.js +436 -0
- package/dist/cli/io.d.ts +26 -0
- package/dist/cli/io.js +181 -0
- package/dist/cli/keychain.d.ts +10 -0
- package/dist/cli/keychain.js +101 -0
- package/dist/cli/prompt.d.ts +20 -0
- package/dist/cli/prompt.js +111 -0
- package/dist/cli.d.ts +214 -0
- package/dist/cli.js +72 -5
- package/dist/compliance/audit-trail.d.ts +66 -0
- package/dist/compliance/backup-verification.d.ts +279 -0
- package/dist/compliance/breach-detector.d.ts +197 -0
- package/dist/compliance/consent-record.d.ts +107 -0
- package/dist/compliance/consent-versioning.d.ts +169 -0
- package/dist/compliance/cross-border-log.d.ts +254 -0
- package/dist/compliance/data-classifier.d.ts +127 -0
- package/dist/compliance/data-lineage.d.ts +268 -0
- package/dist/compliance/data-masker.d.ts +110 -0
- package/dist/compliance/data-portability.d.ts +98 -0
- package/dist/compliance/data-retention.d.ts +108 -0
- package/dist/compliance/dsar-workflow.d.ts +175 -0
- package/dist/compliance/field-encryption.d.ts +84 -0
- package/dist/compliance/immutable-record.d.ts +84 -0
- package/dist/compliance/index.d.ts +93 -0
- package/dist/compliance/privacy-impact-assessment.d.ts +196 -0
- package/dist/compliance/pseudonymization.d.ts +96 -0
- package/dist/compliance/query-firewall.d.ts +661 -0
- package/dist/compliance/rate-limiter.d.ts +203 -0
- package/dist/compliance/right-to-erasure.d.ts +96 -0
- package/dist/compliance/row-level-security.d.ts +152 -0
- package/dist/compliance/security-decorator.d.ts +388 -0
- package/dist/compliance/security-monitor.d.ts +170 -0
- package/dist/compliance/sensitive-data-discovery.d.ts +151 -0
- package/dist/compliance/session-isolation.d.ts +286 -0
- package/dist/compliance/tls-enforcer.d.ts +51 -0
- package/dist/compliance/worm-storage.d.ts +225 -0
- package/dist/connection-manager.d.ts +130 -0
- package/dist/connection-pool.d.ts +311 -0
- package/dist/decorators/audit.d.ts +49 -0
- package/dist/decorators/check.d.ts +218 -0
- package/dist/decorators/collate.d.ts +346 -0
- package/dist/decorators/comment.d.ts +51 -0
- package/dist/decorators/database-settings.d.ts +193 -0
- package/dist/decorators/default.d.ts +148 -0
- package/dist/decorators/encryption.d.ts +175 -0
- package/dist/decorators/engine.d.ts +97 -0
- package/dist/decorators/fk-constraints.d.ts +387 -0
- package/dist/decorators/foreign-table.d.ts +57 -0
- package/dist/decorators/generated.d.ts +232 -0
- package/dist/decorators/hstore.d.ts +96 -0
- package/dist/decorators/index.d.ts +57 -0
- package/dist/decorators/index.js +14 -30
- package/dist/decorators/json-column.d.ts +47 -0
- package/dist/decorators/jsonb.d.ts +83 -0
- package/dist/decorators/orm-decorators.d.ts +274 -0
- package/dist/decorators/permissions.d.ts +192 -0
- package/dist/decorators/procedure.d.ts +168 -0
- package/dist/decorators/procedure.js +31 -7
- package/dist/decorators/query-options.d.ts +527 -0
- package/dist/decorators/range.d.ts +122 -0
- package/dist/decorators/set-column.d.ts +43 -0
- package/dist/decorators/spatial.d.ts +60 -0
- package/dist/decorators/storage.d.ts +561 -0
- package/dist/decorators/timezone.d.ts +319 -0
- package/dist/decorators/trigger.d.ts +50 -0
- package/dist/decorators/uuid.d.ts +102 -0
- package/dist/decorators/view.d.ts +213 -0
- package/dist/diagrams/chen-diagram.d.ts +70 -0
- package/dist/diagrams/chen-diagram.js +33 -31
- package/dist/diagrams/class-diagram.d.ts +78 -0
- package/dist/diagrams/class-diagram.js +23 -27
- package/dist/diagrams/dependency-diagram.d.ts +82 -0
- package/dist/diagrams/dependency-diagram.js +18 -9
- package/dist/diagrams/er-diagram.d.ts +82 -0
- package/dist/diagrams/er-diagram.js +174 -231
- package/dist/diagrams/flow-diagram.d.ts +70 -0
- package/dist/diagrams/flow-diagram.js +23 -18
- package/dist/diagrams/gantt-diagram.d.ts +67 -0
- package/dist/diagrams/gantt-diagram.js +20 -18
- package/dist/diagrams/index-diagram.d.ts +61 -0
- package/dist/diagrams/index-diagram.js +36 -31
- package/dist/diagrams/index.d.ts +155 -0
- package/dist/diagrams/index.js +7 -1
- package/dist/diagrams/migration-diagram.d.ts +67 -0
- package/dist/diagrams/migration-diagram.js +45 -57
- package/dist/diagrams/model-diagram.d.ts +85 -0
- package/dist/diagrams/model-diagram.js +225 -287
- package/dist/diagrams/package-diagram.d.ts +69 -0
- package/dist/diagrams/package-diagram.js +30 -32
- package/dist/diagrams/palette.d.ts +138 -0
- package/dist/diagrams/palette.js +134 -25
- package/dist/diagrams/relational-diagram.d.ts +82 -0
- package/dist/diagrams/relational-diagram.js +51 -59
- package/dist/diagrams/schemadoc-diagram.d.ts +57 -0
- package/dist/diagrams/schemadoc-diagram.js +36 -28
- package/dist/diagrams/sequence-diagram.d.ts +61 -0
- package/dist/diagrams/sequence-diagram.js +20 -11
- package/dist/diagrams/state-diagram.d.ts +85 -0
- package/dist/diagrams/state-diagram.js +21 -17
- package/dist/diagrams/svg-dom.d.ts +62 -0
- package/dist/diagrams/svg-dom.js +11 -0
- package/dist/diagrams/tree-diagram.d.ts +47 -0
- package/dist/diagrams/tree-diagram.js +19 -10
- package/dist/dialects/clickhouse/index.d.ts +660 -0
- package/dist/dialects/clickhouse/index.js +107 -2
- package/dist/dialects/cockroachdb/index.d.ts +1708 -0
- package/dist/dialects/cockroachdb/index.js +139 -10
- package/dist/dialects/cratedb/index.d.ts +262 -0
- package/dist/dialects/cratedb/index.js +148 -0
- package/dist/dialects/databricks/index.d.ts +397 -0
- package/dist/dialects/databricks/index.js +233 -11
- package/dist/dialects/db2/index.d.ts +729 -0
- package/dist/dialects/db2/index.js +152 -2
- package/dist/dialects/dialect.d.ts +1653 -0
- package/dist/dialects/duckdb/index.d.ts +440 -0
- package/dist/dialects/duckdb/index.js +21 -37
- package/dist/dialects/exasol/index.d.ts +197 -0
- package/dist/dialects/exasol/index.js +14 -0
- package/dist/dialects/firebird/index.d.ts +286 -0
- package/dist/dialects/firebird/index.js +135 -0
- package/dist/dialects/greenplum/index.d.ts +336 -0
- package/dist/dialects/greenplum/index.js +168 -0
- package/dist/dialects/hana/index.d.ts +512 -0
- package/dist/dialects/hana/index.js +17 -35
- package/dist/dialects/mariadb/index.d.ts +1241 -0
- package/dist/dialects/mariadb/index.js +181 -43
- package/dist/dialects/mssql/index.d.ts +729 -0
- package/dist/dialects/mssql/index.js +76 -7
- package/dist/dialects/mysql/index.d.ts +1233 -0
- package/dist/dialects/mysql/index.js +87 -19
- package/dist/dialects/oracle/index.d.ts +1222 -0
- package/dist/dialects/oracle/index.js +210 -9
- package/dist/dialects/postgres/index.d.ts +1598 -0
- package/dist/dialects/postgres/index.js +34 -13
- package/dist/dialects/query-stream-helper.d.ts +58 -0
- package/dist/dialects/questdb/index.d.ts +430 -0
- package/dist/dialects/questdb/index.js +292 -0
- package/dist/dialects/redshift/index.d.ts +933 -0
- package/dist/dialects/redshift/index.js +17 -5
- package/dist/dialects/singlestore/index.d.ts +233 -0
- package/dist/dialects/singlestore/index.js +53 -0
- package/dist/dialects/snowflake/index.d.ts +727 -0
- package/dist/dialects/snowflake/index.js +154 -5
- package/dist/dialects/spanner/index.d.ts +660 -0
- package/dist/dialects/spanner/index.js +43 -21
- package/dist/dialects/sqlite/index.d.ts +1133 -0
- package/dist/dialects/sqlite/index.js +168 -30
- package/dist/dialects/tidb/index.d.ts +226 -0
- package/dist/dialects/tidb/index.js +10 -0
- package/dist/dialects/timescaledb/index.d.ts +286 -0
- package/dist/dialects/timescaledb/index.js +179 -0
- package/dist/dialects/trino/index.d.ts +230 -0
- package/dist/dialects/trino/index.js +85 -10
- package/dist/dialects/turso/index.d.ts +98 -0
- package/dist/dialects/turso/index.js +10 -0
- package/dist/dialects/vertica/index.d.ts +321 -0
- package/dist/dialects/vertica/index.js +161 -0
- package/dist/dialects/yugabytedb/index.d.ts +276 -0
- package/dist/dialects/yugabytedb/index.js +121 -0
- package/dist/errors/index.d.ts +378 -0
- package/dist/errors/index.js +29 -1
- package/dist/errors/utils.d.ts +53 -0
- package/dist/errors.d.ts +5 -0
- package/dist/extensions/catalog/cloud-warehouse-features.d.ts +27 -0
- package/dist/extensions/catalog/mssql-features.d.ts +20 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.d.ts +18 -0
- package/dist/extensions/catalog/oracle-db2-features.d.ts +17 -0
- package/dist/extensions/catalog/postgres-extensions.d.ts +15 -0
- package/dist/extensions/index.d.ts +34 -0
- package/dist/extensions/types.d.ts +43 -0
- package/dist/external-fields/adapters.d.ts +50 -0
- package/dist/external-fields/adapters.js +227 -0
- package/dist/external-fields/decorator.d.ts +77 -0
- package/dist/external-fields/decorator.js +80 -0
- package/dist/external-fields/index.d.ts +10 -0
- package/dist/external-fields/index.js +19 -0
- package/dist/external-fields/runtime.d.ts +39 -0
- package/dist/external-fields/runtime.js +221 -0
- package/dist/foreign-data.d.ts +168 -0
- package/dist/graph/base-graph-dialect.d.ts +250 -0
- package/dist/graph/base-graph-dialect.js +539 -0
- package/dist/graph/dgraph/index.d.ts +65 -0
- package/dist/graph/dgraph/index.js +559 -0
- package/dist/graph/gremlin/index.d.ts +59 -0
- package/dist/graph/gremlin/index.js +378 -0
- package/dist/graph/index.d.ts +60 -0
- package/dist/graph/index.js +67 -0
- package/dist/graph/neo4j/index.d.ts +50 -0
- package/dist/graph/neo4j/index.js +462 -0
- package/dist/graph/types.d.ts +213 -0
- package/dist/graph/types.js +234 -0
- package/dist/hooks/hooks-manager.d.ts +189 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/index.d.ts +713 -0
- package/dist/index.js +36 -4
- package/dist/logging.d.ts +183 -0
- package/dist/migrations/index.d.ts +9 -0
- package/dist/migrations/migration.d.ts +143 -0
- package/dist/migrations/migrator.d.ts +199 -0
- package/dist/migrations/prormmigration.d.ts +131 -0
- package/dist/migrations/query-interface.d.ts +335 -0
- package/dist/migrations/seeder.d.ts +167 -0
- package/dist/models/associations.d.ts +131 -0
- package/dist/models/associations.js +7 -2
- package/dist/models/constraints.d.ts +175 -0
- package/dist/models/data-types.d.ts +1656 -0
- package/dist/models/decorators.d.ts +328 -0
- package/dist/models/decorators.js +61 -82
- package/dist/models/eager-load.d.ts +86 -0
- package/dist/models/eager-load.js +369 -0
- package/dist/models/index.d.ts +13 -0
- package/dist/models/indexes.d.ts +325 -0
- package/dist/models/methods.d.ts +419 -0
- package/dist/models/model-manager.d.ts +76 -0
- package/dist/models/model.d.ts +820 -0
- package/dist/models/model.js +15 -101
- package/dist/models/operators.d.ts +29 -0
- package/dist/models/scopes.d.ts +71 -0
- package/dist/models/typescript-types.d.ts +177 -0
- package/dist/nosql/aerospike/index.d.ts +126 -0
- package/dist/nosql/allegrograph/index.d.ts +86 -0
- package/dist/nosql/arangodb/index.d.ts +285 -0
- package/dist/nosql/arangodb/index.js +274 -2
- package/dist/nosql/arangodb/where.d.ts +38 -0
- package/dist/nosql/arangodb/where.js +94 -0
- package/dist/nosql/azure-blob/index.d.ts +104 -0
- package/dist/nosql/beanstalkd/index.d.ts +88 -0
- package/dist/nosql/beequeue/index.d.ts +99 -0
- package/dist/nosql/bigchaindb/index.d.ts +113 -0
- package/dist/nosql/bigtable/index.d.ts +144 -0
- package/dist/nosql/blazegraph/index.d.ts +88 -0
- package/dist/nosql/bullmq/index.d.ts +83 -0
- package/dist/nosql/cassandra/index.d.ts +119 -0
- package/dist/nosql/chroma/index.d.ts +151 -0
- package/dist/nosql/cloudflare-kv/index.d.ts +120 -0
- package/dist/nosql/coherence/index.d.ts +91 -0
- package/dist/nosql/cosmosdb/index.d.ts +78 -0
- package/dist/nosql/couchbase/index.d.ts +103 -0
- package/dist/nosql/dax/index.d.ts +118 -0
- package/dist/nosql/deno-kv/index.d.ts +109 -0
- package/dist/nosql/dgraph/index.d.ts +80 -0
- package/dist/nosql/doris/index.d.ts +88 -0
- package/dist/nosql/druid/index.d.ts +95 -0
- package/dist/nosql/dynamodb/index.d.ts +643 -0
- package/dist/nosql/dynamodb/index.js +423 -0
- package/dist/nosql/elasticsearch/index.d.ts +239 -0
- package/dist/nosql/etcd/index.d.ts +243 -0
- package/dist/nosql/eventhubs/index.d.ts +89 -0
- package/dist/nosql/eventstore/index.d.ts +102 -0
- package/dist/nosql/faunadb/index.d.ts +141 -0
- package/dist/nosql/faunadb/index.js +329 -0
- package/dist/nosql/firestore/index.d.ts +67 -0
- package/dist/nosql/fluree/index.d.ts +88 -0
- package/dist/nosql/fuseki/index.d.ts +94 -0
- package/dist/nosql/gcs/index.d.ts +62 -0
- package/dist/nosql/gearman/index.d.ts +77 -0
- package/dist/nosql/geode/index.d.ts +93 -0
- package/dist/nosql/graphdb/index.d.ts +86 -0
- package/dist/nosql/graylog/index.d.ts +118 -0
- package/dist/nosql/gridgain/index.d.ts +78 -0
- package/dist/nosql/hazelcast/index.d.ts +73 -0
- package/dist/nosql/hbase/index.d.ts +123 -0
- package/dist/nosql/ignite/index.d.ts +80 -0
- package/dist/nosql/immudb/index.d.ts +131 -0
- package/dist/nosql/index.d.ts +215 -0
- package/dist/nosql/infinispan/index.d.ts +95 -0
- package/dist/nosql/influxdb/flux-compiler.d.ts +23 -0
- package/dist/nosql/influxdb/flux-compiler.js +170 -0
- package/dist/nosql/influxdb/index.d.ts +300 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.d.ts +113 -0
- package/dist/nosql/keyspaces/index.d.ts +122 -0
- package/dist/nosql/kinesis/index.d.ts +121 -0
- package/dist/nosql/leveldb/index.d.ts +112 -0
- package/dist/nosql/leveldb/index.js +103 -1
- package/dist/nosql/lmdb/index.d.ts +76 -0
- package/dist/nosql/loki/index.d.ts +126 -0
- package/dist/nosql/marklogic/index.d.ts +76 -0
- package/dist/nosql/materialize/index.d.ts +91 -0
- package/dist/nosql/meilisearch/index.d.ts +76 -0
- package/dist/nosql/memcached/index.d.ts +138 -0
- package/dist/nosql/milvus/index.d.ts +167 -0
- package/dist/nosql/minio/index.d.ts +122 -0
- package/dist/nosql/momento/index.d.ts +99 -0
- package/dist/nosql/mongodb/index.d.ts +265 -0
- package/dist/nosql/mongodb/index.js +139 -0
- package/dist/nosql/mongodb/where.d.ts +8 -0
- package/dist/nosql/mongodb/where.js +181 -0
- package/dist/nosql/nats/index.d.ts +139 -0
- package/dist/nosql/nedb/index.d.ts +79 -0
- package/dist/nosql/neo4j/index.d.ts +217 -0
- package/dist/nosql/neo4j/index.js +26 -14
- package/dist/nosql/neptune/index.d.ts +234 -0
- package/dist/nosql/neptune/index.js +23 -9
- package/dist/nosql/nsq/index.d.ts +93 -0
- package/dist/nosql/opensearch/index.d.ts +97 -0
- package/dist/nosql/orientdb/index.d.ts +72 -0
- package/dist/nosql/papertrail/index.d.ts +120 -0
- package/dist/nosql/pinecone/index.d.ts +148 -0
- package/dist/nosql/pinot/index.d.ts +90 -0
- package/dist/nosql/pouchdb/index.d.ts +95 -0
- package/dist/nosql/prometheus/index.d.ts +112 -0
- package/dist/nosql/provendb/index.d.ts +143 -0
- package/dist/nosql/provendb/index.js +262 -0
- package/dist/nosql/pubsub/index.d.ts +83 -0
- package/dist/nosql/pulsar/index.d.ts +105 -0
- package/dist/nosql/qdrant/index.d.ts +231 -0
- package/dist/nosql/qldb/index.d.ts +182 -0
- package/dist/nosql/qldb/index.js +302 -1
- package/dist/nosql/r2/index.d.ts +160 -0
- package/dist/nosql/rabbitmq/index.d.ts +131 -0
- package/dist/nosql/ravendb/index.d.ts +138 -0
- package/dist/nosql/ravendb/index.js +323 -9
- package/dist/nosql/ravendb/where.d.ts +38 -0
- package/dist/nosql/ravendb/where.js +94 -0
- package/dist/nosql/redis/index.d.ts +267 -0
- package/dist/nosql/redis/index.js +19 -5
- package/dist/nosql/redpanda/index.d.ts +117 -0
- package/dist/nosql/resque/index.d.ts +91 -0
- package/dist/nosql/rethinkdb/index.d.ts +194 -0
- package/dist/nosql/rethinkdb/index.js +290 -0
- package/dist/nosql/rethinkdb/where.d.ts +38 -0
- package/dist/nosql/rethinkdb/where.js +94 -0
- package/dist/nosql/rocksdb/document-layer.d.ts +162 -0
- package/dist/nosql/rocksdb/document-layer.js +338 -0
- package/dist/nosql/rocksdb/index.d.ts +112 -0
- package/dist/nosql/rocksdb/index.js +103 -1
- package/dist/nosql/rocksdb/where-match.d.ts +21 -0
- package/dist/nosql/rocksdb/where-match.js +238 -0
- package/dist/nosql/rockset/index.d.ts +84 -0
- package/dist/nosql/s3/index.d.ts +170 -0
- package/dist/nosql/scylladb/index.d.ts +117 -0
- package/dist/nosql/signoz/index.d.ts +116 -0
- package/dist/nosql/sns/index.d.ts +99 -0
- package/dist/nosql/solr/index.d.ts +129 -0
- package/dist/nosql/splunk/index.d.ts +125 -0
- package/dist/nosql/sqs/index.d.ts +116 -0
- package/dist/nosql/stardog/index.d.ts +86 -0
- package/dist/nosql/starrocks/index.d.ts +89 -0
- package/dist/nosql/store.d.ts +23 -0
- package/dist/nosql/sumologic/index.d.ts +119 -0
- package/dist/nosql/surrealdb/index.d.ts +156 -0
- package/dist/nosql/surrealdb/index.js +174 -1
- package/dist/nosql/surrealdb/query-compiler.d.ts +26 -0
- package/dist/nosql/surrealdb/query-compiler.js +193 -0
- package/dist/nosql/terminusdb/index.d.ts +95 -0
- package/dist/nosql/tigergraph/index.d.ts +314 -0
- package/dist/nosql/typesense/index.d.ts +82 -0
- package/dist/nosql/unqlite/index.d.ts +68 -0
- package/dist/nosql/upstash/index.d.ts +80 -0
- package/dist/nosql/vercel-kv/index.d.ts +82 -0
- package/dist/nosql/victoriametrics/index.d.ts +129 -0
- package/dist/nosql/virtuoso/index.d.ts +87 -0
- package/dist/nosql/weaviate/index.d.ts +196 -0
- package/dist/operators/index.d.ts +7 -0
- package/dist/operators.d.ts +2947 -0
- package/dist/operators.js +46 -1
- package/dist/prisma-migrate/index.d.ts +28 -0
- package/dist/prisma-migrate/migration-generator.d.ts +21 -0
- package/dist/prisma-migrate/model-generator.d.ts +12 -0
- package/dist/prisma-migrate/relations.d.ts +28 -0
- package/dist/prisma-migrate/schema-parser.d.ts +42 -0
- package/dist/prisma-migrate/type-mapper.d.ts +20 -0
- package/dist/prorm.d.ts +2093 -0
- package/dist/prorm.js +721 -302
- package/dist/query-builders/cte-builder.d.ts +104 -0
- package/dist/query-builders/functions/aggregate.d.ts +199 -0
- package/dist/query-builders/functions/conditional.d.ts +195 -0
- package/dist/query-builders/functions/datetime.d.ts +202 -0
- package/dist/query-builders/functions/fulltext.d.ts +220 -0
- package/dist/query-builders/functions/index.d.ts +17 -0
- package/dist/query-builders/functions/json.d.ts +157 -0
- package/dist/query-builders/functions/math.d.ts +215 -0
- package/dist/query-builders/functions/string.d.ts +233 -0
- package/dist/query-builders/functions/window.d.ts +209 -0
- package/dist/query-builders/include-builder.d.ts +85 -0
- package/dist/query-builders/index-expression-builder.d.ts +153 -0
- package/dist/query-builders/index.d.ts +121 -0
- package/dist/query-builders/index.js +10 -0
- package/dist/query-builders/insert-builder.d.ts +62 -0
- package/dist/query-builders/model-helpers.d.ts +28 -0
- package/dist/query-builders/order-limit-builder.d.ts +84 -0
- package/dist/query-builders/sql-compiler.d.ts +562 -0
- package/dist/query-builders/subquery-builder.d.ts +133 -0
- package/dist/query-builders/update-builder.d.ts +71 -0
- package/dist/query-builders/view-builder.d.ts +189 -0
- package/dist/query-builders/where-builder.d.ts +124 -0
- package/dist/query-interface.d.ts +407 -0
- package/dist/query-interface.js +84 -0
- package/dist/query-optimizers/batch-optimizer.d.ts +175 -0
- package/dist/query-optimizers/explain-plans.d.ts +187 -0
- package/dist/query-optimizers/index.d.ts +27 -0
- package/dist/query-optimizers/prepared-statement-cache.d.ts +252 -0
- package/dist/query-optimizers/query-hints.d.ts +201 -0
- package/dist/query-optimizers/query-optimizer.d.ts +162 -0
- package/dist/query-optimizers/slow-query-logger.d.ts +186 -0
- package/dist/replica-manager.d.ts +235 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/migration-generator.d.ts +74 -0
- package/dist/schema/schema-differ.d.ts +114 -0
- package/dist/schema/types.d.ts +246 -0
- package/dist/schema-objects.d.ts +78 -0
- package/dist/schema-objects.js +203 -0
- package/dist/sql-constants.d.ts +240 -0
- package/dist/sqlite-advanced.d.ts +572 -0
- package/dist/streams/index.d.ts +5 -0
- package/dist/streams/transforms.d.ts +120 -0
- package/dist/transaction.d.ts +221 -0
- package/dist/types/index.d.ts +3123 -0
- package/dist/user-management.d.ts +141 -0
- package/dist/utils/date.d.ts +149 -0
- package/dist/utils/index.d.ts +359 -0
- package/dist/utils/string.d.ts +88 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/validator.d.ts +306 -0
- package/package.json +20 -5
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Optimizer - Main entry point that combines all optimization features
|
|
3
|
+
*/
|
|
4
|
+
import { Dialect } from '../dialects/dialect';
|
|
5
|
+
import { QueryHintManager, QueryHint } from './query-hints';
|
|
6
|
+
import { ExplainPlanGenerator, ExplainOptions } from './explain-plans';
|
|
7
|
+
import { SlowQueryLogger, SlowQueryOptions } from './slow-query-logger';
|
|
8
|
+
import { BatchQueryOptimizer, BatchOptions, BatchResult } from './batch-optimizer';
|
|
9
|
+
import { PreparedStatementCache, PreparedStatementCacheOptions, QueryResultCache } from './prepared-statement-cache';
|
|
10
|
+
/**
|
|
11
|
+
* Query optimization options
|
|
12
|
+
*/
|
|
13
|
+
export interface QueryOptimizationOptions {
|
|
14
|
+
/** Enable query hints */
|
|
15
|
+
enableHints?: boolean;
|
|
16
|
+
/** Enable explain plans */
|
|
17
|
+
enableExplain?: boolean;
|
|
18
|
+
/** Enable slow query logging */
|
|
19
|
+
enableSlowQueryLog?: boolean;
|
|
20
|
+
/** Enable prepared statement caching */
|
|
21
|
+
enablePreparedStatementCache?: boolean;
|
|
22
|
+
/** Enable query result caching */
|
|
23
|
+
enableQueryResultCache?: boolean;
|
|
24
|
+
/** Enable batch optimization */
|
|
25
|
+
enableBatchOptimization?: boolean;
|
|
26
|
+
/** Slow query logging options */
|
|
27
|
+
slowQueryOptions?: Partial<SlowQueryOptions>;
|
|
28
|
+
/** Prepared statement cache options */
|
|
29
|
+
preparedStatementCacheOptions?: Partial<PreparedStatementCacheOptions>;
|
|
30
|
+
/** Query result cache options */
|
|
31
|
+
queryResultCacheOptions?: {
|
|
32
|
+
maxSize?: number;
|
|
33
|
+
ttl?: number;
|
|
34
|
+
logging?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** Batch optimization options */
|
|
37
|
+
batchOptions?: Partial<BatchOptions>;
|
|
38
|
+
/** Default explain options */
|
|
39
|
+
explainOptions?: Partial<ExplainOptions>;
|
|
40
|
+
/** Logging function */
|
|
41
|
+
logging?: (message: string, level?: 'info' | 'warn' | 'error') => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Main query optimizer class that combines all optimization features
|
|
45
|
+
*/
|
|
46
|
+
export declare class QueryOptimizer {
|
|
47
|
+
private dialect;
|
|
48
|
+
private options;
|
|
49
|
+
private queryHintManager?;
|
|
50
|
+
private explainPlanGenerator?;
|
|
51
|
+
private slowQueryLogger?;
|
|
52
|
+
private preparedStatementCache?;
|
|
53
|
+
private queryResultCache?;
|
|
54
|
+
private batchOptimizer?;
|
|
55
|
+
constructor(dialect: Dialect, options?: QueryOptimizationOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Initialize all optimization components
|
|
58
|
+
*/
|
|
59
|
+
private initializeComponents;
|
|
60
|
+
/**
|
|
61
|
+
* Get the query hint manager
|
|
62
|
+
*/
|
|
63
|
+
getHintManager(): QueryHintManager | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Get the explain plan generator
|
|
66
|
+
*/
|
|
67
|
+
getExplainGenerator(): ExplainPlanGenerator | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Get the slow query logger
|
|
70
|
+
*/
|
|
71
|
+
getSlowQueryLogger(): SlowQueryLogger | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Get the prepared statement cache
|
|
74
|
+
*/
|
|
75
|
+
getPreparedStatementCache(): PreparedStatementCache | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Get the query result cache
|
|
78
|
+
*/
|
|
79
|
+
getQueryResultCache(): QueryResultCache | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Get the batch optimizer
|
|
82
|
+
*/
|
|
83
|
+
getBatchOptimizer(): BatchQueryOptimizer | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Apply query hints to a SQL statement
|
|
86
|
+
*/
|
|
87
|
+
applyHints(sql: string, hints: QueryHint[]): string;
|
|
88
|
+
/**
|
|
89
|
+
* Execute an optimized query with caching support
|
|
90
|
+
*/
|
|
91
|
+
executeQuery(sql: string, options?: {
|
|
92
|
+
params?: any[];
|
|
93
|
+
useCache?: boolean;
|
|
94
|
+
usePreparedStatement?: boolean;
|
|
95
|
+
hint?: QueryHint[];
|
|
96
|
+
skipSlowLog?: boolean;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
result: any;
|
|
99
|
+
fromCache: boolean;
|
|
100
|
+
duration: number;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Explain a query
|
|
104
|
+
*/
|
|
105
|
+
explainQuery(sql: string, options?: ExplainOptions): Promise<import("./explain-plans").ExplainPlan>;
|
|
106
|
+
/**
|
|
107
|
+
* Analyze a query for optimization opportunities
|
|
108
|
+
*/
|
|
109
|
+
analyzeQuery(sql: string, options?: ExplainOptions): Promise<{
|
|
110
|
+
plan: import("./explain-plans").ExplainPlan;
|
|
111
|
+
recommendations: import("./explain-plans").QueryRecommendation[];
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Perform batch insert with optimization
|
|
115
|
+
*/
|
|
116
|
+
batchInsert(tableName: string, records: Record<string, any>[], options?: Partial<BatchOptions>): Promise<BatchResult>;
|
|
117
|
+
/**
|
|
118
|
+
* Perform batch update with optimization
|
|
119
|
+
*/
|
|
120
|
+
batchUpdate(tableName: string, records: Record<string, any>[], identifierColumn?: string, options?: Partial<BatchOptions>): Promise<BatchResult>;
|
|
121
|
+
/**
|
|
122
|
+
* Perform batch delete with optimization
|
|
123
|
+
*/
|
|
124
|
+
batchDelete(tableName: string, identifiers: any[], identifierColumn?: string, options?: Partial<BatchOptions>): Promise<BatchResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Get optimization statistics
|
|
127
|
+
*/
|
|
128
|
+
getStats(): {
|
|
129
|
+
slowQuery: import("./slow-query-logger").QueryStatistics | undefined;
|
|
130
|
+
preparedStatementCache: import("./prepared-statement-cache").CacheStats | undefined;
|
|
131
|
+
queryResultCache: {
|
|
132
|
+
size: number;
|
|
133
|
+
maxSize: number;
|
|
134
|
+
hitCount: number;
|
|
135
|
+
} | undefined;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Clear all caches
|
|
139
|
+
*/
|
|
140
|
+
clearCaches(): void;
|
|
141
|
+
/**
|
|
142
|
+
* Prune expired cache entries
|
|
143
|
+
*/
|
|
144
|
+
pruneCaches(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Invalidate query result cache for a specific table
|
|
147
|
+
*/
|
|
148
|
+
invalidateTableCache(tableName: string): number;
|
|
149
|
+
/**
|
|
150
|
+
* Log a message
|
|
151
|
+
*/
|
|
152
|
+
private log;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create a query optimizer instance
|
|
156
|
+
*/
|
|
157
|
+
export declare function createQueryOptimizer(dialect: Dialect, options?: QueryOptimizationOptions): QueryOptimizer;
|
|
158
|
+
declare const _default: {
|
|
159
|
+
QueryOptimizer: typeof QueryOptimizer;
|
|
160
|
+
createQueryOptimizer: typeof createQueryOptimizer;
|
|
161
|
+
};
|
|
162
|
+
export default _default;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slow Query Logging
|
|
3
|
+
* Provides functionality to log and analyze slow database queries
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
/**
|
|
7
|
+
* Slow query log entry
|
|
8
|
+
*/
|
|
9
|
+
export interface SlowQueryLogEntry {
|
|
10
|
+
/** Unique identifier for the log entry */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The SQL query that was executed */
|
|
13
|
+
sql: string;
|
|
14
|
+
/** Query parameters (if any) */
|
|
15
|
+
params?: any[];
|
|
16
|
+
/** Duration of query execution in milliseconds */
|
|
17
|
+
duration: number;
|
|
18
|
+
/** Timestamp when query was executed */
|
|
19
|
+
timestamp: Date;
|
|
20
|
+
/** Database dialect used */
|
|
21
|
+
dialect: string;
|
|
22
|
+
/** Whether the query was from a transaction */
|
|
23
|
+
inTransaction: boolean;
|
|
24
|
+
/** Connection info (without sensitive data) */
|
|
25
|
+
connection?: {
|
|
26
|
+
database?: string;
|
|
27
|
+
host?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Error message if query failed */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** Query type (SELECT, INSERT, UPDATE, DELETE) */
|
|
32
|
+
queryType?: string;
|
|
33
|
+
/** Number of rows affected/returned */
|
|
34
|
+
rowCount?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options for slow query logging
|
|
38
|
+
*/
|
|
39
|
+
export interface SlowQueryOptions {
|
|
40
|
+
/** Threshold in milliseconds to consider a query as slow */
|
|
41
|
+
threshold: number;
|
|
42
|
+
/** Minimum number of slow queries to trigger an alert */
|
|
43
|
+
alertThreshold?: number;
|
|
44
|
+
/** Time window in milliseconds for alert calculation */
|
|
45
|
+
alertWindow?: number;
|
|
46
|
+
/** Log all queries, not just slow ones */
|
|
47
|
+
logAllQueries?: boolean;
|
|
48
|
+
/** Log query parameters */
|
|
49
|
+
logParams?: boolean;
|
|
50
|
+
/** Maximum number of log entries to keep in memory */
|
|
51
|
+
maxEntries?: number;
|
|
52
|
+
/** Callback for when a slow query is logged */
|
|
53
|
+
onSlowQuery?: (entry: SlowQueryLogEntry) => void;
|
|
54
|
+
/** Callback for when alert threshold is exceeded */
|
|
55
|
+
onAlert?: (entries: SlowQueryLogEntry[]) => void;
|
|
56
|
+
/** Include stack trace for queries */
|
|
57
|
+
includeStackTrace?: boolean;
|
|
58
|
+
/** Custom logger function */
|
|
59
|
+
logger?: (message: string, meta?: Record<string, any>) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Slow query logger
|
|
63
|
+
*/
|
|
64
|
+
export declare class SlowQueryLogger extends EventEmitter {
|
|
65
|
+
private threshold;
|
|
66
|
+
private logAllQueries;
|
|
67
|
+
private logParams;
|
|
68
|
+
private maxEntries;
|
|
69
|
+
private onSlowQuery?;
|
|
70
|
+
private onAlert?;
|
|
71
|
+
private includeStackTrace;
|
|
72
|
+
private logger?;
|
|
73
|
+
private logs;
|
|
74
|
+
private alertThreshold;
|
|
75
|
+
private alertWindow;
|
|
76
|
+
private queryTimestamps;
|
|
77
|
+
private static readonly DEFAULT_THRESHOLD;
|
|
78
|
+
constructor(options: SlowQueryOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Set the slow query threshold
|
|
81
|
+
*/
|
|
82
|
+
setThreshold(threshold: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get the current threshold
|
|
85
|
+
*/
|
|
86
|
+
getThreshold(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Enable logging of all queries (not just slow ones)
|
|
89
|
+
*/
|
|
90
|
+
setLogAllQueries(logAll: boolean): void;
|
|
91
|
+
/**
|
|
92
|
+
* Log a query execution
|
|
93
|
+
*/
|
|
94
|
+
logQuery(options: {
|
|
95
|
+
sql: string;
|
|
96
|
+
params?: any[];
|
|
97
|
+
duration: number;
|
|
98
|
+
dialect: string;
|
|
99
|
+
inTransaction?: boolean;
|
|
100
|
+
connection?: {
|
|
101
|
+
database?: string;
|
|
102
|
+
host?: string;
|
|
103
|
+
};
|
|
104
|
+
error?: string;
|
|
105
|
+
queryType?: string;
|
|
106
|
+
rowCount?: number;
|
|
107
|
+
}): SlowQueryLogEntry | null;
|
|
108
|
+
/**
|
|
109
|
+
* Add a log entry to the internal log storage
|
|
110
|
+
*/
|
|
111
|
+
private addLogEntry;
|
|
112
|
+
/**
|
|
113
|
+
* Log the entry using the configured logger
|
|
114
|
+
*/
|
|
115
|
+
private logEntry;
|
|
116
|
+
/**
|
|
117
|
+
* Check if alert threshold has been exceeded
|
|
118
|
+
*/
|
|
119
|
+
private checkAlertThreshold;
|
|
120
|
+
/**
|
|
121
|
+
* Get all log entries
|
|
122
|
+
*/
|
|
123
|
+
getLogs(): SlowQueryLogEntry[];
|
|
124
|
+
/**
|
|
125
|
+
* Get slow query entries only
|
|
126
|
+
*/
|
|
127
|
+
getSlowQueries(): SlowQueryLogEntry[];
|
|
128
|
+
/**
|
|
129
|
+
* Get query statistics
|
|
130
|
+
*/
|
|
131
|
+
getStatistics(): QueryStatistics;
|
|
132
|
+
/**
|
|
133
|
+
* Calculate percentile from sorted array
|
|
134
|
+
*/
|
|
135
|
+
private percentile;
|
|
136
|
+
/**
|
|
137
|
+
* Clear all log entries
|
|
138
|
+
*/
|
|
139
|
+
clear(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Generate a unique ID for log entries
|
|
142
|
+
*/
|
|
143
|
+
private generateId;
|
|
144
|
+
/**
|
|
145
|
+
* Export logs to a file-compatible format
|
|
146
|
+
*/
|
|
147
|
+
exportLogs(): string;
|
|
148
|
+
/**
|
|
149
|
+
* Get queries by type
|
|
150
|
+
*/
|
|
151
|
+
getQueriesByType(type: string): SlowQueryLogEntry[];
|
|
152
|
+
/**
|
|
153
|
+
* Get queries on a specific table
|
|
154
|
+
*/
|
|
155
|
+
getQueriesOnTable(tableName: string): SlowQueryLogEntry[];
|
|
156
|
+
/**
|
|
157
|
+
* Find similar queries (group by SQL pattern)
|
|
158
|
+
*/
|
|
159
|
+
findSimilarQueries(sql: string): SlowQueryLogEntry[];
|
|
160
|
+
/**
|
|
161
|
+
* Normalize SQL for comparison
|
|
162
|
+
*/
|
|
163
|
+
private normalizeSql;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Query statistics
|
|
167
|
+
*/
|
|
168
|
+
export interface QueryStatistics {
|
|
169
|
+
totalQueries: number;
|
|
170
|
+
slowQueries: number;
|
|
171
|
+
averageDuration: number;
|
|
172
|
+
maxDuration: number;
|
|
173
|
+
minDuration: number;
|
|
174
|
+
p50Duration: number;
|
|
175
|
+
p95Duration: number;
|
|
176
|
+
p99Duration: number;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create a slow query logger instance
|
|
180
|
+
*/
|
|
181
|
+
export declare function createSlowQueryLogger(options: SlowQueryOptions): SlowQueryLogger;
|
|
182
|
+
declare const _default: {
|
|
183
|
+
SlowQueryLogger: typeof SlowQueryLogger;
|
|
184
|
+
createSlowQueryLogger: typeof createSlowQueryLogger;
|
|
185
|
+
};
|
|
186
|
+
export default _default;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replica Manager for handling read replicas with lag detection
|
|
3
|
+
* Supports multiple database dialects with dialect-specific lag detection queries
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { QueryOptions } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Routing strategy for selecting a replica.
|
|
9
|
+
*
|
|
10
|
+
* Companion enum to the `RoutingStrategy` string-literal union below.
|
|
11
|
+
* Use either `ReplicaRoutingStrategy.RoundRobin` or the raw string
|
|
12
|
+
* `'round-robin'` (and so on) — both are accepted wherever a
|
|
13
|
+
* `RoutingStrategy` is expected.
|
|
14
|
+
*/
|
|
15
|
+
export declare enum ReplicaRoutingStrategy {
|
|
16
|
+
RoundRobin = "round-robin",
|
|
17
|
+
LeastConnections = "least-connections",
|
|
18
|
+
LowestLag = "lowest-lag"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Routing strategy for selecting a replica
|
|
22
|
+
*
|
|
23
|
+
* Accepts either the string-literal union values directly, or the
|
|
24
|
+
* equivalent `ReplicaRoutingStrategy` enum member. Widened to include
|
|
25
|
+
* the enum in a non-breaking way: existing string-literal usage
|
|
26
|
+
* continues to work unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export type RoutingStrategy = 'round-robin' | 'least-connections' | 'lowest-lag' | ReplicaRoutingStrategy;
|
|
29
|
+
/**
|
|
30
|
+
* Replica status
|
|
31
|
+
*/
|
|
32
|
+
export interface ReplicaStatus {
|
|
33
|
+
/** Replica name */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Whether the replica is healthy */
|
|
36
|
+
healthy: boolean;
|
|
37
|
+
/** Replication lag in milliseconds */
|
|
38
|
+
lag: number | null;
|
|
39
|
+
/** Number of active connections */
|
|
40
|
+
activeConnections: number;
|
|
41
|
+
/** Last check timestamp */
|
|
42
|
+
lastCheck: Date;
|
|
43
|
+
/** Error message if unhealthy */
|
|
44
|
+
error?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Configuration for connecting to a replica
|
|
48
|
+
*/
|
|
49
|
+
export interface ReplicaConnectionConfig {
|
|
50
|
+
/** Unique name for this replica */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Connection host */
|
|
53
|
+
host: string;
|
|
54
|
+
/** Connection port */
|
|
55
|
+
port: number;
|
|
56
|
+
/** Database name */
|
|
57
|
+
database: string;
|
|
58
|
+
/** Username */
|
|
59
|
+
username: string;
|
|
60
|
+
/** Password */
|
|
61
|
+
password: string;
|
|
62
|
+
/** Connection dialect (mysql, mariadb, postgres, mssql, sqlite, oracle) */
|
|
63
|
+
dialect: string;
|
|
64
|
+
/** Additional dialect-specific options */
|
|
65
|
+
dialectOptions?: Record<string, any>;
|
|
66
|
+
/** Pool options for this replica */
|
|
67
|
+
pool?: {
|
|
68
|
+
max?: number;
|
|
69
|
+
min?: number;
|
|
70
|
+
idle?: number;
|
|
71
|
+
acquire?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Configuration for lag detection
|
|
76
|
+
*/
|
|
77
|
+
export interface LagDetectionConfig {
|
|
78
|
+
/** Enable lag detection */
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
/** Interval in milliseconds between lag checks */
|
|
81
|
+
interval: number;
|
|
82
|
+
/** Query timeout in milliseconds */
|
|
83
|
+
timeout: number;
|
|
84
|
+
/** Maximum acceptable lag in milliseconds */
|
|
85
|
+
maxAcceptableLag: number;
|
|
86
|
+
/** Number of consecutive failures before marking replica as unhealthy */
|
|
87
|
+
maxFailures: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Options for configuring replication
|
|
91
|
+
*/
|
|
92
|
+
export interface ReplicationOptions {
|
|
93
|
+
/** Enable replication support */
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
/** The master connection configuration */
|
|
96
|
+
master: ReplicaConnectionConfig;
|
|
97
|
+
/** Array of replica configurations */
|
|
98
|
+
replicas: ReplicaConnectionConfig[];
|
|
99
|
+
/** Default lag detection configuration */
|
|
100
|
+
lagDetection?: Partial<LagDetectionConfig>;
|
|
101
|
+
/** Default routing strategy */
|
|
102
|
+
defaultRoutingStrategy?: RoutingStrategy;
|
|
103
|
+
/** Whether to automatically fail over to master on all replicas unhealthy */
|
|
104
|
+
autoFailover?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Replica connection pool wrapper
|
|
108
|
+
*/
|
|
109
|
+
declare class ReplicaPool {
|
|
110
|
+
private pool;
|
|
111
|
+
private dialect;
|
|
112
|
+
private name;
|
|
113
|
+
private config;
|
|
114
|
+
private dialectModule;
|
|
115
|
+
constructor(config: ReplicaConnectionConfig);
|
|
116
|
+
initialize(dialectModule: any): Promise<void>;
|
|
117
|
+
getPool(): any;
|
|
118
|
+
getName(): string;
|
|
119
|
+
getDialect(): string;
|
|
120
|
+
getConnection(): Promise<any>;
|
|
121
|
+
releaseConnection(connection: any): Promise<void>;
|
|
122
|
+
close(): Promise<void>;
|
|
123
|
+
query(sql: string, options?: QueryOptions): Promise<any>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Replica Manager Events
|
|
127
|
+
*/
|
|
128
|
+
export interface ReplicaManagerEvents {
|
|
129
|
+
'replica:added': (name: string) => void;
|
|
130
|
+
'replica:removed': (name: string) => void;
|
|
131
|
+
'replica:healthy': (name: string, status: ReplicaStatus) => void;
|
|
132
|
+
'replica:unhealthy': (name: string, status: ReplicaStatus) => void;
|
|
133
|
+
'replica:lag-detected': (name: string, lag: number) => void;
|
|
134
|
+
'replica:selected': (name: string) => void;
|
|
135
|
+
'all-replicas-unhealthy': () => void;
|
|
136
|
+
'monitor:started': () => void;
|
|
137
|
+
'monitor:stopped': () => void;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* ReplicaManager class for managing read replicas with lag detection
|
|
141
|
+
*/
|
|
142
|
+
export declare class ReplicaManager extends EventEmitter {
|
|
143
|
+
private replicas;
|
|
144
|
+
private replicaStats;
|
|
145
|
+
private lagDetectionConfig;
|
|
146
|
+
private routingStrategy;
|
|
147
|
+
private roundRobinIndex;
|
|
148
|
+
private monitorInterval;
|
|
149
|
+
private masterConfig;
|
|
150
|
+
/**
|
|
151
|
+
* Create a new ReplicaManager
|
|
152
|
+
*/
|
|
153
|
+
constructor(options?: Partial<ReplicationOptions>);
|
|
154
|
+
/**
|
|
155
|
+
* Add a replica to the manager
|
|
156
|
+
*/
|
|
157
|
+
addReplica(config: ReplicaConnectionConfig): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Remove a replica from the manager
|
|
160
|
+
*/
|
|
161
|
+
removeReplica(name: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Get a replica by name
|
|
164
|
+
*/
|
|
165
|
+
getReplica(name: string): ReplicaPool | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Get all replica names
|
|
168
|
+
*/
|
|
169
|
+
getReplicaNames(): string[];
|
|
170
|
+
/**
|
|
171
|
+
* Check replication lag for a specific replica
|
|
172
|
+
* Uses dialect-specific queries for lag detection
|
|
173
|
+
*/
|
|
174
|
+
checkLag(name: string): Promise<number | null>;
|
|
175
|
+
/**
|
|
176
|
+
* Start the lag monitoring loop
|
|
177
|
+
*/
|
|
178
|
+
startLagMonitor(): void;
|
|
179
|
+
/**
|
|
180
|
+
* Stop the lag monitoring loop
|
|
181
|
+
*/
|
|
182
|
+
stopLagMonitor(): void;
|
|
183
|
+
/**
|
|
184
|
+
* Get statistics for all replicas
|
|
185
|
+
*/
|
|
186
|
+
getReplicaStats(): Map<string, ReplicaStatus>;
|
|
187
|
+
/**
|
|
188
|
+
* Get statistics for a specific replica
|
|
189
|
+
*/
|
|
190
|
+
getReplicaStat(name: string): ReplicaStatus | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Set the routing strategy
|
|
193
|
+
*/
|
|
194
|
+
setRoutingStrategy(strategy: RoutingStrategy): void;
|
|
195
|
+
/**
|
|
196
|
+
* Get the current routing strategy
|
|
197
|
+
*/
|
|
198
|
+
getRoutingStrategy(): RoutingStrategy;
|
|
199
|
+
/**
|
|
200
|
+
* Select a replica based on the current routing strategy
|
|
201
|
+
*/
|
|
202
|
+
selectReplica(): Promise<{
|
|
203
|
+
name: string;
|
|
204
|
+
pool: ReplicaPool;
|
|
205
|
+
}>;
|
|
206
|
+
/**
|
|
207
|
+
* Execute a query on a replica (auto-selects replica based on routing strategy)
|
|
208
|
+
*/
|
|
209
|
+
queryReplica(sql: string, options?: QueryOptions): Promise<any>;
|
|
210
|
+
/**
|
|
211
|
+
* Get healthy replicas
|
|
212
|
+
*/
|
|
213
|
+
getHealthyReplicas(): string[];
|
|
214
|
+
/**
|
|
215
|
+
* Get replica count
|
|
216
|
+
*/
|
|
217
|
+
getReplicaCount(): number;
|
|
218
|
+
/**
|
|
219
|
+
* Check if replication is enabled
|
|
220
|
+
*/
|
|
221
|
+
isReplicationEnabled(): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Set lag detection configuration
|
|
224
|
+
*/
|
|
225
|
+
setLagDetectionConfig(config: Partial<LagDetectionConfig>): void;
|
|
226
|
+
/**
|
|
227
|
+
* Get lag detection configuration
|
|
228
|
+
*/
|
|
229
|
+
getLagDetectionConfig(): LagDetectionConfig;
|
|
230
|
+
/**
|
|
231
|
+
* Close all replica connections
|
|
232
|
+
*/
|
|
233
|
+
close(): Promise<void>;
|
|
234
|
+
}
|
|
235
|
+
export default ReplicaManager;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Module - Automated schema diffing and migration generation
|
|
3
|
+
* Exports classes and functions for comparing model definitions against database schema
|
|
4
|
+
*/
|
|
5
|
+
export type { ChangeType, ColumnChange, IndexChange, ConstraintChange, ForeignKeyChange, TableChange, SchemaDiff, ColumnDefinition, IndexDefinition, ConstraintDefinition, ForeignKeyDefinition, DatabaseColumnInfo, DatabaseIndexInfo, DatabaseConstraintInfo, DatabaseForeignKeyInfo, MigrationScript, MigrationGeneratorOptions, SchemaDifferOptions, } from './types';
|
|
6
|
+
export { SchemaDiffer, createSchemaDiffer } from './schema-differ';
|
|
7
|
+
export { MigrationGenerator, createMigrationGenerator } from './migration-generator';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration Generator
|
|
3
|
+
* Generates migration scripts from schema diffs
|
|
4
|
+
*/
|
|
5
|
+
import type { Dialect } from '../dialects/dialect';
|
|
6
|
+
import type { SchemaDiff, MigrationScript, MigrationGeneratorOptions } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* MigrationGenerator generates SQL migration scripts from schema diffs
|
|
9
|
+
*/
|
|
10
|
+
export declare class MigrationGenerator {
|
|
11
|
+
private dialect;
|
|
12
|
+
private options;
|
|
13
|
+
constructor(dialect: Dialect, options?: MigrationGeneratorOptions);
|
|
14
|
+
/**
|
|
15
|
+
* Generate a migration script from a schema diff
|
|
16
|
+
*/
|
|
17
|
+
generateMigration(diff: SchemaDiff, options?: MigrationGeneratorOptions): MigrationScript;
|
|
18
|
+
/**
|
|
19
|
+
* Generate migration scripts for all schema diffs
|
|
20
|
+
*/
|
|
21
|
+
generateAllMigrations(diffs: SchemaDiff[], options?: MigrationGeneratorOptions): MigrationScript[];
|
|
22
|
+
/**
|
|
23
|
+
* Generate column migration statements
|
|
24
|
+
*/
|
|
25
|
+
private generateColumnMigration;
|
|
26
|
+
/**
|
|
27
|
+
* Generate index migration statements
|
|
28
|
+
*/
|
|
29
|
+
private generateIndexMigration;
|
|
30
|
+
/**
|
|
31
|
+
* Generate constraint migration statements
|
|
32
|
+
*/
|
|
33
|
+
private generateConstraintMigration;
|
|
34
|
+
/**
|
|
35
|
+
* Generate foreign key migration statements
|
|
36
|
+
*/
|
|
37
|
+
private generateForeignKeyMigration;
|
|
38
|
+
/**
|
|
39
|
+
* Generate ADD COLUMN SQL
|
|
40
|
+
*/
|
|
41
|
+
private generateAddColumnSql;
|
|
42
|
+
/**
|
|
43
|
+
* Generate MODIFY COLUMN SQL
|
|
44
|
+
*/
|
|
45
|
+
private generateModifyColumnSql;
|
|
46
|
+
/**
|
|
47
|
+
* Generate CREATE INDEX SQL
|
|
48
|
+
*/
|
|
49
|
+
private generateCreateIndexSql;
|
|
50
|
+
/**
|
|
51
|
+
* Generate ADD CONSTRAINT SQL
|
|
52
|
+
*/
|
|
53
|
+
private generateAddConstraintSql;
|
|
54
|
+
/**
|
|
55
|
+
* Generate ADD FOREIGN KEY SQL
|
|
56
|
+
*/
|
|
57
|
+
private generateAddForeignKeySql;
|
|
58
|
+
/**
|
|
59
|
+
* Quote table name based on dialect
|
|
60
|
+
*/
|
|
61
|
+
private quoteTableName;
|
|
62
|
+
/**
|
|
63
|
+
* Quote identifier based on dialect
|
|
64
|
+
*/
|
|
65
|
+
private quoteIdentifier;
|
|
66
|
+
/**
|
|
67
|
+
* Format default value for SQL
|
|
68
|
+
*/
|
|
69
|
+
private formatDefaultValue;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a MigrationGenerator instance
|
|
73
|
+
*/
|
|
74
|
+
export declare function createMigrationGenerator(dialect: Dialect, options?: MigrationGeneratorOptions): MigrationGenerator;
|