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,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Decorator
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive decorator that applies multiple compliance controls to a model
|
|
5
|
+
* based on a list of security frameworks. Works with the 12 compliance classes.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* @Security({
|
|
9
|
+
* frameworks: ['GDPR', 'HIPAA', 'PCI_DSS'],
|
|
10
|
+
* audit: true,
|
|
11
|
+
* encrypt: ['ssn', 'creditCard'],
|
|
12
|
+
* mask: { ssn: 'ssn', creditCard: 'card-last4' },
|
|
13
|
+
* retention: { years: 7 },
|
|
14
|
+
* })
|
|
15
|
+
* class User extends Model { ... }
|
|
16
|
+
*
|
|
17
|
+
* @Security({
|
|
18
|
+
* frameworks: ['SOX', 'SEC_17A_4'],
|
|
19
|
+
* immutable: true,
|
|
20
|
+
* })
|
|
21
|
+
* class FinancialRecord extends Model { ... }
|
|
22
|
+
*/
|
|
23
|
+
import { RetentionDuration } from './data-retention';
|
|
24
|
+
/**
|
|
25
|
+
* All supported security/compliance frameworks.
|
|
26
|
+
* These map to the 218+ frameworks in docs/sec/SECURITY_COMPLIANCE.md
|
|
27
|
+
*/
|
|
28
|
+
export declare const SecurityFramework: {
|
|
29
|
+
readonly GDPR: "GDPR";
|
|
30
|
+
readonly CCPA: "CCPA";
|
|
31
|
+
readonly CPRA: "CPRA";
|
|
32
|
+
readonly PIPEDA: "PIPEDA";
|
|
33
|
+
readonly LGPD: "LGPD";
|
|
34
|
+
readonly APPI: "APPI";
|
|
35
|
+
readonly PIPA: "PIPA";
|
|
36
|
+
readonly PIPL: "PIPL";
|
|
37
|
+
readonly DPDP: "DPDP";
|
|
38
|
+
readonly PDPA_THAILAND: "PDPA_Thailand";
|
|
39
|
+
readonly PDPA_SINGAPORE: "PDPA_Singapore";
|
|
40
|
+
readonly PDPA_PHILIPPINES: "PDPA_Philippines";
|
|
41
|
+
readonly PDPA_MALAYSIA: "PDPA_Malaysia";
|
|
42
|
+
readonly PDPA_INDONESIA: "PDPA_Indonesia";
|
|
43
|
+
readonly PDPA_VIETNAM: "PDPA_Vietnam";
|
|
44
|
+
readonly POPI: "PoPI";
|
|
45
|
+
readonly NDPR: "NDPR";
|
|
46
|
+
readonly KVKK: "KVKK";
|
|
47
|
+
readonly UK_GDPR: "UK_GDPR";
|
|
48
|
+
readonly PCI_DSS: "PCI_DSS";
|
|
49
|
+
readonly SOX: "SOX";
|
|
50
|
+
readonly GLBA: "GLBA";
|
|
51
|
+
readonly MIDIF_II: "MiFID_II";
|
|
52
|
+
readonly EMIR: "EMIR";
|
|
53
|
+
readonly BASEL_III: "Basel_III";
|
|
54
|
+
readonly DODD_FRANK: "Dodd_Frank";
|
|
55
|
+
readonly SEC_17A_4: "SEC_17a_4";
|
|
56
|
+
readonly FINRA: "FINRA";
|
|
57
|
+
readonly NYDFS: "NYDFS";
|
|
58
|
+
readonly DORA: "DORA";
|
|
59
|
+
readonly HIPAA: "HIPAA";
|
|
60
|
+
readonly HITRUST: "HITRUST";
|
|
61
|
+
readonly CFR_21_PART_11: "21_CFR_Part_11";
|
|
62
|
+
readonly EU_ANNEX_11: "EU_Annex_11";
|
|
63
|
+
readonly ALCOA_PLUS: "ALCOA+";
|
|
64
|
+
readonly GAMP_5: "GAMP_5";
|
|
65
|
+
readonly ICH_E6_GCP: "ICH_E6_GCP";
|
|
66
|
+
readonly DISHA: "DISHA";
|
|
67
|
+
readonly FEDRAMP: "FedRAMP";
|
|
68
|
+
readonly FISMA: "FISMA";
|
|
69
|
+
readonly NIST_800_53: "NIST_SP_800_53";
|
|
70
|
+
readonly NIST_800_171: "NIST_SP_800_171";
|
|
71
|
+
readonly NIST_CSF: "NIST_CSF";
|
|
72
|
+
readonly CMMC: "CMMC";
|
|
73
|
+
readonly DFARS: "DFARS";
|
|
74
|
+
readonly ITAR: "ITAR";
|
|
75
|
+
readonly CJIS: "CJIS";
|
|
76
|
+
readonly NERC_CIP: "NERC_CIP";
|
|
77
|
+
readonly ISO_27001: "ISO_27001";
|
|
78
|
+
readonly ISO_27017: "ISO_27017";
|
|
79
|
+
readonly ISO_27018: "ISO_27018";
|
|
80
|
+
readonly ISO_27701: "ISO_27701";
|
|
81
|
+
readonly ISO_22301: "ISO_22301";
|
|
82
|
+
readonly SOC_2: "SOC_2";
|
|
83
|
+
readonly SOC_1: "SOC_1";
|
|
84
|
+
readonly CIS_CONTROLS: "CIS_Controls";
|
|
85
|
+
readonly OWASP_TOP_10: "OWASP_Top_10";
|
|
86
|
+
readonly CLOUD_ACT: "CLOUD_Act";
|
|
87
|
+
readonly SCHREMS_II: "Schrems_II";
|
|
88
|
+
readonly ESSENTIAL_EIGHT: "Essential_Eight";
|
|
89
|
+
readonly IT_GRUNDSCHUTZ: "IT_Grundschutz";
|
|
90
|
+
};
|
|
91
|
+
export type SecurityFrameworkType = typeof SecurityFramework[keyof typeof SecurityFramework];
|
|
92
|
+
/**
|
|
93
|
+
* Set of all valid security framework names.
|
|
94
|
+
* Use for validation: `if (AllFrameworks.has(myFramework)) { ... }`
|
|
95
|
+
*/
|
|
96
|
+
export declare const AllFrameworks: Set<SecurityFrameworkType>;
|
|
97
|
+
/**
|
|
98
|
+
* Map of framework category to framework names.
|
|
99
|
+
* Useful for UI dropdowns or grouped validation.
|
|
100
|
+
*/
|
|
101
|
+
export declare const FrameworkCategories: Record<string, SecurityFrameworkType[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Validate that a framework name is valid.
|
|
104
|
+
*
|
|
105
|
+
* @param framework - Framework name to validate
|
|
106
|
+
* @returns true if valid, false otherwise
|
|
107
|
+
*/
|
|
108
|
+
export declare function isValidFramework(framework: string): framework is SecurityFrameworkType;
|
|
109
|
+
/**
|
|
110
|
+
* Get the category for a specific framework.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getFrameworkCategory(framework: SecurityFrameworkType): string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Get all frameworks as an array.
|
|
115
|
+
*/
|
|
116
|
+
export declare function getAllFrameworks(): SecurityFrameworkType[];
|
|
117
|
+
/**
|
|
118
|
+
* Get framework count.
|
|
119
|
+
*/
|
|
120
|
+
export declare const FrameworkCount: number;
|
|
121
|
+
/**
|
|
122
|
+
* Map of framework to its required security controls.
|
|
123
|
+
* Used internally to determine which controls to apply.
|
|
124
|
+
*/
|
|
125
|
+
export declare const FrameworkRequirements: Record<SecurityFrameworkType, {
|
|
126
|
+
audit?: boolean;
|
|
127
|
+
encryption?: boolean;
|
|
128
|
+
retention?: boolean;
|
|
129
|
+
masking?: boolean;
|
|
130
|
+
immutable?: boolean;
|
|
131
|
+
consent?: boolean;
|
|
132
|
+
rls?: boolean;
|
|
133
|
+
pseudonymize?: boolean;
|
|
134
|
+
classification?: boolean;
|
|
135
|
+
tls?: boolean;
|
|
136
|
+
lineage?: boolean;
|
|
137
|
+
breachDetection?: boolean;
|
|
138
|
+
sessionIsolation?: boolean;
|
|
139
|
+
worm?: boolean;
|
|
140
|
+
rateLimit?: boolean;
|
|
141
|
+
sensitiveDataDiscovery?: boolean;
|
|
142
|
+
crossBorderLog?: boolean;
|
|
143
|
+
consentVersioning?: boolean;
|
|
144
|
+
dsar?: boolean;
|
|
145
|
+
pia?: boolean;
|
|
146
|
+
backupVerification?: boolean;
|
|
147
|
+
queryFirewall?: boolean;
|
|
148
|
+
}>;
|
|
149
|
+
export interface SecurityOptions {
|
|
150
|
+
/**
|
|
151
|
+
* List of compliance frameworks to apply.
|
|
152
|
+
* Used to automatically determine which controls are needed.
|
|
153
|
+
*/
|
|
154
|
+
frameworks?: SecurityFrameworkType[];
|
|
155
|
+
/**
|
|
156
|
+
* Enable audit trail (logs all CRUD operations).
|
|
157
|
+
*/
|
|
158
|
+
audit?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Fields to encrypt (AES-256-GCM).
|
|
161
|
+
*/
|
|
162
|
+
encrypt?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* Fields to mask in query output.
|
|
165
|
+
* Key = field name, Value = masking pattern.
|
|
166
|
+
*/
|
|
167
|
+
mask?: Record<string, 'ssn' | 'card-last4' | 'card-first6' | 'email' | 'phone' | 'full'>;
|
|
168
|
+
/**
|
|
169
|
+
* Data retention policy.
|
|
170
|
+
*/
|
|
171
|
+
retention?: RetentionDuration;
|
|
172
|
+
/**
|
|
173
|
+
* Make records immutable (append-only, no UPDATE/DELETE).
|
|
174
|
+
*/
|
|
175
|
+
immutable?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Enable soft versioning for immutable records.
|
|
178
|
+
*/
|
|
179
|
+
versioning?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Row-level security scope selector.
|
|
182
|
+
* Function that returns query filters based on security context.
|
|
183
|
+
*/
|
|
184
|
+
rls?: (ctx: any) => {
|
|
185
|
+
where?: Record<string, any>;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Fields to auto-classify as sensitive (PII, PHI, PCI, etc.).
|
|
189
|
+
*/
|
|
190
|
+
classify?: Record<string, 'PII' | 'PHI' | 'PCI' | 'FINANCIAL' | 'HEALTH' | 'BIOMETRIC'>;
|
|
191
|
+
/**
|
|
192
|
+
* Auto-discover sensitive fields based on field name patterns.
|
|
193
|
+
*/
|
|
194
|
+
autoClassify?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Custom user ID getter for audit trail.
|
|
197
|
+
*/
|
|
198
|
+
getUserId?: () => string | number | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Custom IP address getter for audit trail.
|
|
201
|
+
*/
|
|
202
|
+
getIpAddress?: () => string | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Enable data lineage tracking (track data origin and transformations).
|
|
205
|
+
*/
|
|
206
|
+
lineage?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Enable breach detection (monitor for unusual access patterns).
|
|
209
|
+
*/
|
|
210
|
+
breachDetection?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Enable session isolation (multi-tenant data isolation).
|
|
213
|
+
*/
|
|
214
|
+
sessionIsolation?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Enable WORM storage (Write Once Read Many, immutable archival).
|
|
217
|
+
*/
|
|
218
|
+
worm?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Field name that holds the tenant ID, used when session isolation is enabled.
|
|
221
|
+
* Default: 'tenantId'.
|
|
222
|
+
*/
|
|
223
|
+
tenantIdField?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Enable rate limiting on this model.
|
|
226
|
+
*/
|
|
227
|
+
rateLimit?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Enable automatic sensitive data discovery.
|
|
230
|
+
*/
|
|
231
|
+
sensitiveDataDiscovery?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Enable cross-border data transfer logging.
|
|
234
|
+
*/
|
|
235
|
+
crossBorderLog?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Enable consent versioning.
|
|
238
|
+
*/
|
|
239
|
+
consentVersioning?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Enable DSAR (Data Subject Access Request) workflow support.
|
|
242
|
+
*/
|
|
243
|
+
dsar?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Enable privacy impact assessment tracking.
|
|
246
|
+
*/
|
|
247
|
+
pia?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Enable backup verification.
|
|
250
|
+
*/
|
|
251
|
+
backupVerification?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Enable query firewall protections.
|
|
254
|
+
*/
|
|
255
|
+
queryFirewall?: boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Apply security controls to a model based on specified frameworks.
|
|
259
|
+
*
|
|
260
|
+
* @param options - Security configuration
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* @Security({
|
|
264
|
+
* frameworks: ['GDPR', 'HIPAA', 'PCI_DSS'],
|
|
265
|
+
* audit: true,
|
|
266
|
+
* encrypt: ['ssn', 'creditCard'],
|
|
267
|
+
* mask: { ssn: 'ssn', creditCard: 'card-last4' },
|
|
268
|
+
* retention: { years: 7 },
|
|
269
|
+
* autoClassify: true,
|
|
270
|
+
* })
|
|
271
|
+
* class Patient extends Model { ... }
|
|
272
|
+
*/
|
|
273
|
+
export declare function Security(options: SecurityOptions): (target: any) => void;
|
|
274
|
+
/**
|
|
275
|
+
* Apply all security hooks to a model after it's been defined.
|
|
276
|
+
* Call this after Model.init() or prorm.define().
|
|
277
|
+
*
|
|
278
|
+
* @param Model - The model class
|
|
279
|
+
* @param prorm - The Prorm instance (required for audit)
|
|
280
|
+
*/
|
|
281
|
+
export declare function setupSecurity(Model: any, prorm?: any): void;
|
|
282
|
+
/**
|
|
283
|
+
* Apply security to all models in a Prorm instance.
|
|
284
|
+
*/
|
|
285
|
+
export declare function setupAllSecurity(prorm: any): void;
|
|
286
|
+
export interface TableSecurityOptions {
|
|
287
|
+
/**
|
|
288
|
+
* Database name this table belongs to (for multi-tenant setups).
|
|
289
|
+
*/
|
|
290
|
+
database?: string;
|
|
291
|
+
/**
|
|
292
|
+
* Schema name (PostgreSQL/MySQL schema).
|
|
293
|
+
*/
|
|
294
|
+
schema?: string;
|
|
295
|
+
/**
|
|
296
|
+
* Tables this table depends on (for cascade operations).
|
|
297
|
+
*/
|
|
298
|
+
dependsOn?: string[];
|
|
299
|
+
/**
|
|
300
|
+
* Data classification level for the entire table.
|
|
301
|
+
*/
|
|
302
|
+
classification?: 'PUBLIC' | 'INTERNAL' | 'CONFIDENTIAL' | 'SECRET' | 'TOP_SECRET';
|
|
303
|
+
/**
|
|
304
|
+
* Row-level security enabled for this table.
|
|
305
|
+
*/
|
|
306
|
+
rlsEnabled?: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Tables in this schema that require audit.
|
|
309
|
+
*/
|
|
310
|
+
auditEnabled?: boolean;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Apply table-level security metadata.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* @Table({
|
|
317
|
+
* schema: 'financial',
|
|
318
|
+
* classification: 'CONFIDENTIAL',
|
|
319
|
+
* rlsEnabled: true,
|
|
320
|
+
* })
|
|
321
|
+
* class Transaction extends Model { ... }
|
|
322
|
+
*/
|
|
323
|
+
export declare function Table(options?: TableSecurityOptions): (target: any) => void;
|
|
324
|
+
export interface DatabaseSecurityOptions {
|
|
325
|
+
/**
|
|
326
|
+
* Database name.
|
|
327
|
+
*/
|
|
328
|
+
name: string;
|
|
329
|
+
/**
|
|
330
|
+
* Geographic region (for data localization compliance).
|
|
331
|
+
*/
|
|
332
|
+
region?: string;
|
|
333
|
+
/**
|
|
334
|
+
* Default classification for new tables.
|
|
335
|
+
*/
|
|
336
|
+
defaultClassification?: 'PUBLIC' | 'INTERNAL' | 'CONFIDENTIAL' | 'SECRET' | 'TOP_SECRET';
|
|
337
|
+
/**
|
|
338
|
+
* Require TLS for all connections.
|
|
339
|
+
*/
|
|
340
|
+
requireTLS?: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Enable audit logging for all tables by default.
|
|
343
|
+
*/
|
|
344
|
+
defaultAudit?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Default retention period for new tables.
|
|
347
|
+
*/
|
|
348
|
+
defaultRetention?: RetentionDuration;
|
|
349
|
+
/**
|
|
350
|
+
* Allowed countries for data storage (data localization).
|
|
351
|
+
*/
|
|
352
|
+
allowedCountries?: string[];
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Apply database-level security metadata.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* @Database({
|
|
359
|
+
* name: 'healthcare_db',
|
|
360
|
+
* region: 'us-east-1',
|
|
361
|
+
* classification: 'CONFIDENTIAL',
|
|
362
|
+
* requireTLS: true,
|
|
363
|
+
* defaultAudit: true,
|
|
364
|
+
* allowedCountries: ['US'],
|
|
365
|
+
* })
|
|
366
|
+
* class HealthcareDB extends Model { ... }
|
|
367
|
+
*/
|
|
368
|
+
export declare function Database(options: DatabaseSecurityOptions): (target: any) => void;
|
|
369
|
+
/**
|
|
370
|
+
* Get table security options from a model.
|
|
371
|
+
*/
|
|
372
|
+
export declare function getTableSecurity(Model: any): TableSecurityOptions | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Get database security options from a model.
|
|
375
|
+
*/
|
|
376
|
+
export declare function getDatabaseSecurity(Model: any): DatabaseSecurityOptions | undefined;
|
|
377
|
+
/**
|
|
378
|
+
* Get the frameworks applied to a model.
|
|
379
|
+
*/
|
|
380
|
+
export declare function getSecurityFrameworks(Model: any): SecurityFrameworkType[];
|
|
381
|
+
/**
|
|
382
|
+
* Check if a model has audit enabled.
|
|
383
|
+
*/
|
|
384
|
+
export declare function hasAudit(Model: any): boolean;
|
|
385
|
+
/**
|
|
386
|
+
* Check if a model is immutable.
|
|
387
|
+
*/
|
|
388
|
+
export declare function isImmutableModel(Model: any): boolean;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTAT - Monitoring and Threat Assessment Tool
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive security monitoring system that:
|
|
5
|
+
* - Screens SQL logs for suspicious patterns
|
|
6
|
+
* - Flags security-relevant events
|
|
7
|
+
* - Monitors compliance violations (invalid data movement)
|
|
8
|
+
* - Tracks slow/invalid queries
|
|
9
|
+
* - Provides real-time alerts
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* // Initialize with the MTAT monitor
|
|
13
|
+
* const monitor = new SecurityMonitor(prorm, {
|
|
14
|
+
* frameworks: ['GDPR', 'HIPAA'],
|
|
15
|
+
* alertLevel: 'high',
|
|
16
|
+
* onAlert: (alert) => console.log('Security Alert:', alert),
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Start monitoring
|
|
20
|
+
* await monitor.start();
|
|
21
|
+
*
|
|
22
|
+
* // Query the dashboard
|
|
23
|
+
* const stats = monitor.getStats();
|
|
24
|
+
* const alerts = monitor.getAlerts();
|
|
25
|
+
*/
|
|
26
|
+
import { Prorm } from '../prorm';
|
|
27
|
+
export type AlertSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
28
|
+
export type AlertCategory = 'sql_injection' | 'data_exfiltration' | 'unauthorized_access' | 'compliance_violation' | 'slow_query' | 'invalid_query' | 'anomaly' | 'rate_limit' | 'bulk_operation' | 'sensitive_access';
|
|
29
|
+
export interface SecurityAlert {
|
|
30
|
+
id: string;
|
|
31
|
+
timestamp: Date;
|
|
32
|
+
severity: AlertSeverity;
|
|
33
|
+
category: AlertCategory;
|
|
34
|
+
message: string;
|
|
35
|
+
details: Record<string, any>;
|
|
36
|
+
query?: string;
|
|
37
|
+
stackTrace?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SecurityMonitorOptions {
|
|
40
|
+
/** Active compliance frameworks */
|
|
41
|
+
frameworks?: string[];
|
|
42
|
+
/** Minimum severity level to alert on */
|
|
43
|
+
alertLevel?: AlertSeverity;
|
|
44
|
+
/** Callback for real-time alerts */
|
|
45
|
+
onAlert?: (alert: SecurityAlert) => void;
|
|
46
|
+
/** Enable SQL injection detection */
|
|
47
|
+
detectSQLInjection?: boolean;
|
|
48
|
+
/** Enable slow query monitoring */
|
|
49
|
+
monitorSlowQueries?: boolean;
|
|
50
|
+
/** Slow query threshold in ms */
|
|
51
|
+
slowQueryThreshold?: number;
|
|
52
|
+
/** Enable data exfiltration detection */
|
|
53
|
+
detectExfiltration?: boolean;
|
|
54
|
+
/** Enable compliance violation detection */
|
|
55
|
+
detectComplianceViolations?: boolean;
|
|
56
|
+
/** Maximum alerts to keep in memory */
|
|
57
|
+
maxAlerts?: number;
|
|
58
|
+
/** Rate limit (queries per minute) per user */
|
|
59
|
+
rateLimitThreshold?: number;
|
|
60
|
+
/** Enable anomaly detection */
|
|
61
|
+
detectAnomalies?: boolean;
|
|
62
|
+
/** Bulk operation threshold */
|
|
63
|
+
bulkOperationThreshold?: number;
|
|
64
|
+
}
|
|
65
|
+
export declare class SecurityMonitor {
|
|
66
|
+
private prorm;
|
|
67
|
+
private options;
|
|
68
|
+
private alerts;
|
|
69
|
+
private queryCount;
|
|
70
|
+
private slowQueryCount;
|
|
71
|
+
private blockedCount;
|
|
72
|
+
private startTime;
|
|
73
|
+
private isRunning;
|
|
74
|
+
private originalQuery;
|
|
75
|
+
constructor(prorm: Prorm, options?: SecurityMonitorOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Start monitoring queries
|
|
78
|
+
*/
|
|
79
|
+
start(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Stop monitoring
|
|
82
|
+
*/
|
|
83
|
+
stop(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Setup hooks for model-level monitoring
|
|
86
|
+
*/
|
|
87
|
+
private setupHooks;
|
|
88
|
+
/**
|
|
89
|
+
* Analyze a query for security issues
|
|
90
|
+
*/
|
|
91
|
+
private analyzeQuery;
|
|
92
|
+
/**
|
|
93
|
+
* Analyze errors for security issues
|
|
94
|
+
*/
|
|
95
|
+
private analyzeError;
|
|
96
|
+
/**
|
|
97
|
+
* Internal query analysis
|
|
98
|
+
*/
|
|
99
|
+
private analyzeQueryInternal;
|
|
100
|
+
/**
|
|
101
|
+
* Check for compliance violations
|
|
102
|
+
*/
|
|
103
|
+
private checkComplianceViolationDetection;
|
|
104
|
+
/**
|
|
105
|
+
* Add an alert
|
|
106
|
+
*/
|
|
107
|
+
private addAlert;
|
|
108
|
+
/**
|
|
109
|
+
* Get current statistics
|
|
110
|
+
*/
|
|
111
|
+
getStats(): {
|
|
112
|
+
uptime: number;
|
|
113
|
+
totalQueries: number;
|
|
114
|
+
slowQueries: number;
|
|
115
|
+
blockedQueries: number;
|
|
116
|
+
totalAlerts: number;
|
|
117
|
+
alertsBySeverity: Record<AlertSeverity, number>;
|
|
118
|
+
alertsByCategory: Record<AlertCategory, number>;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Get all alerts
|
|
122
|
+
*/
|
|
123
|
+
getAlerts(options?: {
|
|
124
|
+
severity?: AlertSeverity;
|
|
125
|
+
category?: AlertCategory;
|
|
126
|
+
limit?: number;
|
|
127
|
+
}): SecurityAlert[];
|
|
128
|
+
/**
|
|
129
|
+
* Get critical alerts
|
|
130
|
+
*/
|
|
131
|
+
getCriticalAlerts(): SecurityAlert[];
|
|
132
|
+
/**
|
|
133
|
+
* Clear all alerts
|
|
134
|
+
*/
|
|
135
|
+
clearAlerts(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Check if running
|
|
138
|
+
*/
|
|
139
|
+
isActive(): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Manual alert trigger (for custom security checks)
|
|
142
|
+
*/
|
|
143
|
+
alert(options: Omit<SecurityAlert, 'id' | 'timestamp'>): void;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create or get the global security monitor singleton
|
|
147
|
+
*/
|
|
148
|
+
export declare function getGlobalMonitor(): SecurityMonitor | null;
|
|
149
|
+
/**
|
|
150
|
+
* Initialize the global security monitor
|
|
151
|
+
*/
|
|
152
|
+
export declare function initSecurityMonitor(prorm: Prorm, options?: SecurityMonitorOptions): SecurityMonitor;
|
|
153
|
+
/**
|
|
154
|
+
* Quick security check for a query (static method)
|
|
155
|
+
*/
|
|
156
|
+
export declare function analyzeQuerySecurity(query: string): {
|
|
157
|
+
isSQLInjection: boolean;
|
|
158
|
+
isSensitive: boolean;
|
|
159
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical';
|
|
160
|
+
detectedPatterns: string[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* MTAT with Compliance Integration
|
|
164
|
+
* Extends the basic monitor with framework-specific rules
|
|
165
|
+
*/
|
|
166
|
+
export declare class ComplianceSecurityMonitor extends SecurityMonitor {
|
|
167
|
+
constructor(prorm: Prorm, options?: SecurityMonitorOptions & {
|
|
168
|
+
modelsToProtect?: any[];
|
|
169
|
+
});
|
|
170
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SensitiveDataDiscovery
|
|
3
|
+
*
|
|
4
|
+
* Auto-scans models for sensitive data patterns (SSN, credit cards, health IDs, etc.)
|
|
5
|
+
* with support for custom patterns. Supports GDPR, HIPAA, PCI DSS, APPI compliance.
|
|
6
|
+
*
|
|
7
|
+
* Covers ~18 compliance frameworks including:
|
|
8
|
+
* GDPR (Art 25/30/32/44), HIPAA, PCI DSS 3.x, APPI (Japan),
|
|
9
|
+
* NIST SP 800-122, PIPL (China), LGPD (Brazil), CCPA/CPRA,
|
|
10
|
+
* FIPS 199, ISO 29101, and data discovery requirements.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* // Scan a model for sensitive fields:
|
|
14
|
+
* const fields = SensitiveDataDiscovery.scan(User);
|
|
15
|
+
* console.log(fields); // [{ field: 'ssn', type: 'SSN', confidence: 0.95 }, ...]
|
|
16
|
+
*
|
|
17
|
+
* // Scan all models in a prorm instance:
|
|
18
|
+
* const allFields = SensitiveDataDiscovery.scanAll(prorm);
|
|
19
|
+
*
|
|
20
|
+
* // Get previously discovered fields:
|
|
21
|
+
* const discovered = SensitiveDataDiscovery.getDiscoveredFields(User);
|
|
22
|
+
*
|
|
23
|
+
* // Auto-protect: add encryption/masking hooks:
|
|
24
|
+
* SensitiveDataDiscovery.autoProtect(User);
|
|
25
|
+
*/
|
|
26
|
+
/** Types of sensitive data that can be discovered */
|
|
27
|
+
export type SensitiveDataType = 'SSN' | 'CREDIT_CARD' | 'EMAIL' | 'PHONE' | 'HEALTH_ID' | 'DRIVERS_LICENSE' | 'PASSPORT' | 'BANK_ACCOUNT' | 'IBAN' | 'DATE_OF_BIRTH' | 'IP_ADDRESS' | 'BIOMETRIC' | 'MEDICAL_RECORD' | 'PRESCRIPTION' | 'INSURANCE_ID' | 'NATIONAL_ID';
|
|
28
|
+
/** Compliance framework reference */
|
|
29
|
+
export type ComplianceFramework = 'GDPR' | 'HIPAA' | 'PCI_DSS' | 'APPI' | 'PIPL' | 'LGPD' | 'CCPA' | 'NIST' | 'ISO';
|
|
30
|
+
/** Discovered sensitive field information */
|
|
31
|
+
export interface SensitiveField {
|
|
32
|
+
/** The field name in the model */
|
|
33
|
+
field: string;
|
|
34
|
+
/** Type of sensitive data detected */
|
|
35
|
+
type: SensitiveDataType;
|
|
36
|
+
/** Confidence score (0-1) */
|
|
37
|
+
confidence: number;
|
|
38
|
+
/** Detection method used */
|
|
39
|
+
method: 'pattern' | 'column_name' | 'data_sample';
|
|
40
|
+
/** Matching regex or pattern */
|
|
41
|
+
pattern: RegExp;
|
|
42
|
+
/** Regulatory frameworks that apply */
|
|
43
|
+
frameworks: ComplianceFramework[];
|
|
44
|
+
/** Recommended protection method */
|
|
45
|
+
recommendation: 'encrypt' | 'mask' | 'tokenize' | 'redact';
|
|
46
|
+
/** Original matched value (for validation) */
|
|
47
|
+
sampleMatch?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Custom discovery pattern definition */
|
|
50
|
+
export interface DiscoveryPattern {
|
|
51
|
+
/** Unique identifier for the pattern */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Human-readable name */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Type of sensitive data */
|
|
56
|
+
type: SensitiveDataType;
|
|
57
|
+
/** Regex pattern to match */
|
|
58
|
+
pattern: RegExp;
|
|
59
|
+
/** Column name patterns to match */
|
|
60
|
+
columnNames?: RegExp[];
|
|
61
|
+
/** Frameworks that this pattern satisfies */
|
|
62
|
+
frameworks: ComplianceFramework[];
|
|
63
|
+
/** Recommended protection */
|
|
64
|
+
recommendation: 'encrypt' | 'mask' | 'tokenize' | 'redact';
|
|
65
|
+
/** Priority (higher = checked first) */
|
|
66
|
+
priority?: number;
|
|
67
|
+
}
|
|
68
|
+
/** Options for scanning */
|
|
69
|
+
export interface ScanOptions {
|
|
70
|
+
/** Minimum confidence threshold (0-1). Default: 0.7 */
|
|
71
|
+
minConfidence?: number;
|
|
72
|
+
/** Whether to analyze data samples (may be slow). Default: false */
|
|
73
|
+
analyzeSamples?: boolean;
|
|
74
|
+
/** Maximum rows to sample for analysis. Default: 100 */
|
|
75
|
+
sampleSize?: number;
|
|
76
|
+
/** Custom patterns to add */
|
|
77
|
+
customPatterns?: DiscoveryPattern[];
|
|
78
|
+
/** Frameworks to prioritize */
|
|
79
|
+
targetFrameworks?: ComplianceFramework[];
|
|
80
|
+
/** Whether to include column name matching. Default: true */
|
|
81
|
+
matchByName?: boolean;
|
|
82
|
+
/** Whether to include pattern matching. Default: true */
|
|
83
|
+
matchByPattern?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/** Result of scanning a model */
|
|
86
|
+
export interface ScanResult {
|
|
87
|
+
/** The model that was scanned */
|
|
88
|
+
model: any;
|
|
89
|
+
/** Model name */
|
|
90
|
+
modelName: string;
|
|
91
|
+
/** Discovered sensitive fields */
|
|
92
|
+
fields: SensitiveField[];
|
|
93
|
+
/** Timestamp of scan */
|
|
94
|
+
scannedAt: Date;
|
|
95
|
+
/** Frameworks that apply to this model */
|
|
96
|
+
applicableFrameworks: ComplianceFramework[];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Register a custom discovery pattern.
|
|
100
|
+
*/
|
|
101
|
+
export declare function registerPattern(pattern: DiscoveryPattern): void;
|
|
102
|
+
/**
|
|
103
|
+
* Remove a custom discovery pattern.
|
|
104
|
+
*/
|
|
105
|
+
export declare function unregisterPattern(patternId: string): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Get all registered patterns.
|
|
108
|
+
*/
|
|
109
|
+
export declare function getPatterns(): DiscoveryPattern[];
|
|
110
|
+
/**
|
|
111
|
+
* Scan a single model for sensitive fields.
|
|
112
|
+
*/
|
|
113
|
+
export declare function scanModel(Model: any, options?: ScanOptions): SensitiveField[];
|
|
114
|
+
/**
|
|
115
|
+
* Scan all models in a Prorm instance.
|
|
116
|
+
*/
|
|
117
|
+
export declare function scanAllModels(prorm: any, options?: ScanOptions): ScanResult[];
|
|
118
|
+
/**
|
|
119
|
+
* Get previously discovered fields for a model.
|
|
120
|
+
*/
|
|
121
|
+
export declare function getDiscoveredFieldsForModel(Model: any): SensitiveField[] | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Get scan result for a specific model.
|
|
124
|
+
*/
|
|
125
|
+
export declare function getScanResult(prorm: any, modelName: string): ScanResult | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Auto-protect a model by adding encryption/masking hooks.
|
|
128
|
+
*/
|
|
129
|
+
export declare function autoProtectModel(Model: any, options?: ScanOptions): void;
|
|
130
|
+
/**
|
|
131
|
+
* Generate a compliance report for discovered fields.
|
|
132
|
+
*/
|
|
133
|
+
export declare function generateComplianceReport(prorm: any, options?: ScanOptions): {
|
|
134
|
+
summary: {
|
|
135
|
+
totalModels: number;
|
|
136
|
+
totalSensitiveFields: number;
|
|
137
|
+
byFramework: Record<ComplianceFramework, number>;
|
|
138
|
+
byType: Record<SensitiveDataType, number>;
|
|
139
|
+
};
|
|
140
|
+
models: ScanResult[];
|
|
141
|
+
};
|
|
142
|
+
export declare class SensitiveDataDiscovery {
|
|
143
|
+
static scan: typeof scanModel;
|
|
144
|
+
static scanAll: typeof scanAllModels;
|
|
145
|
+
static getDiscoveredFields: typeof getDiscoveredFieldsForModel;
|
|
146
|
+
static autoProtect: typeof autoProtectModel;
|
|
147
|
+
static registerPattern: typeof registerPattern;
|
|
148
|
+
static unregisterPattern: typeof unregisterPattern;
|
|
149
|
+
static getPatterns: typeof getPatterns;
|
|
150
|
+
static generateComplianceReport: typeof generateComplianceReport;
|
|
151
|
+
}
|