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
|
@@ -14,13 +14,25 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Uses the official `neo4j-driver` (Bolt protocol) driver.
|
|
16
16
|
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
18
|
exports.Neo4jStore = void 0;
|
|
22
19
|
exports.intToNumber = intToNumber;
|
|
23
|
-
|
|
20
|
+
// Lazily-loaded `neo4j-driver`. Required only when a connection is opened, so
|
|
21
|
+
// importing this ORM never loads the neo4j driver.
|
|
22
|
+
let neo4jModule = null;
|
|
23
|
+
function loadNeo4j() {
|
|
24
|
+
if (!neo4jModule) {
|
|
25
|
+
try {
|
|
26
|
+
neo4jModule = require('neo4j-driver');
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error("The 'neo4j-driver' package is required to use the Neo4j store but could not be loaded. " +
|
|
30
|
+
'Install it with `npm install neo4j-driver`. Original error: ' +
|
|
31
|
+
(err instanceof Error ? err.message : String(err)));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return neo4jModule;
|
|
35
|
+
}
|
|
24
36
|
const errors_1 = require("../../errors");
|
|
25
37
|
function wrapConnectionError(err, host) {
|
|
26
38
|
const parent = err instanceof Error ? err : new Error(String(err));
|
|
@@ -60,10 +72,10 @@ function mapValue(value) {
|
|
|
60
72
|
if (value === null || value === undefined) {
|
|
61
73
|
return value;
|
|
62
74
|
}
|
|
63
|
-
if (
|
|
75
|
+
if (loadNeo4j().isInt(value)) {
|
|
64
76
|
return intToNumber(value);
|
|
65
77
|
}
|
|
66
|
-
if (
|
|
78
|
+
if (loadNeo4j().isNode(value)) {
|
|
67
79
|
const node = value;
|
|
68
80
|
const mapped = {
|
|
69
81
|
elementId: node.elementId,
|
|
@@ -73,7 +85,7 @@ function mapValue(value) {
|
|
|
73
85
|
};
|
|
74
86
|
return mapped;
|
|
75
87
|
}
|
|
76
|
-
if (
|
|
88
|
+
if (loadNeo4j().isRelationship(value)) {
|
|
77
89
|
const rel = value;
|
|
78
90
|
const mapped = {
|
|
79
91
|
elementId: rel.elementId,
|
|
@@ -158,7 +170,7 @@ class Neo4jStore {
|
|
|
158
170
|
return this.options.auth;
|
|
159
171
|
}
|
|
160
172
|
if (this.options.username !== undefined || this.options.password !== undefined) {
|
|
161
|
-
return
|
|
173
|
+
return loadNeo4j().auth.basic(this.options.username ?? '', this.options.password ?? '');
|
|
162
174
|
}
|
|
163
175
|
return undefined;
|
|
164
176
|
}
|
|
@@ -168,7 +180,7 @@ class Neo4jStore {
|
|
|
168
180
|
}
|
|
169
181
|
let candidate = null;
|
|
170
182
|
try {
|
|
171
|
-
candidate =
|
|
183
|
+
candidate = loadNeo4j().driver(this.options.uri, this.resolveAuth(), this.options.config);
|
|
172
184
|
await candidate.verifyConnectivity(this.options.database ? { database: this.options.database } : undefined);
|
|
173
185
|
this.driverInstance = candidate;
|
|
174
186
|
this.connected = true;
|
|
@@ -218,7 +230,7 @@ class Neo4jStore {
|
|
|
218
230
|
const driver = this.requireDriver();
|
|
219
231
|
return driver.session({
|
|
220
232
|
database: options.database ?? this.options.database,
|
|
221
|
-
defaultAccessMode: options.defaultAccessMode === 'READ' ?
|
|
233
|
+
defaultAccessMode: options.defaultAccessMode === 'READ' ? loadNeo4j().session.READ : loadNeo4j().session.WRITE,
|
|
222
234
|
});
|
|
223
235
|
}
|
|
224
236
|
// ---------------------------------------------------------------------
|
|
@@ -360,11 +372,11 @@ class Neo4jStore {
|
|
|
360
372
|
const params = { ...where };
|
|
361
373
|
if (options.skip !== undefined) {
|
|
362
374
|
cypher += ' SKIP $skip';
|
|
363
|
-
params.skip =
|
|
375
|
+
params.skip = loadNeo4j().int(options.skip);
|
|
364
376
|
}
|
|
365
377
|
if (options.limit !== undefined) {
|
|
366
378
|
cypher += ' LIMIT $limit';
|
|
367
|
-
params.limit =
|
|
379
|
+
params.limit = loadNeo4j().int(options.limit);
|
|
368
380
|
}
|
|
369
381
|
const result = await this.run(cypher, params);
|
|
370
382
|
return result.records.map((record) => record.n);
|
|
@@ -430,11 +442,11 @@ class Neo4jStore {
|
|
|
430
442
|
const params = { ...where };
|
|
431
443
|
if (options.skip !== undefined) {
|
|
432
444
|
cypher += ' SKIP $skip';
|
|
433
|
-
params.skip =
|
|
445
|
+
params.skip = loadNeo4j().int(options.skip);
|
|
434
446
|
}
|
|
435
447
|
if (options.limit !== undefined) {
|
|
436
448
|
cypher += ' LIMIT $limit';
|
|
437
|
-
params.limit =
|
|
449
|
+
params.limit = loadNeo4j().int(options.limit);
|
|
438
450
|
}
|
|
439
451
|
const result = await this.run(cypher, params);
|
|
440
452
|
return result.records.map((record) => record.r);
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Amazon Neptune store.
|
|
3
|
+
*
|
|
4
|
+
* Neptune is a managed graph database: data is modeled as vertices and
|
|
5
|
+
* edges (plus their properties), queried by graph traversal, not by
|
|
6
|
+
* arbitrary `WHERE`-clause SQL. It has no joins, no relational schema, and
|
|
7
|
+
* no `query(sql)` shape, so — like the other stores in `src/nosql/` — this
|
|
8
|
+
* class does not implement the SQL-shaped `Dialect` interface
|
|
9
|
+
* (`src/dialects/dialect.ts`). Instead it implements the minimal
|
|
10
|
+
* `NoSqlStore` marker interface (`src/nosql/store.ts`) and exposes
|
|
11
|
+
* Neptune's own query model directly: Gremlin traversals.
|
|
12
|
+
*
|
|
13
|
+
* Neptune supports two graph query languages: Gremlin and openCypher.
|
|
14
|
+
* This store uses **Gremlin**, via the official `gremlin` npm package
|
|
15
|
+
* (Apache TinkerPop's JavaScript Gremlin Language Variant), because it is
|
|
16
|
+
* the more universally-supported path for Neptune from Node.js — the
|
|
17
|
+
* `gremlin` package speaks Neptune's Gremlin websocket protocol directly
|
|
18
|
+
* (`DriverRemoteConnection` for the fluent, bytecode-based traversal API;
|
|
19
|
+
* `Client` for raw Gremlin script submission).
|
|
20
|
+
*
|
|
21
|
+
* ## IAM authentication — read this before using in production
|
|
22
|
+
*
|
|
23
|
+
* Neptune clusters can require AWS IAM (SigV4) request signing on every
|
|
24
|
+
* Gremlin connection. **This store does NOT implement SigV4 signing.**
|
|
25
|
+
* Correctly signing a websocket handshake (canonical request, credential
|
|
26
|
+
* scope, signing key derivation, clock-skew-sensitive timestamps, and
|
|
27
|
+
* keeping all of that valid for the life of a persistent connection) is
|
|
28
|
+
* substantial, security-sensitive logic that is easy to get subtly wrong,
|
|
29
|
+
* and shipping a partial/approximate implementation would be worse than
|
|
30
|
+
* not shipping one — silent auth failures or, worse, requests that
|
|
31
|
+
* "happen to work" against a lenient test setup but fail against real
|
|
32
|
+
* Neptune are not an acceptable trade-off here.
|
|
33
|
+
*
|
|
34
|
+
* Instead, `NeptuneStoreOptions` supports two supported ways to connect:
|
|
35
|
+
*
|
|
36
|
+
* 1. **No auth** — Neptune clusters are frequently run inside a VPC with
|
|
37
|
+
* IAM database authentication *disabled*, relying on VPC/security-group
|
|
38
|
+
* isolation instead. Just supply `endpoint`/`url` and nothing else.
|
|
39
|
+
* 2. **Caller-supplied signed headers** — if the target cluster has IAM
|
|
40
|
+
* auth enabled, sign the request yourself (e.g. with
|
|
41
|
+
* `@aws-sdk/signature-v4` / `aws4`, or your own SigV4 helper) and pass
|
|
42
|
+
* the resulting headers via `options.headers` (static) or
|
|
43
|
+
* `options.authHeaderProvider` (called on every `connect()`, so it can
|
|
44
|
+
* mint a fresh signature — SigV4 signatures are timestamp-bound and a
|
|
45
|
+
* static one will eventually be rejected). This store passes those
|
|
46
|
+
* headers straight through to `DriverRemoteConnection`/`Client` via
|
|
47
|
+
* their `options.headers` field; it performs no signing of its own.
|
|
48
|
+
*
|
|
49
|
+
* See the README in this directory for a worked example of option 2.
|
|
50
|
+
*/
|
|
51
|
+
import { DatabaseError } from '../../errors';
|
|
52
|
+
import type { NoSqlStore } from '../store';
|
|
53
|
+
/** Anything Gremlin/Neptune accepts as an element ID: string, number, or a custom ID object. */
|
|
54
|
+
export type NeptuneId = string | number | Record<string, unknown>;
|
|
55
|
+
/** A vertex or edge normalized from Gremlin's `Map`/`Vertex`/`Edge` result shapes into a plain object. */
|
|
56
|
+
export interface NeptuneVertex<P extends Record<string, unknown> = Record<string, unknown>> {
|
|
57
|
+
id: NeptuneId;
|
|
58
|
+
label: string;
|
|
59
|
+
properties: P;
|
|
60
|
+
}
|
|
61
|
+
/** A normalized edge; `outV`/`inV` are the endpoint vertex IDs (the edge's tail/head). */
|
|
62
|
+
export interface NeptuneEdge<P extends Record<string, unknown> = Record<string, unknown>> {
|
|
63
|
+
id: NeptuneId;
|
|
64
|
+
label: string;
|
|
65
|
+
outV: NeptuneId;
|
|
66
|
+
inV: NeptuneId;
|
|
67
|
+
properties: P;
|
|
68
|
+
}
|
|
69
|
+
/** Filters shared by `findVertices()`/`findEdges()`. */
|
|
70
|
+
export interface ElementQueryOptions {
|
|
71
|
+
/** Restrict to a single label, i.e. a `hasLabel(label)` step. */
|
|
72
|
+
label?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Equality filters, one `has(key, value)` step per entry. All entries
|
|
75
|
+
* are ANDed together (Gremlin's default `has()` chaining behavior).
|
|
76
|
+
* For anything beyond flat equality (ranges, `P.within`, regex, OR
|
|
77
|
+
* logic), use `traversal()` directly.
|
|
78
|
+
*/
|
|
79
|
+
has?: Record<string, unknown>;
|
|
80
|
+
/** Caps the number of results, i.e. a `limit(n)` step. */
|
|
81
|
+
limit?: number;
|
|
82
|
+
}
|
|
83
|
+
/** Direction to traverse for `neighbors()`. */
|
|
84
|
+
export type NeptuneDirection = 'out' | 'in' | 'both';
|
|
85
|
+
/** Options for `neighbors()`. */
|
|
86
|
+
export interface NeighborOptions {
|
|
87
|
+
/** Defaults to `'out'`. */
|
|
88
|
+
direction?: NeptuneDirection;
|
|
89
|
+
/** Restrict to a single edge label. */
|
|
90
|
+
edgeLabel?: string;
|
|
91
|
+
limit?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Supplies pre-signed IAM auth headers (e.g. `Authorization`,
|
|
95
|
+
* `X-Amz-Date`, `X-Amz-Security-Token`) computed by the caller, called
|
|
96
|
+
* fresh on every `connect()` since SigV4 signatures are timestamp-bound.
|
|
97
|
+
* See the "IAM authentication" section above — this store does not sign
|
|
98
|
+
* requests itself.
|
|
99
|
+
*/
|
|
100
|
+
export type NeptuneAuthHeaderProvider = () => Record<string, string> | Promise<Record<string, string>>;
|
|
101
|
+
export interface NeptuneStoreOptions {
|
|
102
|
+
/**
|
|
103
|
+
* Neptune cluster/instance endpoint hostname, e.g.
|
|
104
|
+
* `'my-cluster.cluster-xxxxxxxxxxxx.us-east-1.neptune.amazonaws.com'`.
|
|
105
|
+
* Combined with `port` (default `8182`) and `useSsl` (default `true`)
|
|
106
|
+
* into a `wss://host:port/gremlin` URL. Ignored if `url` is set.
|
|
107
|
+
*/
|
|
108
|
+
endpoint?: string;
|
|
109
|
+
/** Port for `endpoint`. Defaults to `8182` (Neptune's default Gremlin websocket port). */
|
|
110
|
+
port?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Full connection URL, e.g. `'wss://my-endpoint:8182/gremlin'`. Takes
|
|
113
|
+
* precedence over `endpoint`/`port`/`useSsl` when set — use this for
|
|
114
|
+
* non-standard paths/ports or when connecting through a proxy/tunnel.
|
|
115
|
+
*/
|
|
116
|
+
url?: string;
|
|
117
|
+
/** Whether to use `wss://` (true, default) or plain `ws://` (local testing only — Neptune itself requires TLS). */
|
|
118
|
+
useSsl?: boolean;
|
|
119
|
+
/** Gremlin traversal source name on the server. Defaults to `'g'`. */
|
|
120
|
+
traversalSource?: string;
|
|
121
|
+
/** Verify the server's TLS certificate. Defaults to `true`; only disable for local/self-signed test setups. */
|
|
122
|
+
rejectUnauthorized?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Static pre-signed IAM auth headers, merged with (and overridden by)
|
|
125
|
+
* `authHeaderProvider`'s result if both are given. Omit entirely when
|
|
126
|
+
* connecting to a cluster with IAM auth disabled. See the "IAM
|
|
127
|
+
* authentication" section above.
|
|
128
|
+
*/
|
|
129
|
+
headers?: Record<string, string>;
|
|
130
|
+
/** Called on every `connect()` to obtain fresh pre-signed IAM auth headers. See the "IAM authentication" section above. */
|
|
131
|
+
authHeaderProvider?: NeptuneAuthHeaderProvider;
|
|
132
|
+
/**
|
|
133
|
+
* Passed straight through to the underlying `DriverRemoteConnection`/
|
|
134
|
+
* `Client` constructors for anything not covered above (`ca`, `cert`,
|
|
135
|
+
* `pfx`, `mimeType`, `agent`, `enableCompression`, ...).
|
|
136
|
+
*/
|
|
137
|
+
connectionOptions?: Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
/** `DatabaseError` subclass used for all Neptune/Gremlin failures wrapped by this store. */
|
|
140
|
+
export declare class NeptuneError extends DatabaseError {
|
|
141
|
+
constructor(message: string, options?: {
|
|
142
|
+
code?: import('../../errors').ErrorCode;
|
|
143
|
+
parent?: Error;
|
|
144
|
+
original?: string;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* `NeptuneStore` wraps the `gremlin` package's `DriverRemoteConnection`
|
|
149
|
+
* (fluent, bytecode-based traversals via a `GraphTraversalSource`, i.e.
|
|
150
|
+
* `g`) and `Client` (raw Gremlin script submission) to talk to Amazon
|
|
151
|
+
* Neptune, implementing the minimal `NoSqlStore` marker interface. Vertex/
|
|
152
|
+
* edge CRUD helpers below are convenience wrappers built on top of real
|
|
153
|
+
* Gremlin steps (`addV`/`addE`/`has`/`hasLabel`/`drop`/...) — for anything
|
|
154
|
+
* they don't cover, use `getClient()` (the raw `GraphTraversalSource`),
|
|
155
|
+
* `traversal()` (build an arbitrary traversal against `g`), or `submit()`
|
|
156
|
+
* (raw parameterized Gremlin script text).
|
|
157
|
+
*/
|
|
158
|
+
export declare class NeptuneStore implements NoSqlStore {
|
|
159
|
+
readonly name = "neptune";
|
|
160
|
+
readonly library = "gremlin";
|
|
161
|
+
private readonly options;
|
|
162
|
+
private connection;
|
|
163
|
+
private g;
|
|
164
|
+
private client;
|
|
165
|
+
private connected;
|
|
166
|
+
constructor(options?: NeptuneStoreOptions);
|
|
167
|
+
private resolveUrl;
|
|
168
|
+
private resolveHeaders;
|
|
169
|
+
connect(): Promise<void>;
|
|
170
|
+
private safeCloseAll;
|
|
171
|
+
disconnect(): Promise<void>;
|
|
172
|
+
isConnected(): boolean;
|
|
173
|
+
/** Returns the underlying `GraphTraversalSource` (`g`) for building traversals not wrapped below. */
|
|
174
|
+
getClient(): unknown;
|
|
175
|
+
/** Access to the raw `DriverRemoteConnection`, e.g. to inspect `isOpen` directly. */
|
|
176
|
+
getConnection(): unknown;
|
|
177
|
+
private requireG;
|
|
178
|
+
private requireClient;
|
|
179
|
+
/**
|
|
180
|
+
* Runs an arbitrary traversal built against `g` and Gremlin's anonymous
|
|
181
|
+
* traversal statics (`gremlin.process.statics`, e.g. `statics.V(id)` for
|
|
182
|
+
* nested traversals like `.to(statics.V(id))`), returning the fully
|
|
183
|
+
* materialized, normalized result list. This is the escape hatch for any
|
|
184
|
+
* Gremlin step this store doesn't wrap in a dedicated helper.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* const names = await store.traversal((g) => g.V().hasLabel('person').values('name'));
|
|
188
|
+
*/
|
|
189
|
+
traversal<T = unknown>(build: (g: unknown, statics: unknown) => unknown): Promise<T[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Submits a raw Gremlin script string via the driver's script-eval
|
|
192
|
+
* `Client` (as opposed to the fluent bytecode traversal `g` used
|
|
193
|
+
* elsewhere in this class), with `bindings` substituted server-side for
|
|
194
|
+
* named parameters in the script (e.g. `'g.V(id)'` with
|
|
195
|
+
* `{ id: '1' }`) — the standard way to parameterize Gremlin script text
|
|
196
|
+
* without string-concatenating untrusted values into it.
|
|
197
|
+
*/
|
|
198
|
+
submit<T = unknown>(script: string, bindings?: Record<string, unknown>): Promise<T[]>;
|
|
199
|
+
/** `addV(label)` + a `property(key, value)` step per entry in `properties`, returning the created vertex via `elementMap()`. */
|
|
200
|
+
addVertex<P extends Record<string, unknown> = Record<string, unknown>>(label: string, properties?: Record<string, unknown>): Promise<NeptuneVertex<P>>;
|
|
201
|
+
/** `g.V(id).elementMap().next()` — returns `undefined` if no vertex with that ID exists. */
|
|
202
|
+
getVertex<P extends Record<string, unknown> = Record<string, unknown>>(id: NeptuneId): Promise<NeptuneVertex<P> | undefined>;
|
|
203
|
+
/** `g.V()` filtered by `options.label`/`options.has`/`options.limit`, projected with `elementMap()`. */
|
|
204
|
+
findVertices<P extends Record<string, unknown> = Record<string, unknown>>(options?: ElementQueryOptions): Promise<NeptuneVertex<P>[]>;
|
|
205
|
+
/** Same filters as `findVertices()`, terminated with `count()` instead of materializing elements. */
|
|
206
|
+
countVertices(options?: ElementQueryOptions): Promise<number>;
|
|
207
|
+
/** `g.V(id)` + a `property(key, value)` step per entry in `properties` (existing properties keep their value unless overwritten here), returning the updated vertex. */
|
|
208
|
+
updateVertex<P extends Record<string, unknown> = Record<string, unknown>>(id: NeptuneId, properties: Record<string, unknown>): Promise<NeptuneVertex<P> | undefined>;
|
|
209
|
+
/** `g.V(id).drop().iterate()` — also drops any incident edges (Neptune cascades edge drops when their vertex is dropped). No-op (does not throw) if the vertex doesn't exist. */
|
|
210
|
+
dropVertex(id: NeptuneId): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* `g.V(fromId).addE(label).to(statics.V(toId))` + a `property(key, value)`
|
|
213
|
+
* step per entry in `properties`, returning the created edge via
|
|
214
|
+
* `elementMap()`. Throws a `NeptuneError` if `fromId`/`toId` don't
|
|
215
|
+
* resolve to existing vertices (same as real Gremlin `addE`/`to`).
|
|
216
|
+
*/
|
|
217
|
+
addEdge<P extends Record<string, unknown> = Record<string, unknown>>(fromId: NeptuneId, label: string, toId: NeptuneId, properties?: Record<string, unknown>): Promise<NeptuneEdge<P>>;
|
|
218
|
+
/** `g.E(id).elementMap().next()` — returns `undefined` if no edge with that ID exists. */
|
|
219
|
+
getEdge<P extends Record<string, unknown> = Record<string, unknown>>(id: NeptuneId): Promise<NeptuneEdge<P> | undefined>;
|
|
220
|
+
/** `g.E()` filtered by `options.label`/`options.has`/`options.limit`, projected with `elementMap()`. */
|
|
221
|
+
findEdges<P extends Record<string, unknown> = Record<string, unknown>>(options?: ElementQueryOptions): Promise<NeptuneEdge<P>[]>;
|
|
222
|
+
/** `g.E(id).drop().iterate()`. No-op (does not throw) if the edge doesn't exist. */
|
|
223
|
+
dropEdge(id: NeptuneId): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* `g.V(id).out(edgeLabel)` (or `.in_()`/`.both()` per `options.direction`,
|
|
226
|
+
* default `'out'`), projected with `elementMap()`. The common
|
|
227
|
+
* "one-hop neighbors" query — for multi-hop traversals, path-finding, or
|
|
228
|
+
* anything else Gremlin's step library covers beyond one hop, use
|
|
229
|
+
* `traversal()` directly.
|
|
230
|
+
*/
|
|
231
|
+
neighbors<P extends Record<string, unknown> = Record<string, unknown>>(id: NeptuneId, options?: NeighborOptions): Promise<NeptuneVertex<P>[]>;
|
|
232
|
+
private applyElementFilters;
|
|
233
|
+
}
|
|
234
|
+
export default NeptuneStore;
|
|
@@ -49,9 +49,6 @@
|
|
|
49
49
|
*
|
|
50
50
|
* See the README in this directory for a worked example of option 2.
|
|
51
51
|
*/
|
|
52
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
53
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
|
-
};
|
|
55
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
53
|
exports.NeptuneStore = exports.NeptuneError = void 0;
|
|
57
54
|
// The `gremlin` package ships no TypeScript declarations, so this import
|
|
@@ -59,7 +56,23 @@ exports.NeptuneStore = exports.NeptuneError = void 0;
|
|
|
59
56
|
// which is exactly the escape hatch intended for cases like this). All
|
|
60
57
|
// gremlin types used below (`GraphTraversalSource`, `Traversal`, ...) are
|
|
61
58
|
// therefore documented in comments rather than enforced by the compiler.
|
|
62
|
-
|
|
59
|
+
// Lazily-loaded `gremlin` package. Required only when a connection is opened,
|
|
60
|
+
// so importing this ORM never loads the gremlin driver. The package ships no
|
|
61
|
+
// TypeScript declarations, so the module is typed as `any` (see note above).
|
|
62
|
+
let gremlinModule = null;
|
|
63
|
+
function loadGremlin() {
|
|
64
|
+
if (!gremlinModule) {
|
|
65
|
+
try {
|
|
66
|
+
gremlinModule = require('gremlin');
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
throw new Error("The 'gremlin' package is required to use the Neptune store but could not be loaded. " +
|
|
70
|
+
'Install it with `npm install gremlin`. Original error: ' +
|
|
71
|
+
(err instanceof Error ? err.message : String(err)));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return gremlinModule;
|
|
75
|
+
}
|
|
63
76
|
const errors_1 = require("../../errors");
|
|
64
77
|
/** `DatabaseError` subclass used for all Neptune/Gremlin failures wrapped by this store. */
|
|
65
78
|
class NeptuneError extends errors_1.DatabaseError {
|
|
@@ -166,10 +179,11 @@ class NeptuneStore {
|
|
|
166
179
|
headers,
|
|
167
180
|
...this.options.connectionOptions,
|
|
168
181
|
};
|
|
169
|
-
|
|
182
|
+
const gremlinLib = loadGremlin();
|
|
183
|
+
this.connection = new gremlinLib.driver.DriverRemoteConnection(url, connectionOptions);
|
|
170
184
|
await this.connection.open();
|
|
171
|
-
this.g =
|
|
172
|
-
this.client = new
|
|
185
|
+
this.g = gremlinLib.process.AnonymousTraversalSource.traversal().with_(this.connection);
|
|
186
|
+
this.client = new gremlinLib.driver.Client(url, connectionOptions);
|
|
173
187
|
await this.client.open();
|
|
174
188
|
this.connected = true;
|
|
175
189
|
}
|
|
@@ -248,7 +262,7 @@ class NeptuneStore {
|
|
|
248
262
|
async traversal(build) {
|
|
249
263
|
const g = this.requireG();
|
|
250
264
|
try {
|
|
251
|
-
const t = build(g,
|
|
265
|
+
const t = build(g, loadGremlin().process.statics);
|
|
252
266
|
const list = await t.toList();
|
|
253
267
|
return list.map(normalizeValue);
|
|
254
268
|
}
|
|
@@ -373,7 +387,7 @@ class NeptuneStore {
|
|
|
373
387
|
async addEdge(fromId, label, toId, properties = {}) {
|
|
374
388
|
const g = this.requireG();
|
|
375
389
|
try {
|
|
376
|
-
let t = g.V(fromId).addE(label).to(
|
|
390
|
+
let t = g.V(fromId).addE(label).to(loadGremlin().process.statics.V(toId));
|
|
377
391
|
for (const [key, value] of Object.entries(properties)) {
|
|
378
392
|
t = t.property(key, value);
|
|
379
393
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NSQ topic/channel queue store.
|
|
3
|
+
*
|
|
4
|
+
* NSQ is a realtime distributed messaging platform. Producers `publish`
|
|
5
|
+
* messages to a *topic* via a `Writer`; consumers create a `Reader` bound to
|
|
6
|
+
* a topic + *channel* and handle each delivered message (calling
|
|
7
|
+
* `msg.finish()`/`msg.requeue()`). NSQ distributes a topic's messages across
|
|
8
|
+
* all channels, and load-balances within a channel. It is not a database and
|
|
9
|
+
* does not fit the SQL-shaped `Dialect` interface, so this class implements
|
|
10
|
+
* the minimal `NoSqlStore` marker interface and exposes NSQ's real
|
|
11
|
+
* publish/subscribe operations instead.
|
|
12
|
+
*
|
|
13
|
+
* Uses the `nsqjs` driver. It is an optional peer loaded lazily (via
|
|
14
|
+
* `require`) inside `connect()`, so importing this module does not require it
|
|
15
|
+
* to be installed unless you actually connect. A pre-built driver module
|
|
16
|
+
* (providing `Writer` and `Reader` constructors) can be injected via
|
|
17
|
+
* `NsqStoreOptions.client`, in which case `connect()` adopts it and skips the
|
|
18
|
+
* `require` entirely (used by the unit tests to inject mocks).
|
|
19
|
+
*/
|
|
20
|
+
import type { NoSqlStore } from '../store';
|
|
21
|
+
/** Connection options for `NsqStore`. */
|
|
22
|
+
export interface NsqStoreOptions {
|
|
23
|
+
/** nsqd host for the producer `Writer`. Defaults to `'127.0.0.1'`. */
|
|
24
|
+
nsqdHost?: string;
|
|
25
|
+
/** nsqd TCP port for the producer `Writer`. Defaults to `4150`. */
|
|
26
|
+
nsqdPort?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Reader connection options: typically `{ lookupdHTTPAddresses }` or
|
|
29
|
+
* `{ nsqdTCPAddresses }`. Passed straight to every `Reader`.
|
|
30
|
+
*/
|
|
31
|
+
readerOptions?: any;
|
|
32
|
+
/**
|
|
33
|
+
* A pre-built `nsqjs` module (or a stand-in exposing `Writer` and `Reader`
|
|
34
|
+
* constructors). When provided, `connect()` adopts it and does not
|
|
35
|
+
* `require('nsqjs')` — used for injecting mocks in tests.
|
|
36
|
+
*/
|
|
37
|
+
client?: any;
|
|
38
|
+
}
|
|
39
|
+
/** Options for `process()` (subscribing a Reader to a topic). */
|
|
40
|
+
export interface NsqProcessOptions {
|
|
41
|
+
/** The NSQ channel to consume on. Defaults to `'default'`. */
|
|
42
|
+
channel?: string;
|
|
43
|
+
/** Additional `nsqjs` Reader options, merged over `readerOptions`. */
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `NsqStore` wraps a single producer `Writer` plus a pool of consumer
|
|
48
|
+
* `Reader`s (keyed by `topic/channel`) and exposes the common queue surface.
|
|
49
|
+
* NSQ has no server-side job registry, so `getJob()`/`remove()` (which imply
|
|
50
|
+
* addressing a job by id) are not supported and throw.
|
|
51
|
+
*/
|
|
52
|
+
export declare class NsqStore implements NoSqlStore {
|
|
53
|
+
readonly name = "nsq";
|
|
54
|
+
readonly library = "nsqjs";
|
|
55
|
+
private readonly options;
|
|
56
|
+
private driver;
|
|
57
|
+
private writer;
|
|
58
|
+
private connected;
|
|
59
|
+
private readonly readers;
|
|
60
|
+
constructor(options?: NsqStoreOptions);
|
|
61
|
+
connect(): Promise<void>;
|
|
62
|
+
disconnect(): Promise<void>;
|
|
63
|
+
isConnected(): boolean;
|
|
64
|
+
/** Returns the underlying producer `Writer` for operations not wrapped here. */
|
|
65
|
+
getClient(): any;
|
|
66
|
+
private requireWriter;
|
|
67
|
+
/**
|
|
68
|
+
* Publish a message to a topic via the producer `Writer`. The payload is
|
|
69
|
+
* JSON-serialized (strings/Buffers pass through). NSQ does not return a
|
|
70
|
+
* client-visible job id, so this resolves to `null`.
|
|
71
|
+
*/
|
|
72
|
+
enqueue(queue: string, jobData: unknown): Promise<null>;
|
|
73
|
+
/**
|
|
74
|
+
* Subscribe a `Reader` to `queue` (topic) on a channel and invoke
|
|
75
|
+
* `handler(msg)` for each delivered message. One reader is cached per
|
|
76
|
+
* `topic/channel`; a repeat `process()` on the same pair returns it.
|
|
77
|
+
*/
|
|
78
|
+
process(queue: string, handler: (msg: any) => void | Promise<void>, opts?: NsqProcessOptions): Promise<any>;
|
|
79
|
+
/** Not supported: NSQ exposes no server-side lookup of a message by id. */
|
|
80
|
+
getJob(_queue: string, _id: string): Promise<never>;
|
|
81
|
+
/** Not supported: NSQ messages are acknowledged via `finish()`, not removed by id. */
|
|
82
|
+
remove(_queue: string, _id: string): Promise<never>;
|
|
83
|
+
/**
|
|
84
|
+
* Return a lightweight local view of consumers for a topic: the number of
|
|
85
|
+
* active `Reader`s this store has bound to it. (NSQ's authoritative stats
|
|
86
|
+
* live in nsqd's HTTP `/stats` endpoint, not the client library.)
|
|
87
|
+
*/
|
|
88
|
+
stats(queue: string): Promise<{
|
|
89
|
+
topic: string;
|
|
90
|
+
readers: number;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
export default NsqStore;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenSearch store implementation.
|
|
3
|
+
*
|
|
4
|
+
* OpenSearch is a distributed document store forked from Elasticsearch 7.10.
|
|
5
|
+
* Like Elasticsearch it is built around an inverted index and a JSON-based
|
|
6
|
+
* Query DSL (`match`/`term`/`bool`/`range` queries, aggregations, sorting)
|
|
7
|
+
* rather than SQL: no `JOIN`, no transaction log, schema-flexible documents.
|
|
8
|
+
* It therefore does not fit the SQL-shaped `Dialect` interface used by the
|
|
9
|
+
* SQL dialects in this repo. Instead it implements the minimal `NoSqlStore`
|
|
10
|
+
* marker interface (`src/nosql/store.ts`) and exposes OpenSearch's real
|
|
11
|
+
* capabilities grouped by concern: connection lifecycle, index management,
|
|
12
|
+
* document CRUD (single + bulk), and search.
|
|
13
|
+
*
|
|
14
|
+
* Uses the official `@opensearch-project/opensearch` driver. The driver is
|
|
15
|
+
* loaded lazily via `require` so importing this module does not force the
|
|
16
|
+
* dependency to be resolved unless an OpenSearch store is actually
|
|
17
|
+
* constructed. For unit-testing without a live cluster, the constructor also
|
|
18
|
+
* accepts an already-built `client`, which `connect()` will use as-is instead
|
|
19
|
+
* of instantiating a new one.
|
|
20
|
+
*
|
|
21
|
+
* Note: the OpenSearch client wraps every response in an envelope and puts
|
|
22
|
+
* the actual payload under `.body` (`{ body, statusCode, headers, meta }`),
|
|
23
|
+
* so each wrapper here reads through `response.body`.
|
|
24
|
+
*/
|
|
25
|
+
import { NoSqlStore } from '../store';
|
|
26
|
+
/**
|
|
27
|
+
* Connection options for `OpenSearchStore`.
|
|
28
|
+
*
|
|
29
|
+
* `node` (or `nodes`), `auth`, and `ssl` are passed straight through to the
|
|
30
|
+
* driver's `new Client(...)`. Pass `client` to inject an already-built client
|
|
31
|
+
* instance (used in tests and when the caller wants full control over driver
|
|
32
|
+
* configuration); when present, `node`/`auth`/`ssl` are ignored.
|
|
33
|
+
*/
|
|
34
|
+
export interface OpenSearchStoreOptions {
|
|
35
|
+
/** URL of a single OpenSearch node, e.g. `https://localhost:9200`. */
|
|
36
|
+
node?: string;
|
|
37
|
+
/** URLs of multiple OpenSearch nodes for client-side round-robin. */
|
|
38
|
+
nodes?: string | string[];
|
|
39
|
+
/** Basic-auth credentials (`{ username, password }`) or other driver-supported auth. */
|
|
40
|
+
auth?: Record<string, unknown>;
|
|
41
|
+
/** TLS options passed to the driver (e.g. `{ rejectUnauthorized: false }`). */
|
|
42
|
+
ssl?: Record<string, unknown>;
|
|
43
|
+
/** An already-constructed OpenSearch client to use instead of building one. */
|
|
44
|
+
client?: any;
|
|
45
|
+
/** Any additional options passed through to the driver's `Client`. */
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
/** A single operation for `bulk()`, in the driver's NDJSON action/source shape. */
|
|
49
|
+
export type BulkOperation = Record<string, unknown>;
|
|
50
|
+
/** Result of a `bulk()` call, mirroring the driver's response body. */
|
|
51
|
+
export interface BulkResult {
|
|
52
|
+
errors: boolean;
|
|
53
|
+
items: Record<string, unknown>[];
|
|
54
|
+
took: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `OpenSearchStore` wraps the official `@opensearch-project/opensearch`
|
|
58
|
+
* client and exposes index management, document CRUD (single + bulk), and
|
|
59
|
+
* Query-DSL search as a typed, promise-based API.
|
|
60
|
+
*/
|
|
61
|
+
export declare class OpenSearchStore implements NoSqlStore {
|
|
62
|
+
readonly name = "opensearch";
|
|
63
|
+
readonly library = "@opensearch-project/opensearch";
|
|
64
|
+
private readonly options;
|
|
65
|
+
private client;
|
|
66
|
+
private connected;
|
|
67
|
+
constructor(options: OpenSearchStoreOptions);
|
|
68
|
+
connect(): Promise<void>;
|
|
69
|
+
disconnect(): Promise<void>;
|
|
70
|
+
isConnected(): boolean;
|
|
71
|
+
/** Returns the underlying `@opensearch-project/opensearch` client for anything not wrapped here. */
|
|
72
|
+
getClient(): any;
|
|
73
|
+
private requireClient;
|
|
74
|
+
private exec;
|
|
75
|
+
/** Create an index, optionally with a body (mappings/settings/aliases). */
|
|
76
|
+
createIndex(index: string, body?: Record<string, unknown>): Promise<void>;
|
|
77
|
+
/** Delete an index. */
|
|
78
|
+
deleteIndex(index: string): Promise<void>;
|
|
79
|
+
/** Whether an index exists. */
|
|
80
|
+
indexExists(index: string): Promise<boolean>;
|
|
81
|
+
/** Index (create or overwrite) a document under an explicit `id`. */
|
|
82
|
+
indexDocument(index: string, id: string, body: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
83
|
+
/** Get a document's `_source` by ID. */
|
|
84
|
+
get<T = Record<string, unknown>>(index: string, id: string): Promise<T | undefined>;
|
|
85
|
+
/** Run a Query-DSL search and return the `hits` object from the response. */
|
|
86
|
+
search<T = Record<string, unknown>>(index: string, query: Record<string, unknown>): Promise<T>;
|
|
87
|
+
/** Delete a document by ID. */
|
|
88
|
+
deleteDocument(index: string, id: string): Promise<Record<string, unknown>>;
|
|
89
|
+
/**
|
|
90
|
+
* Run a batch of operations (already in the driver's NDJSON action/source
|
|
91
|
+
* array form) in a single request. The real `_bulk` API rejects an empty
|
|
92
|
+
* request body outright, so short-circuit zero operations to a trivial
|
|
93
|
+
* no-op result rather than surfacing that as an error.
|
|
94
|
+
*/
|
|
95
|
+
bulk(operations: BulkOperation[]): Promise<BulkResult>;
|
|
96
|
+
}
|
|
97
|
+
export default OpenSearchStore;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OrientDB store implementation for the Prorm NoSQL layer.
|
|
3
|
+
*
|
|
4
|
+
* OrientDB is a multi-model database combining document, graph, key/value and
|
|
5
|
+
* object models, queried with an extended SQL dialect over a session. While
|
|
6
|
+
* its query language is SQL-like, it does not fit Prorm's SQL-shaped
|
|
7
|
+
* `Dialect` interface (no shared identifier escaping / DDL builder), so this
|
|
8
|
+
* class implements the minimal `NoSqlStore` marker interface for connection
|
|
9
|
+
* lifecycle and exposes OrientDB's real session `command`/`query` API through
|
|
10
|
+
* a small document-CRUD convenience layer.
|
|
11
|
+
*
|
|
12
|
+
* Uses the official `orientjs` driver. That driver is an optional peer
|
|
13
|
+
* dependency and is loaded lazily inside `connect()` so importing this module
|
|
14
|
+
* never requires it to be installed. Tests inject a pre-built mock session via
|
|
15
|
+
* `options.client`, which bypasses the lazy `require` entirely - no real
|
|
16
|
+
* driver and no network are needed.
|
|
17
|
+
*/
|
|
18
|
+
import { NoSqlStore } from '../store';
|
|
19
|
+
/** A native OrientDB session/db handle, left untyped because the driver is an
|
|
20
|
+
* optional dependency not imported here. */
|
|
21
|
+
type OrientSession = any;
|
|
22
|
+
/**
|
|
23
|
+
* Connection options for `OrientDbStore`.
|
|
24
|
+
*
|
|
25
|
+
* `host`/`port` locate the server; `database`/`username`/`password` open a
|
|
26
|
+
* session against a specific database. When a pre-built `client` (an open
|
|
27
|
+
* session) is supplied (e.g. in tests), `connect()` uses it directly and skips
|
|
28
|
+
* loading the `orientjs` driver.
|
|
29
|
+
*/
|
|
30
|
+
export interface OrientDbStoreOptions {
|
|
31
|
+
host?: string;
|
|
32
|
+
port?: number;
|
|
33
|
+
database?: string;
|
|
34
|
+
username?: string;
|
|
35
|
+
password?: string;
|
|
36
|
+
/** A pre-built OrientDB session to use instead of the driver. */
|
|
37
|
+
client?: OrientSession;
|
|
38
|
+
}
|
|
39
|
+
/** Options accepted by {@link OrientDbStore.query}. */
|
|
40
|
+
export interface OrientDbQueryOptions {
|
|
41
|
+
/** Named/positional parameters bound into the statement. */
|
|
42
|
+
params?: Record<string, unknown> | unknown[];
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
export declare class OrientDbStore implements NoSqlStore {
|
|
46
|
+
readonly name = "orientdb";
|
|
47
|
+
readonly library = "orientjs";
|
|
48
|
+
private readonly options;
|
|
49
|
+
private orientClient;
|
|
50
|
+
private session;
|
|
51
|
+
private connected;
|
|
52
|
+
constructor(options?: OrientDbStoreOptions);
|
|
53
|
+
connect(): Promise<void>;
|
|
54
|
+
disconnect(): Promise<void>;
|
|
55
|
+
isConnected(): boolean;
|
|
56
|
+
getClient(): OrientSession;
|
|
57
|
+
private requireSession;
|
|
58
|
+
/** Insert a document into `collection` (class); returns its `@rid`/id. */
|
|
59
|
+
insert(collection: string, doc: Record<string, unknown>): Promise<unknown>;
|
|
60
|
+
/** Fetch a document by `@rid`. */
|
|
61
|
+
get(collection: string, id: string): Promise<unknown>;
|
|
62
|
+
/** Merge `patch` into an existing document identified by `@rid`. */
|
|
63
|
+
update(collection: string, id: string, patch: Record<string, unknown>): Promise<unknown>;
|
|
64
|
+
/** Delete a document identified by `@rid`. */
|
|
65
|
+
delete(collection: string, id: string): Promise<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Run an OrientDB SQL `statement` and return the resulting rows.
|
|
68
|
+
* `options.params` binds parameters into the statement.
|
|
69
|
+
*/
|
|
70
|
+
query(collection: string, statement: string, options?: OrientDbQueryOptions): Promise<unknown[]>;
|
|
71
|
+
}
|
|
72
|
+
export default OrientDbStore;
|