ts-prorm-orm 1.1.0 → 1.2.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 +83 -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 +711 -0
- package/dist/index.js +19 -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,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Compiles the ORM `where`/`order` shape into Flux, so callers read InfluxDB
|
|
4
|
+
* through the model API instead of hand-writing Flux for standard queries.
|
|
5
|
+
*
|
|
6
|
+
* The generated predicate references the *pivoted* row (`r.<column>`), i.e. it
|
|
7
|
+
* is applied after `pivot()` folds each measurement's fields into columns, so a
|
|
8
|
+
* single predicate can mix tag columns and field columns uniformly. Operators
|
|
9
|
+
* Flux cannot express are surfaced as {@link FluxPushdownUnsupported}, which
|
|
10
|
+
* the store catches to fall back to collecting rows and filtering them in
|
|
11
|
+
* memory with the shared matcher - the read still succeeds.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FluxPushdownUnsupported = void 0;
|
|
15
|
+
exports.compileFluxPredicate = compileFluxPredicate;
|
|
16
|
+
exports.compileFluxSort = compileFluxSort;
|
|
17
|
+
/** Thrown when a where clause cannot be fully translated to a Flux predicate. */
|
|
18
|
+
class FluxPushdownUnsupported extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'FluxPushdownUnsupported';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.FluxPushdownUnsupported = FluxPushdownUnsupported;
|
|
25
|
+
function opName(key) {
|
|
26
|
+
if (typeof key === 'symbol')
|
|
27
|
+
return key.description ?? '';
|
|
28
|
+
return key.startsWith('$') ? key.slice(1) : key;
|
|
29
|
+
}
|
|
30
|
+
/** Render a JS value as a Flux literal. */
|
|
31
|
+
function lit(value) {
|
|
32
|
+
if (value === null || value === undefined)
|
|
33
|
+
return 'false';
|
|
34
|
+
if (typeof value === 'number')
|
|
35
|
+
return String(value);
|
|
36
|
+
if (typeof value === 'boolean')
|
|
37
|
+
return value ? 'true' : 'false';
|
|
38
|
+
if (value instanceof Date)
|
|
39
|
+
return value.toISOString();
|
|
40
|
+
// Strings: escape backslashes and double-quotes for a Flux string literal.
|
|
41
|
+
return `"${String(value).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
42
|
+
}
|
|
43
|
+
/** Reference to a pivoted column: `r["name"]` (bracket form handles any key). */
|
|
44
|
+
function col(field) {
|
|
45
|
+
return `r["${field.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"]`;
|
|
46
|
+
}
|
|
47
|
+
/** Convert a SQL LIKE pattern into a Flux regex literal body (no anchors added here). */
|
|
48
|
+
function likeToRegexBody(pattern) {
|
|
49
|
+
let out = '';
|
|
50
|
+
for (const ch of pattern) {
|
|
51
|
+
if (ch === '%')
|
|
52
|
+
out += '.*';
|
|
53
|
+
else if (ch === '_')
|
|
54
|
+
out += '.';
|
|
55
|
+
else
|
|
56
|
+
out += ch.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function compileOperator(field, op, operand) {
|
|
61
|
+
const c = col(field);
|
|
62
|
+
switch (op) {
|
|
63
|
+
case 'eq':
|
|
64
|
+
case 'is':
|
|
65
|
+
return `${c} == ${lit(operand)}`;
|
|
66
|
+
case 'ne':
|
|
67
|
+
return `${c} != ${lit(operand)}`;
|
|
68
|
+
case 'gt':
|
|
69
|
+
return `${c} > ${lit(operand)}`;
|
|
70
|
+
case 'gte':
|
|
71
|
+
return `${c} >= ${lit(operand)}`;
|
|
72
|
+
case 'lt':
|
|
73
|
+
return `${c} < ${lit(operand)}`;
|
|
74
|
+
case 'lte':
|
|
75
|
+
return `${c} <= ${lit(operand)}`;
|
|
76
|
+
case 'in':
|
|
77
|
+
return `contains(value: ${c}, set: [${operand.map(lit).join(', ')}])`;
|
|
78
|
+
case 'notIn':
|
|
79
|
+
return `not contains(value: ${c}, set: [${operand.map(lit).join(', ')}])`;
|
|
80
|
+
case 'between': {
|
|
81
|
+
const [a, b] = operand;
|
|
82
|
+
return `(${c} >= ${lit(a)} and ${c} <= ${lit(b)})`;
|
|
83
|
+
}
|
|
84
|
+
case 'notBetween': {
|
|
85
|
+
const [a, b] = operand;
|
|
86
|
+
return `not (${c} >= ${lit(a)} and ${c} <= ${lit(b)})`;
|
|
87
|
+
}
|
|
88
|
+
case 'like':
|
|
89
|
+
return `${c} =~ /^${likeToRegexBody(String(operand))}$/`;
|
|
90
|
+
case 'notLike':
|
|
91
|
+
return `${c} !~ /^${likeToRegexBody(String(operand))}$/`;
|
|
92
|
+
case 'iLike':
|
|
93
|
+
return `${c} =~ /(?i)^${likeToRegexBody(String(operand))}$/`;
|
|
94
|
+
case 'notILike':
|
|
95
|
+
return `${c} !~ /(?i)^${likeToRegexBody(String(operand))}$/`;
|
|
96
|
+
case 'startsWith':
|
|
97
|
+
return `${c} =~ /^${likeToRegexBody(String(operand))}/`;
|
|
98
|
+
case 'endsWith':
|
|
99
|
+
return `${c} =~ /${likeToRegexBody(String(operand))}$/`;
|
|
100
|
+
case 'substring':
|
|
101
|
+
return `${c} =~ /${likeToRegexBody(String(operand))}/`;
|
|
102
|
+
case 'regexp':
|
|
103
|
+
return `${c} =~ /${String(operand)}/`;
|
|
104
|
+
case 'notRegexp':
|
|
105
|
+
return `${c} !~ /${String(operand)}/`;
|
|
106
|
+
case 'iRegexp':
|
|
107
|
+
return `${c} =~ /(?i)${String(operand)}/`;
|
|
108
|
+
default:
|
|
109
|
+
throw new FluxPushdownUnsupported(`operator ${op}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function compileField(field, condition) {
|
|
113
|
+
if (condition === null ||
|
|
114
|
+
typeof condition !== 'object' ||
|
|
115
|
+
condition instanceof Date ||
|
|
116
|
+
Array.isArray(condition)) {
|
|
117
|
+
return `${col(field)} == ${lit(condition)}`;
|
|
118
|
+
}
|
|
119
|
+
const clauses = [];
|
|
120
|
+
for (const key of Reflect.ownKeys(condition)) {
|
|
121
|
+
clauses.push(compileOperator(field, opName(key), condition[key]));
|
|
122
|
+
}
|
|
123
|
+
return clauses.length > 1 ? `(${clauses.join(' and ')})` : clauses[0] ?? 'true';
|
|
124
|
+
}
|
|
125
|
+
function compileClause(where) {
|
|
126
|
+
const parts = [];
|
|
127
|
+
for (const key of Reflect.ownKeys(where)) {
|
|
128
|
+
const val = where[key];
|
|
129
|
+
const op = opName(key);
|
|
130
|
+
if (op === 'and') {
|
|
131
|
+
const arr = Array.isArray(val) ? val : [val];
|
|
132
|
+
parts.push(`(${arr.map((s) => compileClause(s)).join(' and ')})`);
|
|
133
|
+
}
|
|
134
|
+
else if (op === 'or') {
|
|
135
|
+
const arr = Array.isArray(val) ? val : [val];
|
|
136
|
+
parts.push(`(${arr.map((s) => compileClause(s)).join(' or ')})`);
|
|
137
|
+
}
|
|
138
|
+
else if (op === 'not') {
|
|
139
|
+
const arr = Array.isArray(val) ? val : [val];
|
|
140
|
+
parts.push(`not (${arr.map((s) => compileClause(s)).join(' and ')})`);
|
|
141
|
+
}
|
|
142
|
+
else if (typeof key === 'symbol') {
|
|
143
|
+
throw new FluxPushdownUnsupported(`operator ${op} without a field`);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
parts.push(compileField(key, val));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return parts.length > 1 ? `(${parts.join(' and ')})` : parts[0] ?? 'true';
|
|
150
|
+
}
|
|
151
|
+
/** Compile a where clause to a Flux `filter(fn: (r) => ...)` predicate body. */
|
|
152
|
+
function compileFluxPredicate(where) {
|
|
153
|
+
return compileClause(where);
|
|
154
|
+
}
|
|
155
|
+
/** Compile an `order` spec to Flux `sort()` args: `columns: [...], desc: bool`. */
|
|
156
|
+
function compileFluxSort(order) {
|
|
157
|
+
const entries = typeof order === 'string' ? [order] : order;
|
|
158
|
+
const columns = [];
|
|
159
|
+
let desc = false;
|
|
160
|
+
for (const entry of entries) {
|
|
161
|
+
if (typeof entry === 'string') {
|
|
162
|
+
columns.push(entry);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
columns.push(entry[0]);
|
|
166
|
+
desc = String(entry[1]).toUpperCase() === 'DESC';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return { columns, desc };
|
|
170
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InfluxDB store implementation.
|
|
3
|
+
*
|
|
4
|
+
* InfluxDB is a time-series database: writes are append-only points
|
|
5
|
+
* (measurement + tags + fields + timestamp) expressed in line protocol,
|
|
6
|
+
* and reads are Flux scripts that stream back annotated CSV rows grouped
|
|
7
|
+
* into tables. There is no `JOIN`/`WHERE row = ...` update model, no
|
|
8
|
+
* transactions, and no schema beyond "a bucket accepts points" - none of
|
|
9
|
+
* which fits the SQL-shaped `Dialect` interface (`src/dialects/dialect.ts`).
|
|
10
|
+
* This class instead implements the minimal `NoSqlStore` marker interface
|
|
11
|
+
* (`src/nosql/store.ts`) and exposes InfluxDB's real write/query APIs
|
|
12
|
+
* directly.
|
|
13
|
+
*
|
|
14
|
+
* Uses the official `@influxdata/influxdb-client` driver (InfluxDB 2.x /
|
|
15
|
+
* InfluxDB Cloud, token + org + bucket auth, Flux query language).
|
|
16
|
+
*
|
|
17
|
+
* ## Write buffering - the #1 gotcha
|
|
18
|
+
*
|
|
19
|
+
* The client's `WriteApi` ALWAYS buffers written points/lines in memory
|
|
20
|
+
* and batches them to the server in the background (by `batchSize` or
|
|
21
|
+
* `flushInterval`, whichever comes first). Calling `writePoint`/
|
|
22
|
+
* `writePoints`/`writeRecord`/`writeRecords` returns immediately and does
|
|
23
|
+
* NOT guarantee the data has reached the server - a query issued right
|
|
24
|
+
* after can legitimately observe nothing yet. Call `flush()` (or
|
|
25
|
+
* `close()`, which flushes then releases the write API) to force pending
|
|
26
|
+
* points out. `disconnect()` below flushes and closes every write API
|
|
27
|
+
* this store has opened, so buffered points are never silently dropped
|
|
28
|
+
* on shutdown.
|
|
29
|
+
*/
|
|
30
|
+
import { InfluxDB, Point, type WriteApi, type WriteOptions, type WritePrecisionType, type Row, type FluxTableMetaData, type ParameterizedQuery } from '@influxdata/influxdb-client';
|
|
31
|
+
import { NoSqlStore } from '../store';
|
|
32
|
+
import { type WhereClause, type OrderSpec } from '../rocksdb/where-match';
|
|
33
|
+
export { compileFluxPredicate, compileFluxSort, FluxPushdownUnsupported } from './flux-compiler';
|
|
34
|
+
export type { WhereClause, OrderSpec } from '../rocksdb/where-match';
|
|
35
|
+
/**
|
|
36
|
+
* Describes how a record maps onto InfluxDB's line-protocol shape: which
|
|
37
|
+
* keys are indexed tags, which key carries the timestamp, and integer-typed
|
|
38
|
+
* fields. Everything not named a tag or the time field becomes a value field.
|
|
39
|
+
*/
|
|
40
|
+
export interface InfluxMeasurementSchema {
|
|
41
|
+
/** Measurement (table) name. */
|
|
42
|
+
measurement: string;
|
|
43
|
+
/** Bucket to write to / read from. Falls back to the store's default bucket. */
|
|
44
|
+
bucket?: string;
|
|
45
|
+
/** Record keys to write as indexed tags (strings). */
|
|
46
|
+
tags?: string[];
|
|
47
|
+
/** Record key holding the point timestamp. Defaults to `'time'`. */
|
|
48
|
+
timeField?: string;
|
|
49
|
+
/** Field names to write as signed integers rather than floats. */
|
|
50
|
+
intFields?: string[];
|
|
51
|
+
/** Field names to write as unsigned integers rather than floats. */
|
|
52
|
+
uintFields?: string[];
|
|
53
|
+
}
|
|
54
|
+
/** A start/stop window for a Flux `range()`. Accepts durations, Dates, or epoch ms. */
|
|
55
|
+
export interface InfluxTimeRange {
|
|
56
|
+
/** Range start: a Flux duration string (`'-30d'`), RFC3339 string, `Date`, or epoch ms. Defaults to the Unix epoch. */
|
|
57
|
+
start?: string | number | Date;
|
|
58
|
+
/** Range stop. Defaults to `now()`. */
|
|
59
|
+
stop?: string | number | Date;
|
|
60
|
+
}
|
|
61
|
+
/** Options for {@link InfluxDBStore.findAll} / {@link InfluxDBStore.findOne}. */
|
|
62
|
+
export interface InfluxFindOptions {
|
|
63
|
+
/** Measurement to read from. */
|
|
64
|
+
measurement: string;
|
|
65
|
+
/** Bucket to read from. Falls back to the store's default bucket. */
|
|
66
|
+
bucket?: string;
|
|
67
|
+
/** Row filter. Tag and field predicates are pushed into Flux where possible. */
|
|
68
|
+
where?: WhereClause;
|
|
69
|
+
/** Sort spec. Defaults to ascending `_time`. */
|
|
70
|
+
order?: OrderSpec;
|
|
71
|
+
limit?: number;
|
|
72
|
+
offset?: number;
|
|
73
|
+
/** Time window. Defaults to all time (`epoch`..`now()`). */
|
|
74
|
+
range?: InfluxTimeRange;
|
|
75
|
+
}
|
|
76
|
+
/** Aggregate/downsample options for {@link InfluxDBStore.aggregate}. */
|
|
77
|
+
export interface InfluxAggregateOptions {
|
|
78
|
+
measurement: string;
|
|
79
|
+
bucket?: string;
|
|
80
|
+
/** Field to aggregate. */
|
|
81
|
+
field: string;
|
|
82
|
+
/** Aggregate function: `mean`, `sum`, `min`, `max`, `count`, `first`, `last`, `median`, `stddev`. */
|
|
83
|
+
fn: 'mean' | 'sum' | 'min' | 'max' | 'count' | 'first' | 'last' | 'median' | 'stddev';
|
|
84
|
+
/** Tag predicate (applied before aggregation). */
|
|
85
|
+
where?: WhereClause;
|
|
86
|
+
/** Time window. */
|
|
87
|
+
range?: InfluxTimeRange;
|
|
88
|
+
/** Downsample window, e.g. `'1h'`. Uses `aggregateWindow` when set. */
|
|
89
|
+
window?: string;
|
|
90
|
+
/** Tags to group by before aggregating. */
|
|
91
|
+
groupBy?: string[];
|
|
92
|
+
}
|
|
93
|
+
export { Point } from '@influxdata/influxdb-client';
|
|
94
|
+
export type { WriteApi, QueryApi, WriteOptions, WritePrecisionType, Row, FluxTableMetaData, ParameterizedQuery, } from '@influxdata/influxdb-client';
|
|
95
|
+
/**
|
|
96
|
+
* Connection options for `InfluxDBStore`.
|
|
97
|
+
*
|
|
98
|
+
* `url`, `token`, and `org` are required - InfluxDB 2.x/Cloud auth is
|
|
99
|
+
* token-based and every write/query is scoped to an organization.
|
|
100
|
+
* `bucket` is optional here and is only used as the default bucket for
|
|
101
|
+
* convenience methods that don't take an explicit `bucket` override.
|
|
102
|
+
*/
|
|
103
|
+
export interface InfluxDBStoreOptions {
|
|
104
|
+
/** Base URL of the InfluxDB server/cloud instance, e.g. `http://localhost:8086`. */
|
|
105
|
+
url: string;
|
|
106
|
+
/** API token used for both writes and queries. */
|
|
107
|
+
token: string;
|
|
108
|
+
/** Organization (name or ID) that writes/queries are scoped to. */
|
|
109
|
+
org: string;
|
|
110
|
+
/** Default bucket used by convenience methods when no `bucket` override is given. */
|
|
111
|
+
bucket?: string;
|
|
112
|
+
/** Default timestamp precision for the write API. Defaults to `'ns'`. */
|
|
113
|
+
precision?: WritePrecisionType;
|
|
114
|
+
/** Socket timeout in milliseconds. Defaults to the client's own default (10000). */
|
|
115
|
+
timeout?: number;
|
|
116
|
+
/** Extra HTTP headers sent with every request. */
|
|
117
|
+
headers?: Record<string, string>;
|
|
118
|
+
/** Overrides for the write API's batching/retry behavior (batchSize, flushInterval, maxRetries, ...). */
|
|
119
|
+
writeOptions?: Partial<WriteOptions>;
|
|
120
|
+
}
|
|
121
|
+
/** Per-call override of bucket/org/precision for write operations. */
|
|
122
|
+
export interface WriteScopeOptions {
|
|
123
|
+
/** Bucket to write into. Falls back to `InfluxDBStoreOptions.bucket`. */
|
|
124
|
+
bucket?: string;
|
|
125
|
+
/** Organization to write into. Falls back to `InfluxDBStoreOptions.org`. */
|
|
126
|
+
org?: string;
|
|
127
|
+
/** Timestamp precision for this write API instance. Falls back to `InfluxDBStoreOptions.precision`. */
|
|
128
|
+
precision?: WritePrecisionType;
|
|
129
|
+
}
|
|
130
|
+
/** Per-call override of org for query operations. */
|
|
131
|
+
export interface QueryScopeOptions {
|
|
132
|
+
/** Organization to query against. Falls back to `InfluxDBStoreOptions.org`. */
|
|
133
|
+
org?: string;
|
|
134
|
+
}
|
|
135
|
+
/** Plain-object description of a point, for the `writeMeasurement`/`writeMeasurements` convenience methods. */
|
|
136
|
+
export interface PointInput {
|
|
137
|
+
/** Measurement name. */
|
|
138
|
+
measurement: string;
|
|
139
|
+
/** Tag set (indexed, string-valued). */
|
|
140
|
+
tags?: Record<string, string>;
|
|
141
|
+
/**
|
|
142
|
+
* Field set (the actual values). `number` fields are written as floats
|
|
143
|
+
* unless `intFields`/`uintFields` name them explicitly - see
|
|
144
|
+
* `PointInput.intFields`/`uintFields`.
|
|
145
|
+
*/
|
|
146
|
+
fields: Record<string, string | number | boolean>;
|
|
147
|
+
/** Names (subset of `fields`' keys) that should be written as signed integers instead of floats. */
|
|
148
|
+
intFields?: string[];
|
|
149
|
+
/** Names (subset of `fields`' keys) that should be written as unsigned integers instead of floats. */
|
|
150
|
+
uintFields?: string[];
|
|
151
|
+
/**
|
|
152
|
+
* Point timestamp. `undefined` (default) lets the client stamp it with
|
|
153
|
+
* the local clock; an explicit `Date`/`number`/string sets it; the
|
|
154
|
+
* empty string `''` omits it so the server assigns one on ingest.
|
|
155
|
+
*/
|
|
156
|
+
timestamp?: Date | number | string;
|
|
157
|
+
}
|
|
158
|
+
/** A single row from a Flux query result, already converted to a plain object via its table metadata. */
|
|
159
|
+
export type QueryRow = Record<string, unknown>;
|
|
160
|
+
/**
|
|
161
|
+
* `InfluxDBStore` wraps `@influxdata/influxdb-client`'s `InfluxDB` client
|
|
162
|
+
* and exposes InfluxDB's write API (point/line-protocol writes, buffered
|
|
163
|
+
* with explicit flush/close) and query API (Flux, streamed row-by-row)
|
|
164
|
+
* as a typed, promise/async-iterable-based API.
|
|
165
|
+
*/
|
|
166
|
+
export declare class InfluxDBStore implements NoSqlStore {
|
|
167
|
+
readonly name = "influxdb";
|
|
168
|
+
readonly library = "@influxdata/influxdb-client";
|
|
169
|
+
private readonly options;
|
|
170
|
+
private client;
|
|
171
|
+
private connected;
|
|
172
|
+
private readonly writeApis;
|
|
173
|
+
private readonly queryApis;
|
|
174
|
+
constructor(options: InfluxDBStoreOptions);
|
|
175
|
+
/**
|
|
176
|
+
* Creates the underlying `InfluxDB` client and verifies the url/token/org
|
|
177
|
+
* combination by issuing a trivial Flux query (`buckets() |> limit(n:1)`).
|
|
178
|
+
* InfluxDB's HTTP client has no persistent socket to "connect", so this
|
|
179
|
+
* is the closest equivalent to the connect-time failure surfaced by
|
|
180
|
+
* socket-based stores (bad host, refused connection, invalid token/org).
|
|
181
|
+
*/
|
|
182
|
+
connect(): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Flushes and closes every write API opened by this store (so no
|
|
185
|
+
* buffered point is silently dropped), then drops the client.
|
|
186
|
+
*/
|
|
187
|
+
disconnect(): Promise<void>;
|
|
188
|
+
isConnected(): boolean;
|
|
189
|
+
/** Returns the underlying `InfluxDB` client for anything not wrapped here. */
|
|
190
|
+
getClient(): InfluxDB;
|
|
191
|
+
private requireClient;
|
|
192
|
+
private resolveBucket;
|
|
193
|
+
/**
|
|
194
|
+
* Returns the memoized `WriteApi` for the given (org, bucket, precision),
|
|
195
|
+
* creating it on first use. Returned instances buffer writes - see the
|
|
196
|
+
* write-buffering note in this file's header comment.
|
|
197
|
+
*/
|
|
198
|
+
getWriteApi(scope?: WriteScopeOptions): WriteApi;
|
|
199
|
+
/** Write a single already-built `Point`. Buffered - call `flush()` to force delivery. */
|
|
200
|
+
writePoint(point: Point, scope?: WriteScopeOptions): void;
|
|
201
|
+
/** Write multiple already-built `Point`s. Buffered - call `flush()` to force delivery. */
|
|
202
|
+
writePoints(points: ArrayLike<Point>, scope?: WriteScopeOptions): void;
|
|
203
|
+
/** Write a single raw line-protocol record. Buffered - call `flush()` to force delivery. */
|
|
204
|
+
writeRecord(record: string, scope?: WriteScopeOptions): void;
|
|
205
|
+
/** Write multiple raw line-protocol records. Buffered - call `flush()` to force delivery. */
|
|
206
|
+
writeRecords(records: string[], scope?: WriteScopeOptions): void;
|
|
207
|
+
/** Convenience: build a `Point` from a plain object and write it. */
|
|
208
|
+
writeMeasurement(input: PointInput, scope?: WriteScopeOptions): void;
|
|
209
|
+
/** Convenience: build and write a batch of `Point`s from plain objects. */
|
|
210
|
+
writeMeasurements(inputs: PointInput[], scope?: WriteScopeOptions): void;
|
|
211
|
+
/**
|
|
212
|
+
* Flushes the write API for the given scope, sending any buffered
|
|
213
|
+
* points/lines to the server immediately. Resolves once the flush
|
|
214
|
+
* completes (or immediately if nothing was ever written for that scope).
|
|
215
|
+
*/
|
|
216
|
+
flush(scope?: WriteScopeOptions): Promise<void>;
|
|
217
|
+
/** Flushes every write API this store has opened, across all buckets/orgs/precisions. */
|
|
218
|
+
flushAll(): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Flushes and closes the write API for the given scope, releasing it so
|
|
221
|
+
* a subsequent write for the same scope opens a fresh one.
|
|
222
|
+
*/
|
|
223
|
+
closeWriteApi(scope?: WriteScopeOptions): Promise<void>;
|
|
224
|
+
private getQueryApi;
|
|
225
|
+
/**
|
|
226
|
+
* Streams a Flux query's result rows, already converted to plain
|
|
227
|
+
* objects via each row's table metadata (equivalent to
|
|
228
|
+
* `tableMeta.toObject(row.values)`). Suitable for `for-await` loops
|
|
229
|
+
* over large result sets without buffering everything in memory.
|
|
230
|
+
*/
|
|
231
|
+
query(fluxQuery: string | ParameterizedQuery, scope?: QueryScopeOptions): AsyncIterable<QueryRow>;
|
|
232
|
+
/**
|
|
233
|
+
* Streams a Flux query's raw `Row`s (values + table metadata),
|
|
234
|
+
* without the `toObject` conversion `query()` applies.
|
|
235
|
+
*/
|
|
236
|
+
queryRows(fluxQuery: string | ParameterizedQuery, scope?: QueryScopeOptions): AsyncIterable<Row>;
|
|
237
|
+
/**
|
|
238
|
+
* Executes a Flux query and collects every result row into an array via
|
|
239
|
+
* the returned Promise. Use with caution on large result sets - the
|
|
240
|
+
* whole result is buffered in memory. Prefer `query()`/`queryRows()`
|
|
241
|
+
* for streaming.
|
|
242
|
+
*/
|
|
243
|
+
collectRows<T = QueryRow>(fluxQuery: string | ParameterizedQuery, rowMapper?: (values: string[], tableMeta: FluxTableMetaData) => T | undefined, scope?: QueryScopeOptions): Promise<T[]>;
|
|
244
|
+
/** Executes a Flux query and returns the full annotated-CSV response as a string. */
|
|
245
|
+
queryRaw(fluxQuery: string | ParameterizedQuery, scope?: QueryScopeOptions): Promise<string>;
|
|
246
|
+
/** Render a time-range bound as a Flux time/duration literal. */
|
|
247
|
+
private static fluxTime;
|
|
248
|
+
private static escapeFlux;
|
|
249
|
+
/**
|
|
250
|
+
* ORM `create`: model one record as a line-protocol point per `schema`
|
|
251
|
+
* (tags vs fields vs timestamp) and write it. Buffered - this method flushes
|
|
252
|
+
* so the point is durable before it resolves.
|
|
253
|
+
*/
|
|
254
|
+
create(schema: InfluxMeasurementSchema, record: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
255
|
+
/** ORM `bulkCreate`: write many records as points, then flush. */
|
|
256
|
+
bulkCreate(schema: InfluxMeasurementSchema, records: Array<Record<string, unknown>>): Promise<Array<Record<string, unknown>>>;
|
|
257
|
+
/** Build the base Flux for a measurement read (range + measurement filter + pivot). */
|
|
258
|
+
private buildBaseFlux;
|
|
259
|
+
/**
|
|
260
|
+
* ORM `findAll`. Generates Flux from `measurement`/`where`/`order`/`range`;
|
|
261
|
+
* `where` predicates are pushed into Flux when expressible, otherwise the
|
|
262
|
+
* rows are collected and filtered in memory with the shared matcher.
|
|
263
|
+
* `limit`/`offset` are applied to the (sorted) result.
|
|
264
|
+
*/
|
|
265
|
+
findAll<T = QueryRow>(options: InfluxFindOptions): Promise<T[]>;
|
|
266
|
+
/** ORM `findOne`: the first row matching `where` (respecting order). */
|
|
267
|
+
findOne<T = QueryRow>(options: InfluxFindOptions): Promise<T | null>;
|
|
268
|
+
/** ORM `count`: number of points/rows matching the query. */
|
|
269
|
+
count(options: InfluxFindOptions): Promise<number>;
|
|
270
|
+
/**
|
|
271
|
+
* Aggregate (and optionally downsample) a field. Generates Flux using either
|
|
272
|
+
* a bare aggregate (`mean()`, `sum()`, ...) or `aggregateWindow(every, fn)`
|
|
273
|
+
* when `window` is set, grouping by `groupBy` tags first. Returns the result
|
|
274
|
+
* rows so callers never hand-write Flux for standard aggregates.
|
|
275
|
+
*/
|
|
276
|
+
aggregate<T = QueryRow>(options: InfluxAggregateOptions): Promise<T[]>;
|
|
277
|
+
/**
|
|
278
|
+
* ORM `update` is unsupported: InfluxDB points are immutable, so there is no
|
|
279
|
+
* safe in-place row update to emulate. Write a new point (`create`) with the
|
|
280
|
+
* corrected values instead, or delete + rewrite via {@link destroy}. Throws
|
|
281
|
+
* a typed capability error rather than silently doing nothing.
|
|
282
|
+
*/
|
|
283
|
+
update(): Promise<never>;
|
|
284
|
+
/**
|
|
285
|
+
* ORM `destroy`: delete points from `measurement` within a time range,
|
|
286
|
+
* optionally narrowed by an equality predicate on tags. Uses InfluxDB's
|
|
287
|
+
* delete API (from the optional `@influxdata/influxdb-client-apis` package,
|
|
288
|
+
* required lazily). `where` supports only equality on tags/`_measurement`/
|
|
289
|
+
* `_field` - the delete API's predicate grammar - and throws a typed error
|
|
290
|
+
* for anything else, since a Flux-style filter cannot be emulated safely here.
|
|
291
|
+
*/
|
|
292
|
+
destroy(options: {
|
|
293
|
+
measurement: string;
|
|
294
|
+
bucket?: string;
|
|
295
|
+
where?: WhereClause;
|
|
296
|
+
range?: InfluxTimeRange;
|
|
297
|
+
}): Promise<void>;
|
|
298
|
+
/** Build a delete-API predicate string (equality-only) from a where clause. */
|
|
299
|
+
private static buildDeletePredicate;
|
|
300
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Kafka store implementation.
|
|
3
|
+
*
|
|
4
|
+
* Kafka is a distributed, partitioned, append-only commit log used as a
|
|
5
|
+
* message broker / event-streaming platform. It has no query language and
|
|
6
|
+
* does not fit the SQL-shaped `Dialect` interface, so this class implements
|
|
7
|
+
* the minimal `NoSqlStore` marker interface and exposes Kafka's real
|
|
8
|
+
* operations - producing to topics, creating/listing topics via the admin
|
|
9
|
+
* client, and subscribing consumers to topics - instead of forcing
|
|
10
|
+
* everything into a `query(sql)` shape.
|
|
11
|
+
*
|
|
12
|
+
* Uses the `kafkajs` driver. `kafkajs` is loaded lazily inside `connect()`
|
|
13
|
+
* (or supplied pre-built via `options.client`) so importing this module does
|
|
14
|
+
* not require the driver to be installed.
|
|
15
|
+
*/
|
|
16
|
+
import { NoSqlStore } from '../store';
|
|
17
|
+
/**
|
|
18
|
+
* SASL authentication options passed straight through to kafkajs.
|
|
19
|
+
*/
|
|
20
|
+
export interface KafkaSaslOptions {
|
|
21
|
+
mechanism: string;
|
|
22
|
+
username: string;
|
|
23
|
+
password: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Connection options for `KafkaStore`.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors kafkajs's `Kafka` constructor options. `brokers` is the list of
|
|
30
|
+
* `host:port` seed brokers. A pre-built kafkajs `Kafka` instance can be
|
|
31
|
+
* injected via `client`, in which case `connect()` uses it directly and
|
|
32
|
+
* skips loading the driver (this is how tests inject a mock).
|
|
33
|
+
*/
|
|
34
|
+
export interface KafkaStoreOptions {
|
|
35
|
+
/** Client identifier reported to the broker. */
|
|
36
|
+
clientId?: string;
|
|
37
|
+
/** Seed broker list, e.g. `['localhost:9092']`. */
|
|
38
|
+
brokers?: string[];
|
|
39
|
+
/** Enable TLS, or pass a kafkajs TLS options object. */
|
|
40
|
+
ssl?: boolean | Record<string, unknown>;
|
|
41
|
+
/** SASL authentication configuration. */
|
|
42
|
+
sasl?: KafkaSaslOptions;
|
|
43
|
+
/**
|
|
44
|
+
* A pre-built kafkajs `Kafka` instance. When provided, `connect()` uses it
|
|
45
|
+
* directly and does not `require('kafkajs')`.
|
|
46
|
+
*/
|
|
47
|
+
client?: any;
|
|
48
|
+
}
|
|
49
|
+
/** A single message to produce to a topic. */
|
|
50
|
+
export interface KafkaMessage {
|
|
51
|
+
key?: string | Buffer | null;
|
|
52
|
+
value: string | Buffer | null;
|
|
53
|
+
partition?: number;
|
|
54
|
+
headers?: Record<string, string | Buffer>;
|
|
55
|
+
timestamp?: string;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
/** Options for `createTopic()`. */
|
|
59
|
+
export interface CreateTopicOptions {
|
|
60
|
+
numPartitions?: number;
|
|
61
|
+
replicationFactor?: number;
|
|
62
|
+
}
|
|
63
|
+
/** Options for `subscribe()`. */
|
|
64
|
+
export interface SubscribeOptions {
|
|
65
|
+
/** Consumer group id. Defaults to a generated id. */
|
|
66
|
+
groupId?: string;
|
|
67
|
+
/** Consume from the beginning of the topic rather than the latest offset. */
|
|
68
|
+
fromBeginning?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* `KafkaStore` wraps a `kafkajs` client and exposes Kafka's core operations:
|
|
72
|
+
* producing messages, topic administration, and consumer subscriptions.
|
|
73
|
+
*/
|
|
74
|
+
export declare class KafkaStore implements NoSqlStore {
|
|
75
|
+
readonly name = "kafka";
|
|
76
|
+
readonly library = "kafkajs";
|
|
77
|
+
private readonly options;
|
|
78
|
+
private client;
|
|
79
|
+
private producer;
|
|
80
|
+
/** Consumers created via `subscribe()`, tracked so `disconnect()` can stop them all. */
|
|
81
|
+
private readonly consumers;
|
|
82
|
+
private connected;
|
|
83
|
+
constructor(options?: KafkaStoreOptions);
|
|
84
|
+
connect(): Promise<void>;
|
|
85
|
+
disconnect(): Promise<void>;
|
|
86
|
+
isConnected(): boolean;
|
|
87
|
+
/** Returns the underlying `kafkajs` `Kafka` client for anything not wrapped here. */
|
|
88
|
+
getClient(): any;
|
|
89
|
+
private requireClient;
|
|
90
|
+
private requireProducer;
|
|
91
|
+
/**
|
|
92
|
+
* Produce one or more messages to `topic`. Returns kafkajs's record
|
|
93
|
+
* metadata (per-partition base offsets).
|
|
94
|
+
*/
|
|
95
|
+
produce(topic: string, messages: KafkaMessage[]): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Create `topic` via a short-lived admin connection. Returns kafkajs's
|
|
98
|
+
* boolean indicating whether the topic was newly created (`false` if it
|
|
99
|
+
* already existed).
|
|
100
|
+
*/
|
|
101
|
+
createTopic(topic: string, opts?: CreateTopicOptions): Promise<boolean>;
|
|
102
|
+
/** List all topic names known to the cluster via a short-lived admin connection. */
|
|
103
|
+
listTopics(): Promise<string[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Subscribe a new consumer to `topics` and invoke `handler` for each
|
|
106
|
+
* message (kafkajs's `eachMessage` payload: `{ topic, partition, message }`).
|
|
107
|
+
* The consumer joins the group `options.groupId` (a generated id is used if
|
|
108
|
+
* omitted) and is tracked so `disconnect()` stops it. Returns the created
|
|
109
|
+
* kafkajs consumer.
|
|
110
|
+
*/
|
|
111
|
+
subscribe(topics: string | string[], handler: (payload: any) => Promise<void> | void, options?: SubscribeOptions): Promise<any>;
|
|
112
|
+
}
|
|
113
|
+
export default KafkaStore;
|