ts-prorm-orm 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/CHANGELOG.md +1111 -0
  2. package/LICENSE +21 -0
  3. package/README.md +573 -0
  4. package/dist/audit/history-query.js +180 -0
  5. package/dist/audit/index.js +23 -0
  6. package/dist/audit/logger.js +236 -0
  7. package/dist/cache/cache-manager.js +84 -0
  8. package/dist/cache/index.js +16 -0
  9. package/dist/cache/redis-cluster-cache.js +557 -0
  10. package/dist/cli.js +2200 -0
  11. package/dist/compliance/audit-trail.js +68 -0
  12. package/dist/compliance/backup-verification.js +685 -0
  13. package/dist/compliance/breach-detector.js +505 -0
  14. package/dist/compliance/consent-record.js +227 -0
  15. package/dist/compliance/consent-versioning.js +331 -0
  16. package/dist/compliance/cross-border-log.js +530 -0
  17. package/dist/compliance/data-classifier.js +258 -0
  18. package/dist/compliance/data-lineage.js +565 -0
  19. package/dist/compliance/data-masker.js +303 -0
  20. package/dist/compliance/data-portability.js +265 -0
  21. package/dist/compliance/data-retention.js +195 -0
  22. package/dist/compliance/dsar-workflow.js +342 -0
  23. package/dist/compliance/field-encryption.js +223 -0
  24. package/dist/compliance/immutable-record.js +148 -0
  25. package/dist/compliance/index.js +260 -0
  26. package/dist/compliance/privacy-impact-assessment.js +364 -0
  27. package/dist/compliance/pseudonymization.js +269 -0
  28. package/dist/compliance/query-firewall.js +1182 -0
  29. package/dist/compliance/rate-limiter.js +580 -0
  30. package/dist/compliance/right-to-erasure.js +117 -0
  31. package/dist/compliance/row-level-security.js +246 -0
  32. package/dist/compliance/security-decorator.js +574 -0
  33. package/dist/compliance/security-monitor.js +525 -0
  34. package/dist/compliance/sensitive-data-discovery.js +476 -0
  35. package/dist/compliance/session-isolation.js +472 -0
  36. package/dist/compliance/tls-enforcer.js +108 -0
  37. package/dist/compliance/worm-storage.js +712 -0
  38. package/dist/connection-manager.js +198 -0
  39. package/dist/connection-pool.js +519 -0
  40. package/dist/decorators/audit.js +136 -0
  41. package/dist/decorators/belongs-to-many.js +115 -0
  42. package/dist/decorators/belongs-to.js +115 -0
  43. package/dist/decorators/check.js +435 -0
  44. package/dist/decorators/collate.js +329 -0
  45. package/dist/decorators/comment.js +205 -0
  46. package/dist/decorators/database-settings.js +236 -0
  47. package/dist/decorators/default.js +244 -0
  48. package/dist/decorators/encryption.js +235 -0
  49. package/dist/decorators/engine.js +97 -0
  50. package/dist/decorators/fk-constraints.js +594 -0
  51. package/dist/decorators/foreign-table.js +136 -0
  52. package/dist/decorators/generated.js +274 -0
  53. package/dist/decorators/has-many.js +127 -0
  54. package/dist/decorators/has-one.js +116 -0
  55. package/dist/decorators/hstore.js +129 -0
  56. package/dist/decorators/index.js +355 -0
  57. package/dist/decorators/json-column.js +83 -0
  58. package/dist/decorators/jsonb.js +101 -0
  59. package/dist/decorators/orm-decorators.js +425 -0
  60. package/dist/decorators/permissions.js +294 -0
  61. package/dist/decorators/procedure.js +210 -0
  62. package/dist/decorators/query-options.js +556 -0
  63. package/dist/decorators/range.js +167 -0
  64. package/dist/decorators/set-column.js +83 -0
  65. package/dist/decorators/spatial.js +114 -0
  66. package/dist/decorators/storage.js +580 -0
  67. package/dist/decorators/timezone.js +512 -0
  68. package/dist/decorators/trigger.js +90 -0
  69. package/dist/decorators/uuid.js +135 -0
  70. package/dist/decorators/view.js +258 -0
  71. package/dist/diagrams/chen-diagram.js +354 -0
  72. package/dist/diagrams/class-diagram.js +384 -0
  73. package/dist/diagrams/dependency-diagram.js +432 -0
  74. package/dist/diagrams/er-diagram.js +605 -0
  75. package/dist/diagrams/flow-diagram.js +394 -0
  76. package/dist/diagrams/gantt-diagram.js +411 -0
  77. package/dist/diagrams/index-diagram.js +353 -0
  78. package/dist/diagrams/index.js +184 -0
  79. package/dist/diagrams/migration-diagram.js +316 -0
  80. package/dist/diagrams/model-diagram.js +616 -0
  81. package/dist/diagrams/package-diagram.js +376 -0
  82. package/dist/diagrams/palette.js +85 -0
  83. package/dist/diagrams/relational-diagram.js +455 -0
  84. package/dist/diagrams/schemadoc-diagram.js +309 -0
  85. package/dist/diagrams/sequence-diagram.js +307 -0
  86. package/dist/diagrams/state-diagram.js +344 -0
  87. package/dist/diagrams/svg-dom.js +111 -0
  88. package/dist/diagrams/tree-diagram.js +250 -0
  89. package/dist/dialects/clickhouse/index.js +1742 -0
  90. package/dist/dialects/cockroachdb/index.js +4677 -0
  91. package/dist/dialects/cratedb/index.js +441 -0
  92. package/dist/dialects/databricks/index.js +517 -0
  93. package/dist/dialects/db2/index.js +2225 -0
  94. package/dist/dialects/dialect.js +720 -0
  95. package/dist/dialects/duckdb/index.js +2014 -0
  96. package/dist/dialects/exasol/index.js +357 -0
  97. package/dist/dialects/firebird/index.js +495 -0
  98. package/dist/dialects/greenplum/index.js +457 -0
  99. package/dist/dialects/hana/index.js +1741 -0
  100. package/dist/dialects/mariadb/index.js +3590 -0
  101. package/dist/dialects/mssql/index.js +2296 -0
  102. package/dist/dialects/mysql/index.js +4058 -0
  103. package/dist/dialects/oracle/index.js +2999 -0
  104. package/dist/dialects/postgres/index.js +5319 -0
  105. package/dist/dialects/query-stream-helper.js +152 -0
  106. package/dist/dialects/questdb/index.js +433 -0
  107. package/dist/dialects/redshift/index.js +2277 -0
  108. package/dist/dialects/singlestore/index.js +354 -0
  109. package/dist/dialects/snowflake/index.js +2082 -0
  110. package/dist/dialects/spanner/index.js +1768 -0
  111. package/dist/dialects/sqlite/index.js +3382 -0
  112. package/dist/dialects/tidb/index.js +377 -0
  113. package/dist/dialects/timescaledb/index.js +164 -0
  114. package/dist/dialects/trino/index.js +420 -0
  115. package/dist/dialects/turso/index.js +227 -0
  116. package/dist/dialects/vertica/index.js +317 -0
  117. package/dist/dialects/yugabytedb/index.js +424 -0
  118. package/dist/errors/index.js +472 -0
  119. package/dist/errors/utils.js +340 -0
  120. package/dist/errors.js +21 -0
  121. package/dist/extensions/catalog/cloud-warehouse-features.js +207 -0
  122. package/dist/extensions/catalog/mssql-features.js +147 -0
  123. package/dist/extensions/catalog/mysql-mariadb-plugins.js +229 -0
  124. package/dist/extensions/catalog/oracle-db2-features.js +196 -0
  125. package/dist/extensions/catalog/postgres-extensions.js +516 -0
  126. package/dist/extensions/index.js +71 -0
  127. package/dist/extensions/types.js +13 -0
  128. package/dist/foreign-data.js +173 -0
  129. package/dist/hooks/hooks-manager.js +350 -0
  130. package/dist/hooks/index.js +37 -0
  131. package/dist/index.js +463 -0
  132. package/dist/logging.js +335 -0
  133. package/dist/migrations/index.js +40 -0
  134. package/dist/migrations/migration.js +196 -0
  135. package/dist/migrations/migrator.js +411 -0
  136. package/dist/migrations/prormmigration.js +275 -0
  137. package/dist/migrations/query-interface.js +435 -0
  138. package/dist/migrations/seeder.js +353 -0
  139. package/dist/models/associations.js +852 -0
  140. package/dist/models/constraints.js +288 -0
  141. package/dist/models/data-types.js +2518 -0
  142. package/dist/models/decorators.js +445 -0
  143. package/dist/models/index.js +33 -0
  144. package/dist/models/indexes.js +531 -0
  145. package/dist/models/methods.js +382 -0
  146. package/dist/models/model-manager.js +103 -0
  147. package/dist/models/model.js +5349 -0
  148. package/dist/models/operators.js +67 -0
  149. package/dist/models/scopes.js +189 -0
  150. package/dist/models/typescript-types.js +26 -0
  151. package/dist/nosql/aerospike/index.js +205 -0
  152. package/dist/nosql/allegrograph/index.js +169 -0
  153. package/dist/nosql/arangodb/index.js +364 -0
  154. package/dist/nosql/azure-blob/index.js +206 -0
  155. package/dist/nosql/beanstalkd/index.js +231 -0
  156. package/dist/nosql/beequeue/index.js +210 -0
  157. package/dist/nosql/bigchaindb/index.js +195 -0
  158. package/dist/nosql/bigtable/index.js +224 -0
  159. package/dist/nosql/blazegraph/index.js +173 -0
  160. package/dist/nosql/bullmq/index.js +191 -0
  161. package/dist/nosql/cassandra/index.js +174 -0
  162. package/dist/nosql/chroma/index.js +190 -0
  163. package/dist/nosql/cloudflare-kv/index.js +220 -0
  164. package/dist/nosql/coherence/index.js +200 -0
  165. package/dist/nosql/cosmosdb/index.js +157 -0
  166. package/dist/nosql/couchbase/index.js +213 -0
  167. package/dist/nosql/dax/index.js +212 -0
  168. package/dist/nosql/deno-kv/index.js +206 -0
  169. package/dist/nosql/dgraph/index.js +171 -0
  170. package/dist/nosql/doris/index.js +169 -0
  171. package/dist/nosql/druid/index.js +162 -0
  172. package/dist/nosql/dynamodb/index.js +937 -0
  173. package/dist/nosql/elasticsearch/index.js +377 -0
  174. package/dist/nosql/etcd/index.js +502 -0
  175. package/dist/nosql/eventhubs/index.js +213 -0
  176. package/dist/nosql/eventstore/index.js +254 -0
  177. package/dist/nosql/faunadb/index.js +188 -0
  178. package/dist/nosql/firestore/index.js +177 -0
  179. package/dist/nosql/fluree/index.js +148 -0
  180. package/dist/nosql/fuseki/index.js +170 -0
  181. package/dist/nosql/gcs/index.js +172 -0
  182. package/dist/nosql/gearman/index.js +160 -0
  183. package/dist/nosql/geode/index.js +196 -0
  184. package/dist/nosql/graphdb/index.js +169 -0
  185. package/dist/nosql/graylog/index.js +188 -0
  186. package/dist/nosql/gridgain/index.js +171 -0
  187. package/dist/nosql/hazelcast/index.js +162 -0
  188. package/dist/nosql/hbase/index.js +230 -0
  189. package/dist/nosql/ignite/index.js +173 -0
  190. package/dist/nosql/immudb/index.js +184 -0
  191. package/dist/nosql/index.js +232 -0
  192. package/dist/nosql/infinispan/index.js +200 -0
  193. package/dist/nosql/influxdb/index.js +0 -0
  194. package/dist/nosql/kafka/index.js +234 -0
  195. package/dist/nosql/keyspaces/index.js +189 -0
  196. package/dist/nosql/kinesis/index.js +253 -0
  197. package/dist/nosql/leveldb/index.js +153 -0
  198. package/dist/nosql/lmdb/index.js +160 -0
  199. package/dist/nosql/loki/index.js +201 -0
  200. package/dist/nosql/marklogic/index.js +204 -0
  201. package/dist/nosql/materialize/index.js +145 -0
  202. package/dist/nosql/meilisearch/index.js +154 -0
  203. package/dist/nosql/memcached/index.js +223 -0
  204. package/dist/nosql/milvus/index.js +410 -0
  205. package/dist/nosql/minio/index.js +265 -0
  206. package/dist/nosql/momento/index.js +179 -0
  207. package/dist/nosql/mongodb/index.js +461 -0
  208. package/dist/nosql/nats/index.js +247 -0
  209. package/dist/nosql/nedb/index.js +164 -0
  210. package/dist/nosql/neo4j/index.js +450 -0
  211. package/dist/nosql/neptune/index.js +470 -0
  212. package/dist/nosql/nsq/index.js +200 -0
  213. package/dist/nosql/opensearch/index.js +186 -0
  214. package/dist/nosql/orientdb/index.js +175 -0
  215. package/dist/nosql/papertrail/index.js +200 -0
  216. package/dist/nosql/pinecone/index.js +0 -0
  217. package/dist/nosql/pinot/index.js +133 -0
  218. package/dist/nosql/pouchdb/index.js +172 -0
  219. package/dist/nosql/prometheus/index.js +174 -0
  220. package/dist/nosql/provendb/index.js +147 -0
  221. package/dist/nosql/pubsub/index.js +187 -0
  222. package/dist/nosql/pulsar/index.js +232 -0
  223. package/dist/nosql/qdrant/index.js +295 -0
  224. package/dist/nosql/qldb/index.js +192 -0
  225. package/dist/nosql/r2/index.js +281 -0
  226. package/dist/nosql/rabbitmq/index.js +237 -0
  227. package/dist/nosql/ravendb/index.js +175 -0
  228. package/dist/nosql/redis/index.js +607 -0
  229. package/dist/nosql/redpanda/index.js +237 -0
  230. package/dist/nosql/resque/index.js +203 -0
  231. package/dist/nosql/rethinkdb/index.js +232 -0
  232. package/dist/nosql/rocksdb/index.js +152 -0
  233. package/dist/nosql/rockset/index.js +126 -0
  234. package/dist/nosql/s3/index.js +298 -0
  235. package/dist/nosql/scylladb/index.js +178 -0
  236. package/dist/nosql/signoz/index.js +227 -0
  237. package/dist/nosql/sns/index.js +201 -0
  238. package/dist/nosql/solr/index.js +231 -0
  239. package/dist/nosql/splunk/index.js +227 -0
  240. package/dist/nosql/sqs/index.js +246 -0
  241. package/dist/nosql/stardog/index.js +169 -0
  242. package/dist/nosql/starrocks/index.js +170 -0
  243. package/dist/nosql/store.js +2 -0
  244. package/dist/nosql/sumologic/index.js +213 -0
  245. package/dist/nosql/surrealdb/index.js +179 -0
  246. package/dist/nosql/terminusdb/index.js +151 -0
  247. package/dist/nosql/tigergraph/index.js +469 -0
  248. package/dist/nosql/typesense/index.js +148 -0
  249. package/dist/nosql/unqlite/index.js +157 -0
  250. package/dist/nosql/upstash/index.js +167 -0
  251. package/dist/nosql/vercel-kv/index.js +166 -0
  252. package/dist/nosql/victoriametrics/index.js +213 -0
  253. package/dist/nosql/virtuoso/index.js +169 -0
  254. package/dist/nosql/weaviate/index.js +276 -0
  255. package/dist/operators/index.js +108 -0
  256. package/dist/operators.js +2690 -0
  257. package/dist/prisma-migrate/index.js +38 -0
  258. package/dist/prisma-migrate/migration-generator.js +125 -0
  259. package/dist/prisma-migrate/model-generator.js +172 -0
  260. package/dist/prisma-migrate/relations.js +100 -0
  261. package/dist/prisma-migrate/schema-parser.js +167 -0
  262. package/dist/prisma-migrate/type-mapper.js +40 -0
  263. package/dist/prorm.js +6832 -0
  264. package/dist/query-builders/cte-builder.js +80 -0
  265. package/dist/query-builders/functions/aggregate.js +390 -0
  266. package/dist/query-builders/functions/conditional.js +503 -0
  267. package/dist/query-builders/functions/datetime.js +695 -0
  268. package/dist/query-builders/functions/fulltext.js +439 -0
  269. package/dist/query-builders/functions/index.js +93 -0
  270. package/dist/query-builders/functions/json.js +427 -0
  271. package/dist/query-builders/functions/math.js +399 -0
  272. package/dist/query-builders/functions/string.js +518 -0
  273. package/dist/query-builders/functions/window.js +328 -0
  274. package/dist/query-builders/include-builder.js +323 -0
  275. package/dist/query-builders/index-expression-builder.js +242 -0
  276. package/dist/query-builders/index.js +161 -0
  277. package/dist/query-builders/insert-builder.js +164 -0
  278. package/dist/query-builders/model-helpers.js +38 -0
  279. package/dist/query-builders/order-limit-builder.js +239 -0
  280. package/dist/query-builders/sql-compiler.js +2040 -0
  281. package/dist/query-builders/subquery-builder.js +152 -0
  282. package/dist/query-builders/update-builder.js +182 -0
  283. package/dist/query-builders/view-builder.js +218 -0
  284. package/dist/query-builders/where-builder.js +1532 -0
  285. package/dist/query-interface.js +622 -0
  286. package/dist/query-optimizers/batch-optimizer.js +426 -0
  287. package/dist/query-optimizers/explain-plans.js +415 -0
  288. package/dist/query-optimizers/index.js +51 -0
  289. package/dist/query-optimizers/prepared-statement-cache.js +423 -0
  290. package/dist/query-optimizers/query-hints.js +438 -0
  291. package/dist/query-optimizers/query-optimizer.js +278 -0
  292. package/dist/query-optimizers/slow-query-logger.js +271 -0
  293. package/dist/replica-manager.js +507 -0
  294. package/dist/schema/index.js +15 -0
  295. package/dist/schema/migration-generator.js +374 -0
  296. package/dist/schema/schema-differ.js +549 -0
  297. package/dist/schema/types.js +6 -0
  298. package/dist/sql-constants.js +300 -0
  299. package/dist/sqlite-advanced.js +1047 -0
  300. package/dist/streams/index.js +12 -0
  301. package/dist/streams/transforms.js +178 -0
  302. package/dist/transaction.js +456 -0
  303. package/dist/types/index.js +180 -0
  304. package/dist/user-management.js +127 -0
  305. package/dist/utils/date.js +300 -0
  306. package/dist/utils/index.js +1079 -0
  307. package/dist/utils/string.js +161 -0
  308. package/dist/validators/index.js +19 -0
  309. package/dist/validators/validator.js +911 -0
  310. package/package.json +190 -0
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ /**
3
+ * FieldEncryption
4
+ *
5
+ * AES-256-GCM reversible field-level encryption for model attributes.
6
+ * Unlike the existing @Secure decorator (which one-way hashes passwords),
7
+ * this encrypts data so it can be decrypted — suitable for PII, PHI, and PCI data.
8
+ *
9
+ * Covers ~63 compliance frameworks including:
10
+ * GDPR, HIPAA, PCI DSS, FIPS 140-2/140-3, NIST SP 800-111, PIPL, KVKK,
11
+ * PDPA (multiple), SOC 2, ISO 27001, HITRUST, and more.
12
+ *
13
+ * Usage:
14
+ * FieldEncryption.configure('32-byte-hex-key-here');
15
+ *
16
+ * // Annotate fields:
17
+ * Encrypt('ssn')(User);
18
+ * Encrypt('creditCardNumber')(User);
19
+ *
20
+ * // Apply hooks (once per model):
21
+ * applyEncryptionHooks(User);
22
+ *
23
+ * // Values are encrypted in the DB, transparent on read:
24
+ * const user = await User.findByPk(1);
25
+ * console.log(user.ssn); // plain text — decrypted automatically
26
+ */
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.FieldEncryption = void 0;
29
+ exports.configureFieldEncryption = configureFieldEncryption;
30
+ exports.encryptValue = encryptValue;
31
+ exports.decryptValue = decryptValue;
32
+ exports.getEncryptedFields = getEncryptedFields;
33
+ exports.Encrypt = Encrypt;
34
+ exports.applyEncryptionHooks = applyEncryptionHooks;
35
+ const crypto_1 = require("crypto");
36
+ // ==================== Key Management ====================
37
+ const ALGORITHM = 'aes-256-gcm';
38
+ const IV_LENGTH = 12; // 96-bit IV for GCM
39
+ const TAG_LENGTH = 16;
40
+ const ENCRYPTED_PREFIX = 'enc:v1:';
41
+ let globalKey = null;
42
+ /**
43
+ * Configure the global encryption key.
44
+ * Call once at app startup before any encrypted models are used.
45
+ *
46
+ * @param key - A 32-byte key as a hex string (64 hex chars) or raw Buffer.
47
+ */
48
+ function configureFieldEncryption(key) {
49
+ if (typeof key === 'string') {
50
+ // Accept hex string
51
+ if (key.length === 64) {
52
+ globalKey = Buffer.from(key, 'hex');
53
+ }
54
+ else {
55
+ // Hash arbitrary passphrase to 32 bytes
56
+ globalKey = (0, crypto_1.createHash)('sha256').update(key).digest();
57
+ }
58
+ }
59
+ else {
60
+ globalKey = key;
61
+ }
62
+ }
63
+ /** Returns the configured encryption key, throwing if configureFieldEncryption() hasn't been called yet. */
64
+ function getKey() {
65
+ if (!globalKey) {
66
+ throw new Error('[FieldEncryption] No encryption key configured. Call configureFieldEncryption(key) at startup.');
67
+ }
68
+ return globalKey;
69
+ }
70
+ // ==================== Encrypt / Decrypt ====================
71
+ /**
72
+ * Encrypt a plain-text value.
73
+ * Returns a prefixed base64 string: "enc:v1:<iv>:<tag>:<ciphertext>"
74
+ */
75
+ function encryptValue(plain) {
76
+ const key = getKey();
77
+ const iv = (0, crypto_1.randomBytes)(IV_LENGTH);
78
+ const cipher = (0, crypto_1.createCipheriv)(ALGORITHM, key, iv);
79
+ const encrypted = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
80
+ const tag = cipher.getAuthTag();
81
+ const payload = Buffer.concat([iv, tag, encrypted]).toString('base64');
82
+ return ENCRYPTED_PREFIX + payload;
83
+ }
84
+ /**
85
+ * Decrypt a value produced by encryptValue().
86
+ * Returns the original plain-text string.
87
+ */
88
+ function decryptValue(ciphertext) {
89
+ if (!ciphertext.startsWith(ENCRYPTED_PREFIX)) {
90
+ return ciphertext; // already plain (e.g. during migration)
91
+ }
92
+ const key = getKey();
93
+ const payload = Buffer.from(ciphertext.slice(ENCRYPTED_PREFIX.length), 'base64');
94
+ const iv = payload.subarray(0, IV_LENGTH);
95
+ const tag = payload.subarray(IV_LENGTH, IV_LENGTH + TAG_LENGTH);
96
+ const encrypted = payload.subarray(IV_LENGTH + TAG_LENGTH);
97
+ const decipher = (0, crypto_1.createDecipheriv)(ALGORITHM, key, iv);
98
+ decipher.setAuthTag(tag);
99
+ return decipher.update(encrypted) + decipher.final('utf8');
100
+ }
101
+ /** Checks whether a value is already in encrypted form (prefixed with `enc:v1:`), used to avoid double-encrypting. */
102
+ function isEncrypted(value) {
103
+ return typeof value === 'string' && value.startsWith(ENCRYPTED_PREFIX);
104
+ }
105
+ // ==================== Field Registry ====================
106
+ const ENCRYPTED_FIELDS_KEY = '__orm_encrypted_fields__';
107
+ /**
108
+ * Get the list of fields marked for encryption on a model class.
109
+ */
110
+ function getEncryptedFields(target) {
111
+ return target[ENCRYPTED_FIELDS_KEY] ?? [];
112
+ }
113
+ // ==================== Decorator ====================
114
+ /**
115
+ * Mark a field for AES-256-GCM encryption.
116
+ * Apply as a class decorator, passing the field name(s).
117
+ *
118
+ * Encrypt('ssn')(User);
119
+ * Encrypt('bankAccount')(User);
120
+ *
121
+ * Then call applyEncryptionHooks(User) once to wire the hooks.
122
+ */
123
+ function Encrypt(field) {
124
+ return function (target) {
125
+ if (!target[ENCRYPTED_FIELDS_KEY]) {
126
+ target[ENCRYPTED_FIELDS_KEY] = [];
127
+ }
128
+ if (!target[ENCRYPTED_FIELDS_KEY].includes(field)) {
129
+ target[ENCRYPTED_FIELDS_KEY].push(field);
130
+ }
131
+ };
132
+ }
133
+ // ==================== Hook Wiring ====================
134
+ /**
135
+ * Wire beforeSave and afterFind hooks onto a model to transparently
136
+ * encrypt on write and decrypt on read.
137
+ *
138
+ * Call once per model after it is defined:
139
+ * applyEncryptionHooks(User);
140
+ */
141
+ function applyEncryptionHooks(ModelClass) {
142
+ const fields = getEncryptedFields(ModelClass);
143
+ if (fields.length === 0)
144
+ return;
145
+ const addHook = (name, fn) => {
146
+ if (typeof ModelClass.addHook === 'function') {
147
+ ModelClass.addHook(name, `orm:fieldEncrypt:${name}`, fn);
148
+ }
149
+ else if (typeof ModelClass.hook === 'function') {
150
+ ModelClass.hook(name, fn);
151
+ }
152
+ };
153
+ // Encrypt on save
154
+ addHook('beforeSave', (instance) => {
155
+ for (const field of fields) {
156
+ const value = instance.getDataValue ? instance.getDataValue(field) : instance[field];
157
+ if (value != null && typeof value === 'string' && !isEncrypted(value)) {
158
+ const encrypted = encryptValue(value);
159
+ if (instance.setDataValue)
160
+ instance.setDataValue(field, encrypted);
161
+ else
162
+ instance[field] = encrypted;
163
+ }
164
+ }
165
+ });
166
+ // Also encrypt on bulk create/update
167
+ addHook('beforeBulkCreate', (instances) => {
168
+ for (const instance of instances) {
169
+ for (const field of fields) {
170
+ const value = instance.getDataValue ? instance.getDataValue(field) : instance[field];
171
+ if (value != null && typeof value === 'string' && !isEncrypted(value)) {
172
+ const encrypted = encryptValue(value);
173
+ if (instance.setDataValue)
174
+ instance.setDataValue(field, encrypted);
175
+ else
176
+ instance[field] = encrypted;
177
+ }
178
+ }
179
+ }
180
+ });
181
+ // Decrypt after find
182
+ const decryptInstance = (instance) => {
183
+ if (!instance)
184
+ return;
185
+ for (const field of fields) {
186
+ const value = instance.getDataValue ? instance.getDataValue(field) : instance[field];
187
+ if (value != null && isEncrypted(value)) {
188
+ const decrypted = decryptValue(value);
189
+ if (instance.setDataValue)
190
+ instance.setDataValue(field, decrypted);
191
+ else
192
+ instance[field] = decrypted;
193
+ }
194
+ }
195
+ };
196
+ addHook('afterFind', (result) => {
197
+ if (Array.isArray(result)) {
198
+ result.forEach(decryptInstance);
199
+ }
200
+ else {
201
+ decryptInstance(result);
202
+ }
203
+ });
204
+ }
205
+ // ==================== FieldEncryption Class ====================
206
+ /**
207
+ * Convenience class grouping the encryption API.
208
+ */
209
+ class FieldEncryption {
210
+ }
211
+ exports.FieldEncryption = FieldEncryption;
212
+ /** Configure the global AES-256-GCM key. */
213
+ FieldEncryption.configure = configureFieldEncryption;
214
+ /** Manually encrypt a value. */
215
+ FieldEncryption.encrypt = encryptValue;
216
+ /** Manually decrypt a value. */
217
+ FieldEncryption.decrypt = decryptValue;
218
+ /** Check if a value is already encrypted. */
219
+ FieldEncryption.isEncrypted = isEncrypted;
220
+ /** Wire hooks onto a model. */
221
+ FieldEncryption.applyHooks = applyEncryptionHooks;
222
+ /** Get the list of encrypted fields on a model. */
223
+ FieldEncryption.getFields = getEncryptedFields;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * ImmutableRecord
4
+ *
5
+ * Prevents UPDATE and DELETE on a model. Only CREATE and READ are allowed.
6
+ * Provides an `append()` method for creating new versions of immutable data,
7
+ * optionally with soft versioning (storing the version number).
8
+ *
9
+ * Covers ~14 compliance frameworks including:
10
+ * SOX, SEC 17a-4 (WORM), 21 CFR Part 11, EU Annex 11, ALCOA+,
11
+ * GAMP 5, ICH E6 GCP, NATO STANAG, and financial audit requirements.
12
+ *
13
+ * Usage:
14
+ * // Make a model immutable:
15
+ * ImmutableRecord.makeImmutable(FinancialEntry);
16
+ *
17
+ * // Now attempting to update/delete throws:
18
+ * await entry.update({ amount: 100 }); // throws Error
19
+ * await entry.destroy(); // throws Error
20
+ *
21
+ * // Instead, create a new version:
22
+ * const newEntry = await FinancialEntry.append({
23
+ * amount: 100,
24
+ * description: 'Q3 adjustment',
25
+ * }, { parentId: entry.id });
26
+ *
27
+ * // Enable soft versioning (tracks version numbers):
28
+ * ImmutableRecord.enableVersioning(FinancialEntry, { versionField: 'version' });
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.ImmutableRecord = void 0;
32
+ exports.makeImmutable = makeImmutable;
33
+ exports.enableVersioning = enableVersioning;
34
+ exports.isImmutable = isImmutable;
35
+ exports.hasVersioning = hasVersioning;
36
+ exports.getVersionConfig = getVersionConfig;
37
+ exports.listImmutableModels = listImmutableModels;
38
+ const immutableModels = new Map();
39
+ const versionConfigs = new Map();
40
+ /**
41
+ * Mark a model as immutable — blocks UPDATE and DELETE.
42
+ *
43
+ * @param Model - The model class to protect
44
+ * @param options - Immutable configuration options
45
+ */
46
+ function makeImmutable(Model, options = {}) {
47
+ immutableModels.set(Model, {
48
+ silentDelete: options.silentDelete ?? false,
49
+ allowCreate: options.allowCreate ?? true,
50
+ });
51
+ // Register beforeUpdate and beforeDestroy hooks
52
+ const hookName = 'orm:immutableRecord';
53
+ if (typeof Model.addHook === 'function') {
54
+ Model.addHook('beforeUpdate', hookName, () => {
55
+ throw new Error(`[ImmutableRecord] UPDATE is not allowed on model "${Model.name ?? Model}". ` +
56
+ `This model is configured as immutable for compliance (SOX, SEC 17a-4, 21 CFR Part 11, etc.). ` +
57
+ `Use ${Model.name}.append() to create a new version instead.`);
58
+ });
59
+ Model.addHook('beforeDestroy', hookName, function () {
60
+ const opts = immutableModels.get(Model);
61
+ if (opts?.silentDelete) {
62
+ // Prevent the delete by throwing (the alternative would be to silently do nothing)
63
+ // Actually, to truly be silent we'd need to return a no-op, which isn't possible in hooks
64
+ // So we throw to be explicit, but document that silentDelete is deprecated
65
+ throw new Error(`[ImmutableRecord] DELETE is not allowed on model "${Model.name ?? Model}". ` +
66
+ `This model is configured as immutable.`);
67
+ }
68
+ throw new Error(`[ImmutableRecord] DELETE is not allowed on model "${Model.name ?? Model}". ` +
69
+ `This model is configured as immutable for compliance (SOX, SEC 17a-4, 21 CFR Part 11, etc.). ` +
70
+ `Immutable records cannot be deleted — they must be retained.`);
71
+ });
72
+ // Add class method for appending new versions
73
+ Model.append = async function (data, options = {}) {
74
+ const versionConfig = versionConfigs.get(Model);
75
+ const createData = { ...data };
76
+ if (versionConfig) {
77
+ // Find the latest version number
78
+ const latest = await Model.findOne({
79
+ order: [[versionConfig.versionField, 'DESC']],
80
+ });
81
+ const nextVersion = latest ? (latest[versionConfig.versionField] ?? 0) + 1 : versionConfig.startAt;
82
+ createData[versionConfig.versionField] = nextVersion;
83
+ if (options.parentId) {
84
+ createData[versionConfig.parentField] = options.parentId;
85
+ }
86
+ else if (latest) {
87
+ createData[versionConfig.parentField] = latest.id;
88
+ }
89
+ }
90
+ return Model.create(createData);
91
+ };
92
+ }
93
+ }
94
+ /**
95
+ * Enable soft versioning on an immutable model.
96
+ * Adds version and previousId fields, and auto-increments on append.
97
+ *
98
+ * @param Model - The model class
99
+ * @param options - Version field configuration
100
+ */
101
+ function enableVersioning(Model, options = {}) {
102
+ versionConfigs.set(Model, {
103
+ versionField: options.versionField ?? 'version',
104
+ parentField: options.parentField ?? 'previousId',
105
+ startAt: options.startAt ?? 1,
106
+ });
107
+ // If the model is not already immutable, make it so
108
+ if (!immutableModels.has(Model)) {
109
+ makeImmutable(Model);
110
+ }
111
+ }
112
+ /**
113
+ * Check if a model is configured as immutable.
114
+ */
115
+ function isImmutable(Model) {
116
+ return immutableModels.has(Model);
117
+ }
118
+ /**
119
+ * Check if an immutable model has versioning enabled.
120
+ */
121
+ function hasVersioning(Model) {
122
+ return versionConfigs.has(Model);
123
+ }
124
+ /**
125
+ * Get the version configuration for an immutable model.
126
+ */
127
+ function getVersionConfig(Model) {
128
+ return versionConfigs.get(Model);
129
+ }
130
+ /**
131
+ * Get all immutable models registered.
132
+ */
133
+ function listImmutableModels() {
134
+ return Array.from(immutableModels.entries()).map(([model, options]) => ({
135
+ model,
136
+ options,
137
+ }));
138
+ }
139
+ // ==================== Class Export ====================
140
+ class ImmutableRecord {
141
+ }
142
+ exports.ImmutableRecord = ImmutableRecord;
143
+ ImmutableRecord.makeImmutable = makeImmutable;
144
+ ImmutableRecord.enableVersioning = enableVersioning;
145
+ ImmutableRecord.isImmutable = isImmutable;
146
+ ImmutableRecord.hasVersioning = hasVersioning;
147
+ ImmutableRecord.getVersionConfig = getVersionConfig;
148
+ ImmutableRecord.listImmutableModels = listImmutableModels;
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ /**
3
+ * Compliance Module
4
+ *
5
+ * A set of 12 reusable classes for addressing data storage requirements
6
+ * from 218+ security and compliance frameworks.
7
+ *
8
+ * Each class wraps existing ORM infrastructure (hooks, decorators, scopes)
9
+ * into simple one-liner APIs.
10
+ *
11
+ * ---
12
+ *
13
+ * Quick reference:
14
+ *
15
+ * // 1. Audit trail for all CRUD operations
16
+ * import { ComplianceAuditTrail } from './compliance/audit-trail';
17
+ * ComplianceAuditTrail.enable(prorm, UserModel, { getUserId: () => user.id });
18
+ *
19
+ * // 2. Field-level AES-256-GCM encryption
20
+ * import { FieldEncryption } from './compliance/field-encryption';
21
+ * FieldEncryption.configure('32-byte-hex-key');
22
+ * @Encrypt('ssn') class User extends Model {}
23
+ * applyEncryptionHooks(User);
24
+ *
25
+ * // 3. TLS enforcement at connection time
26
+ * import { TLSEnforcer } from './compliance/tls-enforcer';
27
+ * TLSEnforcer.enforce(prorm);
28
+ *
29
+ * // 4. Data retention / TTL policies
30
+ * import { DataRetentionPolicy } from './compliance/data-retention';
31
+ * DataRetentionPolicy.set(FinancialRecord, { maxAge: { years: 7 } });
32
+ * await DataRetentionPolicy.purge(FinancialRecord);
33
+ *
34
+ * // 5. Right to erasure (DSAR response)
35
+ * import { RightToErasure } from './compliance/right-to-erasure';
36
+ * await RightToErasure.erase(User, { where: { id: userId } }, { mode: 'anonymize' });
37
+ *
38
+ * // 6. Consent record storage
39
+ * import { ConsentRecord } from './compliance/consent-record';
40
+ * await ConsentRecord.initialize(prorm);
41
+ * await ConsentRecord.grant({ subjectId: userId, purpose: 'marketing' });
42
+ *
43
+ * // 7. Row-level security (tenant filtering)
44
+ * import { RowLevelSecurity } from './compliance/row-level-security';
45
+ * RowLevelSecurity.apply(Document, ctx => ({ where: { tenantId: ctx.tenantId } }));
46
+ *
47
+ * // 8. Data masking in query output
48
+ * import { DataMasker } from './compliance/data-masker';
49
+ * DataMasker.maskField(User, 'ssn', { pattern: 'ssn' });
50
+ * const masked = DataMasker.mask(user, 'admin');
51
+ *
52
+ * // 9. Immutable records (append-only, no update/delete)
53
+ * import { ImmutableRecord } from './compliance/immutable-record';
54
+ * ImmutableRecord.makeImmutable(AuditEntry);
55
+ *
56
+ * // 10. Pseudonymization / tokenization
57
+ * import { PseudonymizationService } from './compliance/pseudonymization';
58
+ * await PseudonymizationService.configure({ secretKey: '...' });
59
+ * const token = await PseudonymizationService.tokenize('user-123');
60
+ *
61
+ * // 11. Data portability (DSAR export)
62
+ * import { DataPortabilityExporter } from './compliance/data-portability';
63
+ * const export = await DataPortabilityExporter.export(User, { where: { id: userId } });
64
+ *
65
+ * // 12. Data classification / sensitivity tagging
66
+ * import { DataClassifier } from './compliance/data-classifier';
67
+ * @FieldClassification('email', 'PII') class User extends Model {}
68
+ * const piiFields = DataClassifier.getPIIFields(User);
69
+ */
70
+ Object.defineProperty(exports, "__esModule", { value: true });
71
+ exports.getPIIFields = exports.getClassification = exports.FieldClassification = exports.Classify = exports.DataClassifier = exports.createDSARResponse = exports.exportStream = exports.exportData = exports.DataPortabilityExporter = exports.applyPseudonymizationHooks = exports.Pseudonymize = exports.detokenize = exports.tokenize = exports.configure = exports.PseudonymizationService = exports.isImmutable = exports.enableVersioning = exports.makeImmutable = exports.ImmutableRecord = exports.applyMaskingHooks = exports.maskMany = exports.mask = exports.maskValue = exports.maskField = exports.Mask = exports.MaskPatternEnum = exports.DataMasker = exports.registerHooks = exports.rlsMiddleware = exports.runInContext = exports.getContext = exports.setContext = exports.apply = exports.initRLS = exports.RLS = exports.RowLevelSecurity = exports.ConsentVersioning = exports.LegalBasisEnum = exports.ConsentRecord = exports.RightToErasure = exports.DataRetentionPolicy = exports.TLSEnforcer = exports.getEncryptedFields = exports.applyEncryptionHooks = exports.Encrypt = exports.decryptValue = exports.encryptValue = exports.configureFieldEncryption = exports.FieldEncryption = exports.ComplianceAuditTrail = void 0;
72
+ exports.SensitiveDataDiscovery = exports.getRecommendedLimits = exports.satisfiesCompliance = exports.checkRateLimit = exports.initRateLimiter = exports.getGlobalLimiter = exports.getRateLimitOptions = exports.RateLimit = exports.RateLimiter = exports.isArchived = exports.isFrozen = exports.applyWORMHooks = exports.getWORMOptions = exports.WORM = exports.WORMStorage = exports.getTenantIsolationOptions = exports.getTenantAuditMetadata = exports.sessionIsolationMiddleware = exports.TenantIsolation = exports.SessionIsolation = exports.initBreachDetector = exports.getGlobalBreachDetector = exports.BreachDetector = exports.analyzeQuerySecurity = exports.initSecurityMonitor = exports.getGlobalMonitor = exports.ComplianceSecurityMonitor = exports.SecurityMonitor = exports.isImmutableModel = exports.hasAudit = exports.getSecurityFrameworks = exports.getDatabaseSecurity = exports.getTableSecurity = exports.DatabaseSecurity = exports.Table = exports.setupAllSecurity = exports.setupSecurity = exports.getAllFrameworks = exports.getFrameworkCategory = exports.isValidFramework = exports.FrameworkCount = exports.FrameworkRequirements = exports.FrameworkCategories = exports.AllFrameworks = exports.SecurityFramework = exports.Security = exports.autoDiscover = exports.isSensitive = exports.getPCIFields = exports.getPHIFields = void 0;
73
+ exports.applyFirewallRulesToModel = exports.SQLiteFirewall = exports.OracleFirewall = exports.MSSQLFirewall = exports.MariaDBFirewall = exports.MySQLFirewall = exports.PostgreSQLFirewall = exports.FirewallRules = exports.DATABASE_RULES = exports.SQLITE_RULES = exports.ORACLE_RULES = exports.MSSQL_RULES = exports.MARIADB_RULES = exports.MYSQL_RULES = exports.POSTGRESQL_RULES = exports.NIST_CSF_RULES = exports.SOX_RULES = exports.HIPAA_RULES = exports.PCI_DSS_RULES = exports.CIS_BENCHMARK_RULES = exports.OWASP_SQL_INJECTION_PATTERNS = exports.FIREWALL_RULES = exports.getRecommendedRules = exports.FirewallModeEnum = exports.QueryFirewall = exports.BackupVerification = exports.PrivacyImpactAssessment = exports.DSARWorkflow = exports.generateTransferReport = exports.getComplianceTransfers = exports.CrossBorderLog = exports.generateComplianceReport = exports.getPatterns = exports.unregisterPattern = exports.registerPattern = void 0;
74
+ // Audit Trail
75
+ var audit_trail_1 = require("./audit-trail");
76
+ Object.defineProperty(exports, "ComplianceAuditTrail", { enumerable: true, get: function () { return audit_trail_1.ComplianceAuditTrail; } });
77
+ // Field Encryption
78
+ var field_encryption_1 = require("./field-encryption");
79
+ Object.defineProperty(exports, "FieldEncryption", { enumerable: true, get: function () { return field_encryption_1.FieldEncryption; } });
80
+ Object.defineProperty(exports, "configureFieldEncryption", { enumerable: true, get: function () { return field_encryption_1.configureFieldEncryption; } });
81
+ Object.defineProperty(exports, "encryptValue", { enumerable: true, get: function () { return field_encryption_1.encryptValue; } });
82
+ Object.defineProperty(exports, "decryptValue", { enumerable: true, get: function () { return field_encryption_1.decryptValue; } });
83
+ Object.defineProperty(exports, "Encrypt", { enumerable: true, get: function () { return field_encryption_1.Encrypt; } });
84
+ Object.defineProperty(exports, "applyEncryptionHooks", { enumerable: true, get: function () { return field_encryption_1.applyEncryptionHooks; } });
85
+ Object.defineProperty(exports, "getEncryptedFields", { enumerable: true, get: function () { return field_encryption_1.getEncryptedFields; } });
86
+ // TLS Enforcer
87
+ var tls_enforcer_1 = require("./tls-enforcer");
88
+ Object.defineProperty(exports, "TLSEnforcer", { enumerable: true, get: function () { return tls_enforcer_1.TLSEnforcer; } });
89
+ // Data Retention
90
+ var data_retention_1 = require("./data-retention");
91
+ Object.defineProperty(exports, "DataRetentionPolicy", { enumerable: true, get: function () { return data_retention_1.DataRetentionPolicy; } });
92
+ // Right to Erasure
93
+ var right_to_erasure_1 = require("./right-to-erasure");
94
+ Object.defineProperty(exports, "RightToErasure", { enumerable: true, get: function () { return right_to_erasure_1.RightToErasure; } });
95
+ // Consent Record
96
+ var consent_record_1 = require("./consent-record");
97
+ Object.defineProperty(exports, "ConsentRecord", { enumerable: true, get: function () { return consent_record_1.ConsentRecord; } });
98
+ Object.defineProperty(exports, "LegalBasisEnum", { enumerable: true, get: function () { return consent_record_1.LegalBasisEnum; } });
99
+ // Consent Versioning
100
+ var consent_versioning_1 = require("./consent-versioning");
101
+ Object.defineProperty(exports, "ConsentVersioning", { enumerable: true, get: function () { return consent_versioning_1.ConsentVersioning; } });
102
+ // Row Level Security
103
+ var row_level_security_1 = require("./row-level-security");
104
+ Object.defineProperty(exports, "RowLevelSecurity", { enumerable: true, get: function () { return row_level_security_1.RowLevelSecurityAPI; } });
105
+ Object.defineProperty(exports, "RLS", { enumerable: true, get: function () { return row_level_security_1.RLS; } });
106
+ Object.defineProperty(exports, "initRLS", { enumerable: true, get: function () { return row_level_security_1.initRLS; } });
107
+ Object.defineProperty(exports, "apply", { enumerable: true, get: function () { return row_level_security_1.apply; } });
108
+ Object.defineProperty(exports, "setContext", { enumerable: true, get: function () { return row_level_security_1.setContext; } });
109
+ Object.defineProperty(exports, "getContext", { enumerable: true, get: function () { return row_level_security_1.getContext; } });
110
+ Object.defineProperty(exports, "runInContext", { enumerable: true, get: function () { return row_level_security_1.runInContext; } });
111
+ Object.defineProperty(exports, "rlsMiddleware", { enumerable: true, get: function () { return row_level_security_1.rlsMiddleware; } });
112
+ Object.defineProperty(exports, "registerHooks", { enumerable: true, get: function () { return row_level_security_1.registerHooks; } });
113
+ // Data Masker
114
+ var data_masker_1 = require("./data-masker");
115
+ Object.defineProperty(exports, "DataMasker", { enumerable: true, get: function () { return data_masker_1.DataMasker; } });
116
+ Object.defineProperty(exports, "MaskPatternEnum", { enumerable: true, get: function () { return data_masker_1.MaskPatternEnum; } });
117
+ Object.defineProperty(exports, "Mask", { enumerable: true, get: function () { return data_masker_1.Mask; } });
118
+ Object.defineProperty(exports, "maskField", { enumerable: true, get: function () { return data_masker_1.maskField; } });
119
+ Object.defineProperty(exports, "maskValue", { enumerable: true, get: function () { return data_masker_1.maskValue; } });
120
+ Object.defineProperty(exports, "mask", { enumerable: true, get: function () { return data_masker_1.mask; } });
121
+ Object.defineProperty(exports, "maskMany", { enumerable: true, get: function () { return data_masker_1.maskMany; } });
122
+ Object.defineProperty(exports, "applyMaskingHooks", { enumerable: true, get: function () { return data_masker_1.applyHooks; } });
123
+ // Immutable Record
124
+ var immutable_record_1 = require("./immutable-record");
125
+ Object.defineProperty(exports, "ImmutableRecord", { enumerable: true, get: function () { return immutable_record_1.ImmutableRecord; } });
126
+ Object.defineProperty(exports, "makeImmutable", { enumerable: true, get: function () { return immutable_record_1.makeImmutable; } });
127
+ Object.defineProperty(exports, "enableVersioning", { enumerable: true, get: function () { return immutable_record_1.enableVersioning; } });
128
+ Object.defineProperty(exports, "isImmutable", { enumerable: true, get: function () { return immutable_record_1.isImmutable; } });
129
+ // Pseudonymization
130
+ var pseudonymization_1 = require("./pseudonymization");
131
+ Object.defineProperty(exports, "PseudonymizationService", { enumerable: true, get: function () { return pseudonymization_1.PseudonymizationService; } });
132
+ Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return pseudonymization_1.configure; } });
133
+ Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return pseudonymization_1.tokenize; } });
134
+ Object.defineProperty(exports, "detokenize", { enumerable: true, get: function () { return pseudonymization_1.detokenize; } });
135
+ Object.defineProperty(exports, "Pseudonymize", { enumerable: true, get: function () { return pseudonymization_1.Pseudonymize; } });
136
+ Object.defineProperty(exports, "applyPseudonymizationHooks", { enumerable: true, get: function () { return pseudonymization_1.applyHooks; } });
137
+ // Data Portability
138
+ var data_portability_1 = require("./data-portability");
139
+ Object.defineProperty(exports, "DataPortabilityExporter", { enumerable: true, get: function () { return data_portability_1.DataPortabilityExporter; } });
140
+ Object.defineProperty(exports, "exportData", { enumerable: true, get: function () { return data_portability_1.exportData; } });
141
+ Object.defineProperty(exports, "exportStream", { enumerable: true, get: function () { return data_portability_1.exportStream; } });
142
+ Object.defineProperty(exports, "createDSARResponse", { enumerable: true, get: function () { return data_portability_1.createDSARResponse; } });
143
+ // Data Classifier
144
+ var data_classifier_1 = require("./data-classifier");
145
+ Object.defineProperty(exports, "DataClassifier", { enumerable: true, get: function () { return data_classifier_1.DataClassifier; } });
146
+ Object.defineProperty(exports, "Classify", { enumerable: true, get: function () { return data_classifier_1.Classify; } });
147
+ Object.defineProperty(exports, "FieldClassification", { enumerable: true, get: function () { return data_classifier_1.FieldClassification; } });
148
+ Object.defineProperty(exports, "getClassification", { enumerable: true, get: function () { return data_classifier_1.getClassification; } });
149
+ Object.defineProperty(exports, "getPIIFields", { enumerable: true, get: function () { return data_classifier_1.getPIIFields; } });
150
+ Object.defineProperty(exports, "getPHIFields", { enumerable: true, get: function () { return data_classifier_1.getPHIFields; } });
151
+ Object.defineProperty(exports, "getPCIFields", { enumerable: true, get: function () { return data_classifier_1.getPCIFields; } });
152
+ Object.defineProperty(exports, "isSensitive", { enumerable: true, get: function () { return data_classifier_1.isSensitive; } });
153
+ Object.defineProperty(exports, "autoDiscover", { enumerable: true, get: function () { return data_classifier_1.autoDiscover; } });
154
+ // Security Decorator (comprehensive)
155
+ var security_decorator_1 = require("./security-decorator");
156
+ Object.defineProperty(exports, "Security", { enumerable: true, get: function () { return security_decorator_1.Security; } });
157
+ Object.defineProperty(exports, "SecurityFramework", { enumerable: true, get: function () { return security_decorator_1.SecurityFramework; } });
158
+ Object.defineProperty(exports, "AllFrameworks", { enumerable: true, get: function () { return security_decorator_1.AllFrameworks; } });
159
+ Object.defineProperty(exports, "FrameworkCategories", { enumerable: true, get: function () { return security_decorator_1.FrameworkCategories; } });
160
+ Object.defineProperty(exports, "FrameworkRequirements", { enumerable: true, get: function () { return security_decorator_1.FrameworkRequirements; } });
161
+ Object.defineProperty(exports, "FrameworkCount", { enumerable: true, get: function () { return security_decorator_1.FrameworkCount; } });
162
+ Object.defineProperty(exports, "isValidFramework", { enumerable: true, get: function () { return security_decorator_1.isValidFramework; } });
163
+ Object.defineProperty(exports, "getFrameworkCategory", { enumerable: true, get: function () { return security_decorator_1.getFrameworkCategory; } });
164
+ Object.defineProperty(exports, "getAllFrameworks", { enumerable: true, get: function () { return security_decorator_1.getAllFrameworks; } });
165
+ Object.defineProperty(exports, "setupSecurity", { enumerable: true, get: function () { return security_decorator_1.setupSecurity; } });
166
+ Object.defineProperty(exports, "setupAllSecurity", { enumerable: true, get: function () { return security_decorator_1.setupAllSecurity; } });
167
+ Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return security_decorator_1.Table; } });
168
+ Object.defineProperty(exports, "DatabaseSecurity", { enumerable: true, get: function () { return security_decorator_1.Database; } });
169
+ Object.defineProperty(exports, "getTableSecurity", { enumerable: true, get: function () { return security_decorator_1.getTableSecurity; } });
170
+ Object.defineProperty(exports, "getDatabaseSecurity", { enumerable: true, get: function () { return security_decorator_1.getDatabaseSecurity; } });
171
+ Object.defineProperty(exports, "getSecurityFrameworks", { enumerable: true, get: function () { return security_decorator_1.getSecurityFrameworks; } });
172
+ Object.defineProperty(exports, "hasAudit", { enumerable: true, get: function () { return security_decorator_1.hasAudit; } });
173
+ Object.defineProperty(exports, "isImmutableModel", { enumerable: true, get: function () { return security_decorator_1.isImmutableModel; } });
174
+ // Security Monitor (MTAT)
175
+ var security_monitor_1 = require("./security-monitor");
176
+ Object.defineProperty(exports, "SecurityMonitor", { enumerable: true, get: function () { return security_monitor_1.SecurityMonitor; } });
177
+ Object.defineProperty(exports, "ComplianceSecurityMonitor", { enumerable: true, get: function () { return security_monitor_1.ComplianceSecurityMonitor; } });
178
+ Object.defineProperty(exports, "getGlobalMonitor", { enumerable: true, get: function () { return security_monitor_1.getGlobalMonitor; } });
179
+ Object.defineProperty(exports, "initSecurityMonitor", { enumerable: true, get: function () { return security_monitor_1.initSecurityMonitor; } });
180
+ Object.defineProperty(exports, "analyzeQuerySecurity", { enumerable: true, get: function () { return security_monitor_1.analyzeQuerySecurity; } });
181
+ // Breach Detector
182
+ var breach_detector_1 = require("./breach-detector");
183
+ Object.defineProperty(exports, "BreachDetector", { enumerable: true, get: function () { return breach_detector_1.BreachDetector; } });
184
+ Object.defineProperty(exports, "getGlobalBreachDetector", { enumerable: true, get: function () { return breach_detector_1.getGlobalBreachDetector; } });
185
+ Object.defineProperty(exports, "initBreachDetector", { enumerable: true, get: function () { return breach_detector_1.initBreachDetector; } });
186
+ // Session Isolation
187
+ var session_isolation_1 = require("./session-isolation");
188
+ Object.defineProperty(exports, "SessionIsolation", { enumerable: true, get: function () { return session_isolation_1.SessionIsolation; } });
189
+ Object.defineProperty(exports, "TenantIsolation", { enumerable: true, get: function () { return session_isolation_1.TenantIsolation; } });
190
+ Object.defineProperty(exports, "sessionIsolationMiddleware", { enumerable: true, get: function () { return session_isolation_1.sessionIsolationMiddleware; } });
191
+ Object.defineProperty(exports, "getTenantAuditMetadata", { enumerable: true, get: function () { return session_isolation_1.getTenantAuditMetadata; } });
192
+ Object.defineProperty(exports, "getTenantIsolationOptions", { enumerable: true, get: function () { return session_isolation_1.getTenantIsolationOptions; } });
193
+ // WORM Storage (Write Once Read Many)
194
+ var worm_storage_1 = require("./worm-storage");
195
+ Object.defineProperty(exports, "WORMStorage", { enumerable: true, get: function () { return worm_storage_1.WORMStorage; } });
196
+ Object.defineProperty(exports, "WORM", { enumerable: true, get: function () { return worm_storage_1.WORM; } });
197
+ Object.defineProperty(exports, "getWORMOptions", { enumerable: true, get: function () { return worm_storage_1.getWORMOptions; } });
198
+ Object.defineProperty(exports, "applyWORMHooks", { enumerable: true, get: function () { return worm_storage_1.applyWORMHooks; } });
199
+ Object.defineProperty(exports, "isFrozen", { enumerable: true, get: function () { return worm_storage_1.isFrozen; } });
200
+ Object.defineProperty(exports, "isArchived", { enumerable: true, get: function () { return worm_storage_1.isArchived; } });
201
+ // Rate Limiter
202
+ var rate_limiter_1 = require("./rate-limiter");
203
+ Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function () { return rate_limiter_1.RateLimiter; } });
204
+ Object.defineProperty(exports, "RateLimit", { enumerable: true, get: function () { return rate_limiter_1.RateLimit; } });
205
+ Object.defineProperty(exports, "getRateLimitOptions", { enumerable: true, get: function () { return rate_limiter_1.getRateLimitOptions; } });
206
+ Object.defineProperty(exports, "getGlobalLimiter", { enumerable: true, get: function () { return rate_limiter_1.getGlobalLimiter; } });
207
+ Object.defineProperty(exports, "initRateLimiter", { enumerable: true, get: function () { return rate_limiter_1.initRateLimiter; } });
208
+ Object.defineProperty(exports, "checkRateLimit", { enumerable: true, get: function () { return rate_limiter_1.checkRateLimit; } });
209
+ Object.defineProperty(exports, "satisfiesCompliance", { enumerable: true, get: function () { return rate_limiter_1.satisfiesCompliance; } });
210
+ Object.defineProperty(exports, "getRecommendedLimits", { enumerable: true, get: function () { return rate_limiter_1.getRecommendedLimits; } });
211
+ // Sensitive Data Discovery
212
+ var sensitive_data_discovery_1 = require("./sensitive-data-discovery");
213
+ Object.defineProperty(exports, "SensitiveDataDiscovery", { enumerable: true, get: function () { return sensitive_data_discovery_1.SensitiveDataDiscovery; } });
214
+ Object.defineProperty(exports, "registerPattern", { enumerable: true, get: function () { return sensitive_data_discovery_1.registerPattern; } });
215
+ Object.defineProperty(exports, "unregisterPattern", { enumerable: true, get: function () { return sensitive_data_discovery_1.unregisterPattern; } });
216
+ Object.defineProperty(exports, "getPatterns", { enumerable: true, get: function () { return sensitive_data_discovery_1.getPatterns; } });
217
+ Object.defineProperty(exports, "generateComplianceReport", { enumerable: true, get: function () { return sensitive_data_discovery_1.generateComplianceReport; } });
218
+ // Cross-Border Transfer Log
219
+ var cross_border_log_1 = require("./cross-border-log");
220
+ Object.defineProperty(exports, "CrossBorderLog", { enumerable: true, get: function () { return cross_border_log_1.CrossBorderLog; } });
221
+ Object.defineProperty(exports, "getComplianceTransfers", { enumerable: true, get: function () { return cross_border_log_1.getComplianceTransfers; } });
222
+ Object.defineProperty(exports, "generateTransferReport", { enumerable: true, get: function () { return cross_border_log_1.generateTransferReport; } });
223
+ // DSAR Workflow
224
+ var dsar_workflow_1 = require("./dsar-workflow");
225
+ Object.defineProperty(exports, "DSARWorkflow", { enumerable: true, get: function () { return dsar_workflow_1.DSARWorkflow; } });
226
+ // Privacy Impact Assessment (PIA/DPIA)
227
+ var privacy_impact_assessment_1 = require("./privacy-impact-assessment");
228
+ Object.defineProperty(exports, "PrivacyImpactAssessment", { enumerable: true, get: function () { return privacy_impact_assessment_1.PrivacyImpactAssessment; } });
229
+ // Backup Verification
230
+ var backup_verification_1 = require("./backup-verification");
231
+ Object.defineProperty(exports, "BackupVerification", { enumerable: true, get: function () { return backup_verification_1.BackupVerification; } });
232
+ // Query Firewall
233
+ var query_firewall_1 = require("./query-firewall");
234
+ Object.defineProperty(exports, "QueryFirewall", { enumerable: true, get: function () { return query_firewall_1.QueryFirewall; } });
235
+ Object.defineProperty(exports, "FirewallModeEnum", { enumerable: true, get: function () { return query_firewall_1.FirewallModeEnum; } });
236
+ Object.defineProperty(exports, "getRecommendedRules", { enumerable: true, get: function () { return query_firewall_1.getRecommendedRules; } });
237
+ // Rule constants
238
+ Object.defineProperty(exports, "FIREWALL_RULES", { enumerable: true, get: function () { return query_firewall_1.FIREWALL_RULES; } });
239
+ Object.defineProperty(exports, "OWASP_SQL_INJECTION_PATTERNS", { enumerable: true, get: function () { return query_firewall_1.OWASP_SQL_INJECTION_PATTERNS; } });
240
+ Object.defineProperty(exports, "CIS_BENCHMARK_RULES", { enumerable: true, get: function () { return query_firewall_1.CIS_BENCHMARK_RULES; } });
241
+ Object.defineProperty(exports, "PCI_DSS_RULES", { enumerable: true, get: function () { return query_firewall_1.PCI_DSS_RULES; } });
242
+ Object.defineProperty(exports, "HIPAA_RULES", { enumerable: true, get: function () { return query_firewall_1.HIPAA_RULES; } });
243
+ Object.defineProperty(exports, "SOX_RULES", { enumerable: true, get: function () { return query_firewall_1.SOX_RULES; } });
244
+ Object.defineProperty(exports, "NIST_CSF_RULES", { enumerable: true, get: function () { return query_firewall_1.NIST_CSF_RULES; } });
245
+ Object.defineProperty(exports, "POSTGRESQL_RULES", { enumerable: true, get: function () { return query_firewall_1.POSTGRESQL_RULES; } });
246
+ Object.defineProperty(exports, "MYSQL_RULES", { enumerable: true, get: function () { return query_firewall_1.MYSQL_RULES; } });
247
+ Object.defineProperty(exports, "MARIADB_RULES", { enumerable: true, get: function () { return query_firewall_1.MARIADB_RULES; } });
248
+ Object.defineProperty(exports, "MSSQL_RULES", { enumerable: true, get: function () { return query_firewall_1.MSSQL_RULES; } });
249
+ Object.defineProperty(exports, "ORACLE_RULES", { enumerable: true, get: function () { return query_firewall_1.ORACLE_RULES; } });
250
+ Object.defineProperty(exports, "SQLITE_RULES", { enumerable: true, get: function () { return query_firewall_1.SQLITE_RULES; } });
251
+ Object.defineProperty(exports, "DATABASE_RULES", { enumerable: true, get: function () { return query_firewall_1.DATABASE_RULES; } });
252
+ // Decorators
253
+ Object.defineProperty(exports, "FirewallRules", { enumerable: true, get: function () { return query_firewall_1.FirewallRules; } });
254
+ Object.defineProperty(exports, "PostgreSQLFirewall", { enumerable: true, get: function () { return query_firewall_1.PostgreSQLFirewall; } });
255
+ Object.defineProperty(exports, "MySQLFirewall", { enumerable: true, get: function () { return query_firewall_1.MySQLFirewall; } });
256
+ Object.defineProperty(exports, "MariaDBFirewall", { enumerable: true, get: function () { return query_firewall_1.MariaDBFirewall; } });
257
+ Object.defineProperty(exports, "MSSQLFirewall", { enumerable: true, get: function () { return query_firewall_1.MSSQLFirewall; } });
258
+ Object.defineProperty(exports, "OracleFirewall", { enumerable: true, get: function () { return query_firewall_1.OracleFirewall; } });
259
+ Object.defineProperty(exports, "SQLiteFirewall", { enumerable: true, get: function () { return query_firewall_1.SQLiteFirewall; } });
260
+ Object.defineProperty(exports, "applyFirewallRulesToModel", { enumerable: true, get: function () { return query_firewall_1.applyFirewallRulesToModel; } });