ts-prorm-orm 2.0.0 → 2.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.
- package/CHANGELOG.md +132 -0
- package/dist/compliance/data-classifier.d.ts +6 -0
- package/dist/compliance/data-classifier.js +6 -0
- package/dist/compliance/data-lineage.d.ts +4 -0
- package/dist/compliance/data-lineage.js +4 -0
- package/dist/compliance/data-masker.d.ts +4 -0
- package/dist/compliance/data-masker.js +4 -0
- package/dist/compliance/index.d.ts +2 -0
- package/dist/compliance/index.js +2 -0
- package/dist/compliance/pseudonymization.d.ts +4 -0
- package/dist/compliance/pseudonymization.js +4 -0
- package/dist/compliance/query-firewall.d.ts +9 -9
- package/dist/compliance/query-firewall.js +9 -9
- package/dist/compliance/rate-limiter.d.ts +4 -0
- package/dist/compliance/rate-limiter.js +4 -0
- package/dist/compliance/row-level-security.d.ts +2 -0
- package/dist/compliance/row-level-security.js +2 -0
- package/dist/compliance/security-decorator.d.ts +8 -0
- package/dist/compliance/security-decorator.js +8 -0
- package/dist/compliance/session-isolation.d.ts +4 -0
- package/dist/compliance/session-isolation.js +4 -0
- package/dist/compliance/worm-storage.d.ts +4 -0
- package/dist/compliance/worm-storage.js +4 -0
- package/dist/decorators/audit.d.ts +3 -1
- package/dist/decorators/audit.js +3 -1
- package/dist/decorators/check.d.ts +15 -15
- package/dist/decorators/check.js +15 -15
- package/dist/decorators/collate.d.ts +16 -0
- package/dist/decorators/collate.js +16 -0
- package/dist/decorators/comment.d.ts +3 -1
- package/dist/decorators/comment.js +3 -1
- package/dist/decorators/database-settings.d.ts +6 -0
- package/dist/decorators/database-settings.js +6 -0
- package/dist/decorators/default.d.ts +2 -0
- package/dist/decorators/default.js +2 -0
- package/dist/decorators/encryption.d.ts +7 -1
- package/dist/decorators/encryption.js +7 -1
- package/dist/decorators/engine.d.ts +4 -0
- package/dist/decorators/engine.js +4 -0
- package/dist/decorators/fk-constraints.d.ts +32 -32
- package/dist/decorators/fk-constraints.js +32 -32
- package/dist/decorators/foreign-table.d.ts +1 -1
- package/dist/decorators/generated.d.ts +8 -0
- package/dist/decorators/generated.js +8 -0
- package/dist/decorators/hstore.d.ts +6 -0
- package/dist/decorators/hstore.js +6 -0
- package/dist/decorators/json-column.d.ts +2 -0
- package/dist/decorators/json-column.js +2 -0
- package/dist/decorators/jsonb.d.ts +6 -0
- package/dist/decorators/jsonb.js +6 -0
- package/dist/decorators/permissions.d.ts +12 -0
- package/dist/decorators/permissions.js +12 -0
- package/dist/decorators/procedure.d.ts +4 -2
- package/dist/decorators/procedure.js +4 -2
- package/dist/decorators/query-options.d.ts +24 -0
- package/dist/decorators/query-options.js +24 -0
- package/dist/decorators/range.d.ts +8 -0
- package/dist/decorators/range.js +8 -0
- package/dist/decorators/set-column.d.ts +2 -0
- package/dist/decorators/set-column.js +2 -0
- package/dist/decorators/spatial.d.ts +2 -0
- package/dist/decorators/spatial.js +2 -0
- package/dist/decorators/storage.d.ts +24 -0
- package/dist/decorators/storage.js +24 -0
- package/dist/decorators/timezone.d.ts +7 -7
- package/dist/decorators/timezone.js +7 -7
- package/dist/decorators/trigger.d.ts +3 -1
- package/dist/decorators/trigger.js +3 -1
- package/dist/decorators/uuid.d.ts +6 -0
- package/dist/decorators/uuid.js +6 -0
- package/dist/decorators/view.d.ts +7 -1
- package/dist/decorators/view.js +7 -1
- package/dist/dialects/dialect.d.ts +112 -0
- package/dist/external-fields/decorator.d.ts +2 -0
- package/dist/external-fields/decorator.js +2 -0
- package/dist/models/associations.d.ts +38 -0
- package/dist/models/associations.js +16 -0
- package/dist/models/decorators.d.ts +16 -16
- package/dist/models/decorators.js +21 -19
- package/dist/schema-objects.d.ts +42 -0
- package/dist/schema-objects.js +28 -0
- package/dist/types/index.d.ts +334 -0
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,138 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.1.0] - 2026-09-07
|
|
9
|
+
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
- **The documentation is now a guided path rather than a reference dump.** A
|
|
13
|
+
landing page, a getting-started tutorial that runs as written, a stated
|
|
14
|
+
reading order with an editorial hand-off at the end of each page, and an
|
|
15
|
+
overview page for every major section. The dialect and store indexes listed
|
|
16
|
+
12 of 27 and 12 of 88 pages respectively; both are now complete and generated
|
|
17
|
+
from the pages themselves so they cannot drift.
|
|
18
|
+
|
|
19
|
+
- **An API reference generated from the source.** TypeDoc was configured but
|
|
20
|
+
never ran, leaving 11,098 TSDoc blocks invisible; it now builds in CI and
|
|
21
|
+
ships at `/reference`. TSDoc coverage of exported declarations rose from
|
|
22
|
+
81.2% to 86.0%, and 97 usage examples that TypeDoc had been parsing as block
|
|
23
|
+
tags — rendering as mangled tag soup — are fenced correctly.
|
|
24
|
+
|
|
25
|
+
- **The viewer gained** collapsible grouped navigation (stores was 89 links in
|
|
26
|
+
one flat list), breadcrumbs, in-page contents, heading anchors, callouts,
|
|
27
|
+
mermaid diagrams and Ace syntax highlighting — with eleven Playwright smoke
|
|
28
|
+
tests covering it, since it is the one component that cannot be verified
|
|
29
|
+
without a browser.
|
|
30
|
+
|
|
31
|
+
- **All Vercel content is gone.** The 12 guides under `guides/docker/` were
|
|
32
|
+
written around Vercel Sandbox despite the directory name; each is rewritten
|
|
33
|
+
against real Docker using the images and credentials `docker-compose.test.yml`
|
|
34
|
+
already uses. `runbooks/rollback.md` described three things that no longer
|
|
35
|
+
exist and now documents the GitLab Pages deploy. What stays is
|
|
36
|
+
`stores/vercel-kv.md`: Vercel KV is a supported data store, not deployment
|
|
37
|
+
cruft.
|
|
38
|
+
|
|
39
|
+
### Security
|
|
40
|
+
|
|
41
|
+
- **Cleared every HIGH and CRITICAL dependency advisory** (40 issues / 123
|
|
42
|
+
vulnerable paths at the start, including one Critical). `npm audit` goes from
|
|
43
|
+
46 findings (19 high, 2 critical) to 16 (0 high, 0 critical); everything left
|
|
44
|
+
is moderate or low.
|
|
45
|
+
|
|
46
|
+
Most of it was lockfile staleness rather than unfixable advisories — the
|
|
47
|
+
declared ranges already permitted the patched versions. Refreshing within
|
|
48
|
+
those ranges moved `undici` 7.28.0 → 7.29.1 (the Critical: improper
|
|
49
|
+
certificate validation), `tar` 6.2.1 → 7.5.22, `mysql2` 3.20.0 → 3.24.3,
|
|
50
|
+
`mariadb` 3.5.2 → 3.5.4, `@xmldom/xmldom` 0.9.10 → 0.9.12 (11 advisories),
|
|
51
|
+
`thrift` 0.23.0 → 0.24.0, `protobufjs` 7.6.4 → 7.6.6, `browserslist` 4.28.1 →
|
|
52
|
+
4.28.9, `fast-xml-parser` 5.9.3 → 5.11.1 and `brace-expansion` to 1.1.18 /
|
|
53
|
+
2.1.4 / 5.0.9.
|
|
54
|
+
|
|
55
|
+
Three `overrides` cover transitives whose parents pin a vulnerable version:
|
|
56
|
+
`adm-zip` ^0.6.0 (pinned by `ibm_db`), `toml` ^5.0.0 (pinned by
|
|
57
|
+
`snowflake-sdk` at ^3.0.0) and `node-gyp` ^11.4.2, which pulls modern
|
|
58
|
+
`cacache` (19.0.1), `make-fetch-happen` (14.0.3) and `tar` 7.x through the
|
|
59
|
+
native-build toolchain. Note that npm `overrides` apply to this repository's
|
|
60
|
+
own install and are **not** inherited by packages that depend on
|
|
61
|
+
ts-prorm-orm.
|
|
62
|
+
|
|
63
|
+
npm proposed "fixes" that were actually downgrades — `ibm_db` 4.0.1 → 3.1.0
|
|
64
|
+
and `snowflake-sdk` 3.0.0 → 1.11.0. Those were rejected; the overrides above
|
|
65
|
+
address the same advisories without giving up a major version of DB2 or
|
|
66
|
+
Snowflake support.
|
|
67
|
+
|
|
68
|
+
- **Two advisories are accepted rather than fixed, in a documented `.snyk`
|
|
69
|
+
policy.** Both are HIGH, transitive, and have no upgrade available today; the
|
|
70
|
+
other 38 issues were fixed by moving to patched versions, not ignored. Each
|
|
71
|
+
entry carries a reason and a 2026-12-06 expiry so it has to be re-argued
|
|
72
|
+
rather than quietly living forever.
|
|
73
|
+
|
|
74
|
+
`adm-zip` (Symlink Attack) has **no fixed version at all** — 0.6.0 is the
|
|
75
|
+
latest release. It arrives only through `ibm_db`, and only in
|
|
76
|
+
`installer/driverInstall.js`, which unzips IBM's own CLI driver bundle at
|
|
77
|
+
install time; nothing in `ibm_db/lib` reaches it, and `allowScripts` does not
|
|
78
|
+
approve `ibm_db`, so that installer never runs here anyway.
|
|
79
|
+
|
|
80
|
+
`@opentelemetry/core` (unbounded resource allocation) *is* fixed in 2.8.0,
|
|
81
|
+
but that fix is unreachable: `@google-cloud/spanner` depends on the OTel 1.x
|
|
82
|
+
API, and `@opentelemetry/resources@1.30.1` pins core to exactly 1.30.1, so
|
|
83
|
+
core cannot move alone. Overriding the whole stack to 2.x was tried and
|
|
84
|
+
verified to break Spanner outright — `require('@google-cloud/spanner')`
|
|
85
|
+
throws `ExplicitBucketHistogramAggregation is not a constructor` — so the
|
|
86
|
+
override was reverted rather than shipping a broken Spanner dialect.
|
|
87
|
+
|
|
88
|
+
### Removed
|
|
89
|
+
|
|
90
|
+
- **`sqlite3` is no longer a dependency.** Nothing in the codebase imported it
|
|
91
|
+
— SQLite runs on `better-sqlite3` (and `bun:sqlite` under Bun), which the
|
|
92
|
+
driver loader selects at runtime. It was a hard dependency, so every consumer
|
|
93
|
+
compiled a native addon for a package that was never loaded, and it dragged
|
|
94
|
+
in the vulnerable `node-gyp` 8.x / `cacache` 15.x / `tar` 6.2.1 toolchain.
|
|
95
|
+
Installs are smaller and one native build lighter.
|
|
96
|
+
|
|
97
|
+
- **The CI pipeline drops from 77 jobs to 13.** `db.gitlab-ci.yml` and its 59
|
|
98
|
+
`mirror:*` jobs are gone: each pulled a multi-gigabyte database image through
|
|
99
|
+
docker-in-docker and pushed it to this project's registry, purely so the
|
|
100
|
+
Docker guides could pull from a registry we control — and those guides now
|
|
101
|
+
pull from Docker Hub directly, so the jobs had no remaining consumer. The 18
|
|
102
|
+
`db-*` category stages went with them.
|
|
103
|
+
|
|
104
|
+
Also removed: the `test` shard matrix, `test:coverage`, `tf:plan` and
|
|
105
|
+
`tf:drift`. **The test suite no longer runs in CI**; `build:node22` (tsc) and
|
|
106
|
+
`lint` are the automated gates on a push. The full suite still runs through
|
|
107
|
+
`prepublishOnly` on the tag-triggered `publish` job — but not on
|
|
108
|
+
`publish:npm`, which uses `--ignore-scripts`.
|
|
109
|
+
|
|
110
|
+
### Changed
|
|
111
|
+
|
|
112
|
+
- **Pinned `@qdrant/js-client-rest` to `~1.18.0`.** 1.19.0 removed `search()`
|
|
113
|
+
and `searchBatch()` in a *minor* release; their replacements (`query()` /
|
|
114
|
+
`queryBatch()`) take a different request shape and return `{ points }`
|
|
115
|
+
instead of an array, so adopting them would change the public signature of
|
|
116
|
+
`QdrantStore.searchBatch()`. Pinning keeps the API stable and still clears
|
|
117
|
+
the advisory, because 1.18.0's `undici ^6.24.0` range resolves to the fixed
|
|
118
|
+
6.28.1. Migrating to the query API is deliberate future work.
|
|
119
|
+
|
|
120
|
+
### Fixed
|
|
121
|
+
|
|
122
|
+
- **`allowScripts` no longer silently skips the native build.** It approved
|
|
123
|
+
`better-sqlite3@12.8.0` by exact version, so refreshing the lockfile to
|
|
124
|
+
12.11.1 blocked the `node-gyp` install script — leaving no compiled binding
|
|
125
|
+
and failing 155 suites / 2,283 tests with no obvious cause. npm rejects
|
|
126
|
+
semver ranges in this field, so the entry now lists exact versions joined by
|
|
127
|
+
`||`. Note that after changing it you must `npm rebuild`, because npm only
|
|
128
|
+
runs install scripts when it actually (re)installs a package.
|
|
129
|
+
- **`sbom` no longer fails on peer-dependency noise.** `cyclonedx-npm` shells
|
|
130
|
+
out to `npm ls`, which exits `ELSPROBLEMS` because the root install uses
|
|
131
|
+
`--legacy-peer-deps`; `--ignore-npm-errors` tolerates it.
|
|
132
|
+
- **`snyk:code` no longer blocks on a missing entitlement.** Snyk Code is
|
|
133
|
+
separately licensed and returns `403 Forbidden (SNYK-CLI-0000)` with no
|
|
134
|
+
findings when the org lacks it — a licensing state, not a security result.
|
|
135
|
+
- **The documentation site can actually deploy.** `pages` had no `needs:`, so
|
|
136
|
+
it waited on every earlier stage and was silently blocked by unrelated
|
|
137
|
+
security-scan failures. It is decoupled with `needs: []`; the security jobs
|
|
138
|
+
still gate the pipeline, just not the docs.
|
|
139
|
+
|
|
8
140
|
## [2.0.0]
|
|
9
141
|
|
|
10
142
|
### Breaking
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* PIPL, AI Act EU, GDPR Art 25/30/32, and data classification requirements.
|
|
11
11
|
*
|
|
12
12
|
* Usage:
|
|
13
|
+
* ```ts
|
|
13
14
|
* // Tag fields with sensitivity levels:
|
|
14
15
|
* @Classify('PII')
|
|
15
16
|
* @FieldClassification('email', 'PII')
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
*
|
|
26
27
|
* // Auto-discover fields by name patterns:
|
|
27
28
|
* DataClassifier.autoDiscover(User, ['ssn', 'social', 'dob', 'card', 'password']);
|
|
29
|
+
* ```
|
|
28
30
|
*/
|
|
29
31
|
export type SensitivityLevel = 'PUBLIC' | 'INTERNAL' | 'CONFIDENTIAL' | 'SECRET' | 'TOP_SECRET';
|
|
30
32
|
export type DataCategory = 'PII' | 'PHI' | 'PCI' | 'PCI_PAN' | 'FINANCIAL' | 'HEALTH' | 'BIOMETRIC' | 'CUI' | 'SENSITIVE';
|
|
@@ -45,16 +47,20 @@ export interface ClassificationMetadata {
|
|
|
45
47
|
/**
|
|
46
48
|
* Classify the entire model (applies to all fields, use field-level for specifics).
|
|
47
49
|
*
|
|
50
|
+
* ```ts
|
|
48
51
|
* @Classify('CONFIDENTIAL')
|
|
49
52
|
* class FinancialRecord extends Model { ... }
|
|
53
|
+
* ```
|
|
50
54
|
*/
|
|
51
55
|
export declare function Classify(level: SensitivityLevel): (target: Function) => void;
|
|
52
56
|
/**
|
|
53
57
|
* Classify a specific field.
|
|
54
58
|
*
|
|
59
|
+
* ```ts
|
|
55
60
|
* @FieldClassification('email', 'PII')
|
|
56
61
|
* @FieldClassification('ssn', 'PHI', { level: 'SECRET', regulations: ['HIPAA'] })
|
|
57
62
|
* @FieldClassification('creditCard', 'PCI_PAN', { level: 'TOP_SECRET' })
|
|
63
|
+
* ```
|
|
58
64
|
*/
|
|
59
65
|
export declare function FieldClassification(field: string, category: DataCategory, options?: Partial<ClassificationMetadata>): (target: Function) => void;
|
|
60
66
|
/**
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* PIPL, AI Act EU, GDPR Art 25/30/32, and data classification requirements.
|
|
12
12
|
*
|
|
13
13
|
* Usage:
|
|
14
|
+
* ```ts
|
|
14
15
|
* // Tag fields with sensitivity levels:
|
|
15
16
|
* @Classify('PII')
|
|
16
17
|
* @FieldClassification('email', 'PII')
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
*
|
|
27
28
|
* // Auto-discover fields by name patterns:
|
|
28
29
|
* DataClassifier.autoDiscover(User, ['ssn', 'social', 'dob', 'card', 'password']);
|
|
30
|
+
* ```
|
|
29
31
|
*/
|
|
30
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
33
|
exports.DataClassifier = void 0;
|
|
@@ -54,8 +56,10 @@ function getClassifications(target) {
|
|
|
54
56
|
/**
|
|
55
57
|
* Classify the entire model (applies to all fields, use field-level for specifics).
|
|
56
58
|
*
|
|
59
|
+
* ```ts
|
|
57
60
|
* @Classify('CONFIDENTIAL')
|
|
58
61
|
* class FinancialRecord extends Model { ... }
|
|
62
|
+
* ```
|
|
59
63
|
*/
|
|
60
64
|
function Classify(level) {
|
|
61
65
|
return function (target) {
|
|
@@ -68,9 +72,11 @@ function Classify(level) {
|
|
|
68
72
|
/**
|
|
69
73
|
* Classify a specific field.
|
|
70
74
|
*
|
|
75
|
+
* ```ts
|
|
71
76
|
* @FieldClassification('email', 'PII')
|
|
72
77
|
* @FieldClassification('ssn', 'PHI', { level: 'SECRET', regulations: ['HIPAA'] })
|
|
73
78
|
* @FieldClassification('creditCard', 'PCI_PAN', { level: 'TOP_SECRET' })
|
|
79
|
+
* ```
|
|
74
80
|
*/
|
|
75
81
|
function FieldClassification(field, category, options = {}) {
|
|
76
82
|
return function (target) {
|
|
@@ -25,9 +25,11 @@
|
|
|
25
25
|
* // Get transformation history:
|
|
26
26
|
* const transforms = await DataLineage.getTransformations(orderId, 'Orders');
|
|
27
27
|
*
|
|
28
|
+
* ```ts
|
|
28
29
|
* // Using the decorator:
|
|
29
30
|
* @LineageTrack({ fields: ['amount', 'total'] })
|
|
30
31
|
* class Order extends Model { ... }
|
|
32
|
+
* ```
|
|
31
33
|
*/
|
|
32
34
|
import { ModelStatic, Prorm } from '../prorm';
|
|
33
35
|
/** The origin of data - how it entered the system */
|
|
@@ -128,8 +130,10 @@ export interface LineageTrackOptions {
|
|
|
128
130
|
/**
|
|
129
131
|
* Decorator to mark fields for lineage tracking.
|
|
130
132
|
*
|
|
133
|
+
* ```ts
|
|
131
134
|
* @LineageTrack({ fields: ['amount', 'total', 'tax'] })
|
|
132
135
|
* class Order extends Model { ... }
|
|
136
|
+
* ```
|
|
133
137
|
*/
|
|
134
138
|
export declare function LineageTrack(options?: LineageTrackOptions): (target: Function) => void;
|
|
135
139
|
/**
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
* // Get transformation history:
|
|
27
27
|
* const transforms = await DataLineage.getTransformations(orderId, 'Orders');
|
|
28
28
|
*
|
|
29
|
+
* ```ts
|
|
29
30
|
* // Using the decorator:
|
|
30
31
|
* @LineageTrack({ fields: ['amount', 'total'] })
|
|
31
32
|
* class Order extends Model { ... }
|
|
33
|
+
* ```
|
|
32
34
|
*/
|
|
33
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
36
|
exports.DataLineage = void 0;
|
|
@@ -46,8 +48,10 @@ const lineageRegistry = new Map();
|
|
|
46
48
|
/**
|
|
47
49
|
* Decorator to mark fields for lineage tracking.
|
|
48
50
|
*
|
|
51
|
+
* ```ts
|
|
49
52
|
* @LineageTrack({ fields: ['amount', 'total', 'tax'] })
|
|
50
53
|
* class Order extends Model { ... }
|
|
54
|
+
* ```
|
|
51
55
|
*/
|
|
52
56
|
function LineageTrack(options = {}) {
|
|
53
57
|
return function (target) {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* DataMasker.maskField(Payment, 'cardNumber', { pattern: 'card-last4', showLast: 4 });
|
|
16
16
|
* DataMasker.maskField(Customer, 'email', { pattern: 'email' });
|
|
17
17
|
*
|
|
18
|
+
* ```ts
|
|
18
19
|
* // Or use the decorator:
|
|
19
20
|
* @Mask('ssn', { pattern: 'ssn' })
|
|
20
21
|
* class User extends Model { ... }
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
*
|
|
26
27
|
* // Or use the automatic hook:
|
|
27
28
|
* DataMasker.applyHooks(User);
|
|
29
|
+
* ```
|
|
28
30
|
*/
|
|
29
31
|
/** Built-in masking pattern identifiers; see {@link MaskPatternEnum} for the enum form. */
|
|
30
32
|
export type MaskPattern = 'ssn' | 'card-last4' | 'card-first6' | 'email' | 'phone' | 'full' | 'none' | 'custom';
|
|
@@ -71,8 +73,10 @@ export declare function getMaskRules(Model: any): MaskRule[];
|
|
|
71
73
|
/**
|
|
72
74
|
* Decorator to mark a field for masking.
|
|
73
75
|
*
|
|
76
|
+
* ```ts
|
|
74
77
|
* @Mask('ssn', { pattern: 'ssn' })
|
|
75
78
|
* class User extends Model { ... }
|
|
79
|
+
* ```
|
|
76
80
|
*/
|
|
77
81
|
export declare function Mask(field: string, options?: MaskOptions): (target: Function) => void;
|
|
78
82
|
/**
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* DataMasker.maskField(Payment, 'cardNumber', { pattern: 'card-last4', showLast: 4 });
|
|
17
17
|
* DataMasker.maskField(Customer, 'email', { pattern: 'email' });
|
|
18
18
|
*
|
|
19
|
+
* ```ts
|
|
19
20
|
* // Or use the decorator:
|
|
20
21
|
* @Mask('ssn', { pattern: 'ssn' })
|
|
21
22
|
* class User extends Model { ... }
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
*
|
|
27
28
|
* // Or use the automatic hook:
|
|
28
29
|
* DataMasker.applyHooks(User);
|
|
30
|
+
* ```
|
|
29
31
|
*/
|
|
30
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
33
|
exports.DataMasker = exports.MaskPatternEnum = void 0;
|
|
@@ -197,8 +199,10 @@ function getMaskRules(Model) {
|
|
|
197
199
|
/**
|
|
198
200
|
* Decorator to mark a field for masking.
|
|
199
201
|
*
|
|
202
|
+
* ```ts
|
|
200
203
|
* @Mask('ssn', { pattern: 'ssn' })
|
|
201
204
|
* class User extends Model { ... }
|
|
205
|
+
* ```
|
|
202
206
|
*/
|
|
203
207
|
function Mask(field, options = {}) {
|
|
204
208
|
return function (target) {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* import { ComplianceAuditTrail } from './compliance/audit-trail';
|
|
16
16
|
* ComplianceAuditTrail.enable(prorm, UserModel, { getUserId: () => user.id });
|
|
17
17
|
*
|
|
18
|
+
* ```ts
|
|
18
19
|
* // 2. Field-level AES-256-GCM encryption
|
|
19
20
|
* import { FieldEncryption } from './compliance/field-encryption';
|
|
20
21
|
* FieldEncryption.configure('32-byte-hex-key');
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
* import { DataClassifier } from './compliance/data-classifier';
|
|
66
67
|
* @FieldClassification('email', 'PII') class User extends Model {}
|
|
67
68
|
* const piiFields = DataClassifier.getPIIFields(User);
|
|
69
|
+
* ```
|
|
68
70
|
*/
|
|
69
71
|
export { ComplianceAuditTrail, AuditTrailOptions } from './audit-trail';
|
|
70
72
|
export { FieldEncryption, configureFieldEncryption, encryptValue, decryptValue, Encrypt, applyEncryptionHooks, getEncryptedFields, } from './field-encryption';
|
package/dist/compliance/index.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* import { ComplianceAuditTrail } from './compliance/audit-trail';
|
|
17
17
|
* ComplianceAuditTrail.enable(prorm, UserModel, { getUserId: () => user.id });
|
|
18
18
|
*
|
|
19
|
+
* ```ts
|
|
19
20
|
* // 2. Field-level AES-256-GCM encryption
|
|
20
21
|
* import { FieldEncryption } from './compliance/field-encryption';
|
|
21
22
|
* FieldEncryption.configure('32-byte-hex-key');
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
* import { DataClassifier } from './compliance/data-classifier';
|
|
67
68
|
* @FieldClassification('email', 'PII') class User extends Model {}
|
|
68
69
|
* const piiFields = DataClassifier.getPIIFields(User);
|
|
70
|
+
* ```
|
|
69
71
|
*/
|
|
70
72
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
73
|
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;
|
|
@@ -24,12 +24,14 @@
|
|
|
24
24
|
* const original = await PseudonymizationService.detokenize(token);
|
|
25
25
|
* // original: 'user-123'
|
|
26
26
|
*
|
|
27
|
+
* ```ts
|
|
27
28
|
* // Or use the decorator on a model field:
|
|
28
29
|
* @Pseudonymize('nationalId')
|
|
29
30
|
* class Patient extends Model { ... }
|
|
30
31
|
*
|
|
31
32
|
* // Apply hooks to auto-tokenize on write:
|
|
32
33
|
* PseudonymizationService.applyHooks(Patient, 'nationalId');
|
|
34
|
+
* ```
|
|
33
35
|
*/
|
|
34
36
|
export type StorageMode = 'memory' | 'database';
|
|
35
37
|
export interface PseudonymizationConfig {
|
|
@@ -73,8 +75,10 @@ export declare function getPseudonymizedFields(target: Function): string[];
|
|
|
73
75
|
/**
|
|
74
76
|
* Mark a field for automatic pseudonymization.
|
|
75
77
|
*
|
|
78
|
+
* ```ts
|
|
76
79
|
* @Pseudonymize('nationalId')
|
|
77
80
|
* class Patient extends Model { ... }
|
|
81
|
+
* ```
|
|
78
82
|
*/
|
|
79
83
|
export declare function Pseudonymize(field: string): (target: Function) => void;
|
|
80
84
|
/**
|
|
@@ -25,12 +25,14 @@
|
|
|
25
25
|
* const original = await PseudonymizationService.detokenize(token);
|
|
26
26
|
* // original: 'user-123'
|
|
27
27
|
*
|
|
28
|
+
* ```ts
|
|
28
29
|
* // Or use the decorator on a model field:
|
|
29
30
|
* @Pseudonymize('nationalId')
|
|
30
31
|
* class Patient extends Model { ... }
|
|
31
32
|
*
|
|
32
33
|
* // Apply hooks to auto-tokenize on write:
|
|
33
34
|
* PseudonymizationService.applyHooks(Patient, 'nationalId');
|
|
35
|
+
* ```
|
|
34
36
|
*/
|
|
35
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
38
|
exports.PseudonymizationService = void 0;
|
|
@@ -207,8 +209,10 @@ function getPseudonymizedFields(target) {
|
|
|
207
209
|
/**
|
|
208
210
|
* Mark a field for automatic pseudonymization.
|
|
209
211
|
*
|
|
212
|
+
* ```ts
|
|
210
213
|
* @Pseudonymize('nationalId')
|
|
211
214
|
* class Patient extends Model { ... }
|
|
215
|
+
* ```
|
|
212
216
|
*/
|
|
213
217
|
function Pseudonymize(field) {
|
|
214
218
|
return function (target) {
|
|
@@ -585,21 +585,21 @@ export interface FirewallRuleDecoratorOptions {
|
|
|
585
585
|
*
|
|
586
586
|
* @example
|
|
587
587
|
* // Block destructive operations and file operations on a model
|
|
588
|
-
*
|
|
588
|
+
* `@FirewallRules`({
|
|
589
589
|
* blockDestructive: true,
|
|
590
590
|
* blockFileOperations: true,
|
|
591
591
|
* })
|
|
592
592
|
* class SensitiveData extends Model { ... }
|
|
593
593
|
*
|
|
594
594
|
* // Apply database-specific rules
|
|
595
|
-
*
|
|
595
|
+
* `@FirewallRules`({
|
|
596
596
|
* database: 'postgresql',
|
|
597
597
|
* blockCodeExecution: true,
|
|
598
598
|
* })
|
|
599
599
|
* class UserDefinedFunction extends Model { ... }
|
|
600
600
|
*
|
|
601
601
|
* // Custom rules
|
|
602
|
-
*
|
|
602
|
+
* `@FirewallRules`({
|
|
603
603
|
* rules: [
|
|
604
604
|
* { pattern: /^SELECT\s+FROM\s+logs/i, description: 'Block log access' },
|
|
605
605
|
* ],
|
|
@@ -611,7 +611,7 @@ export declare function FirewallRules(options?: FirewallRuleDecoratorOptions): (
|
|
|
611
611
|
* Decorator for PostgreSQL-specific firewall rules
|
|
612
612
|
*
|
|
613
613
|
* @example
|
|
614
|
-
*
|
|
614
|
+
* `@PostgreSQLFirewall`()
|
|
615
615
|
* class PostgresSensitive extends Model { ... }
|
|
616
616
|
*/
|
|
617
617
|
export declare function PostgreSQLFirewall(): (target: any) => void;
|
|
@@ -619,7 +619,7 @@ export declare function PostgreSQLFirewall(): (target: any) => void;
|
|
|
619
619
|
* Decorator for MySQL-specific firewall rules
|
|
620
620
|
*
|
|
621
621
|
* @example
|
|
622
|
-
*
|
|
622
|
+
* `@MySQLFirewall`()
|
|
623
623
|
* class MySQLSensitive extends Model { ... }
|
|
624
624
|
*/
|
|
625
625
|
export declare function MySQLFirewall(): (target: any) => void;
|
|
@@ -627,7 +627,7 @@ export declare function MySQLFirewall(): (target: any) => void;
|
|
|
627
627
|
* Decorator for MariaDB-specific firewall rules
|
|
628
628
|
*
|
|
629
629
|
* @example
|
|
630
|
-
*
|
|
630
|
+
* `@MariaDBFirewall`()
|
|
631
631
|
* class MariaDBSensitive extends Model { ... }
|
|
632
632
|
*/
|
|
633
633
|
export declare function MariaDBFirewall(): (target: any) => void;
|
|
@@ -635,7 +635,7 @@ export declare function MariaDBFirewall(): (target: any) => void;
|
|
|
635
635
|
* Decorator for SQL Server-specific firewall rules
|
|
636
636
|
*
|
|
637
637
|
* @example
|
|
638
|
-
*
|
|
638
|
+
* `@MSSQLFirewall`()
|
|
639
639
|
* class MSSQLSensitive extends Model { ... }
|
|
640
640
|
*/
|
|
641
641
|
export declare function MSSQLFirewall(): (target: any) => void;
|
|
@@ -643,7 +643,7 @@ export declare function MSSQLFirewall(): (target: any) => void;
|
|
|
643
643
|
* Decorator for Oracle-specific firewall rules
|
|
644
644
|
*
|
|
645
645
|
* @example
|
|
646
|
-
*
|
|
646
|
+
* `@OracleFirewall`()
|
|
647
647
|
* class OracleSensitive extends Model { ... }
|
|
648
648
|
*/
|
|
649
649
|
export declare function OracleFirewall(): (target: any) => void;
|
|
@@ -651,7 +651,7 @@ export declare function OracleFirewall(): (target: any) => void;
|
|
|
651
651
|
* Decorator for SQLite-specific firewall rules
|
|
652
652
|
*
|
|
653
653
|
* @example
|
|
654
|
-
*
|
|
654
|
+
* `@SQLiteFirewall`()
|
|
655
655
|
* class SQLiteSensitive extends Model { ... }
|
|
656
656
|
*/
|
|
657
657
|
export declare function SQLiteFirewall(): (target: any) => void;
|
|
@@ -1009,21 +1009,21 @@ const FIREWALL_DATABASE_KEY = Symbol('__orm_firewall_database__');
|
|
|
1009
1009
|
*
|
|
1010
1010
|
* @example
|
|
1011
1011
|
* // Block destructive operations and file operations on a model
|
|
1012
|
-
*
|
|
1012
|
+
* `@FirewallRules`({
|
|
1013
1013
|
* blockDestructive: true,
|
|
1014
1014
|
* blockFileOperations: true,
|
|
1015
1015
|
* })
|
|
1016
1016
|
* class SensitiveData extends Model { ... }
|
|
1017
1017
|
*
|
|
1018
1018
|
* // Apply database-specific rules
|
|
1019
|
-
*
|
|
1019
|
+
* `@FirewallRules`({
|
|
1020
1020
|
* database: 'postgresql',
|
|
1021
1021
|
* blockCodeExecution: true,
|
|
1022
1022
|
* })
|
|
1023
1023
|
* class UserDefinedFunction extends Model { ... }
|
|
1024
1024
|
*
|
|
1025
1025
|
* // Custom rules
|
|
1026
|
-
*
|
|
1026
|
+
* `@FirewallRules`({
|
|
1027
1027
|
* rules: [
|
|
1028
1028
|
* { pattern: /^SELECT\s+FROM\s+logs/i, description: 'Block log access' },
|
|
1029
1029
|
* ],
|
|
@@ -1075,7 +1075,7 @@ function FirewallRules(options = {}) {
|
|
|
1075
1075
|
* Decorator for PostgreSQL-specific firewall rules
|
|
1076
1076
|
*
|
|
1077
1077
|
* @example
|
|
1078
|
-
*
|
|
1078
|
+
* `@PostgreSQLFirewall`()
|
|
1079
1079
|
* class PostgresSensitive extends Model { ... }
|
|
1080
1080
|
*/
|
|
1081
1081
|
function PostgreSQLFirewall() {
|
|
@@ -1085,7 +1085,7 @@ function PostgreSQLFirewall() {
|
|
|
1085
1085
|
* Decorator for MySQL-specific firewall rules
|
|
1086
1086
|
*
|
|
1087
1087
|
* @example
|
|
1088
|
-
*
|
|
1088
|
+
* `@MySQLFirewall`()
|
|
1089
1089
|
* class MySQLSensitive extends Model { ... }
|
|
1090
1090
|
*/
|
|
1091
1091
|
function MySQLFirewall() {
|
|
@@ -1095,7 +1095,7 @@ function MySQLFirewall() {
|
|
|
1095
1095
|
* Decorator for MariaDB-specific firewall rules
|
|
1096
1096
|
*
|
|
1097
1097
|
* @example
|
|
1098
|
-
*
|
|
1098
|
+
* `@MariaDBFirewall`()
|
|
1099
1099
|
* class MariaDBSensitive extends Model { ... }
|
|
1100
1100
|
*/
|
|
1101
1101
|
function MariaDBFirewall() {
|
|
@@ -1105,7 +1105,7 @@ function MariaDBFirewall() {
|
|
|
1105
1105
|
* Decorator for SQL Server-specific firewall rules
|
|
1106
1106
|
*
|
|
1107
1107
|
* @example
|
|
1108
|
-
*
|
|
1108
|
+
* `@MSSQLFirewall`()
|
|
1109
1109
|
* class MSSQLSensitive extends Model { ... }
|
|
1110
1110
|
*/
|
|
1111
1111
|
function MSSQLFirewall() {
|
|
@@ -1115,7 +1115,7 @@ function MSSQLFirewall() {
|
|
|
1115
1115
|
* Decorator for Oracle-specific firewall rules
|
|
1116
1116
|
*
|
|
1117
1117
|
* @example
|
|
1118
|
-
*
|
|
1118
|
+
* `@OracleFirewall`()
|
|
1119
1119
|
* class OracleSensitive extends Model { ... }
|
|
1120
1120
|
*/
|
|
1121
1121
|
function OracleFirewall() {
|
|
@@ -1125,7 +1125,7 @@ function OracleFirewall() {
|
|
|
1125
1125
|
* Decorator for SQLite-specific firewall rules
|
|
1126
1126
|
*
|
|
1127
1127
|
* @example
|
|
1128
|
-
*
|
|
1128
|
+
* `@SQLiteFirewall`()
|
|
1129
1129
|
* class SQLiteSensitive extends Model { ... }
|
|
1130
1130
|
*/
|
|
1131
1131
|
function SQLiteFirewall() {
|
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
* limiter.reset();
|
|
31
31
|
*
|
|
32
32
|
* Decorator usage:
|
|
33
|
+
* ```ts
|
|
33
34
|
* @RateLimit({ perMinute: 100, perHour: 1000 })
|
|
34
35
|
* class User extends Model { ... }
|
|
36
|
+
* ```
|
|
35
37
|
*/
|
|
36
38
|
import { Prorm } from '../prorm';
|
|
37
39
|
import type { ModelStatic } from '../types';
|
|
@@ -173,8 +175,10 @@ export interface RateLimitDecoratorOptions {
|
|
|
173
175
|
* Rate limit decorator for models
|
|
174
176
|
*
|
|
175
177
|
* Usage:
|
|
178
|
+
* ```ts
|
|
176
179
|
* @RateLimit({ perMinute: 100, perHour: 1000 })
|
|
177
180
|
* class User extends Model { ... }
|
|
181
|
+
* ```
|
|
178
182
|
*/
|
|
179
183
|
export declare function RateLimit(options: RateLimitDecoratorOptions): <T extends ModelStatic<any>>(target: T) => T;
|
|
180
184
|
/**
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
* limiter.reset();
|
|
32
32
|
*
|
|
33
33
|
* Decorator usage:
|
|
34
|
+
* ```ts
|
|
34
35
|
* @RateLimit({ perMinute: 100, perHour: 1000 })
|
|
35
36
|
* class User extends Model { ... }
|
|
37
|
+
* ```
|
|
36
38
|
*/
|
|
37
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
40
|
exports.RateLimiter = void 0;
|
|
@@ -469,8 +471,10 @@ exports.RateLimiter = RateLimiter;
|
|
|
469
471
|
* Rate limit decorator for models
|
|
470
472
|
*
|
|
471
473
|
* Usage:
|
|
474
|
+
* ```ts
|
|
472
475
|
* @RateLimit({ perMinute: 100, perHour: 1000 })
|
|
473
476
|
* class User extends Model { ... }
|
|
477
|
+
* ```
|
|
474
478
|
*/
|
|
475
479
|
function RateLimit(options) {
|
|
476
480
|
return function (target) {
|
|
@@ -96,8 +96,10 @@ export declare function getFilteredQuery(Model: any): {
|
|
|
96
96
|
/**
|
|
97
97
|
* Decorator to apply RLS to a model class.
|
|
98
98
|
*
|
|
99
|
+
* ```ts
|
|
99
100
|
* @RowLevelSecurity((ctx) => ({ where: { tenantId: ctx.tenantId } }))
|
|
100
101
|
* class Document extends Model { ... }
|
|
102
|
+
* ```
|
|
101
103
|
*/
|
|
102
104
|
export declare function RowLevelSecurity(selector: ScopeSelector): (target: any) => void;
|
|
103
105
|
/**
|
|
@@ -120,8 +120,10 @@ function getFilteredQuery(Model) {
|
|
|
120
120
|
/**
|
|
121
121
|
* Decorator to apply RLS to a model class.
|
|
122
122
|
*
|
|
123
|
+
* ```ts
|
|
123
124
|
* @RowLevelSecurity((ctx) => ({ where: { tenantId: ctx.tenantId } }))
|
|
124
125
|
* class Document extends Model { ... }
|
|
126
|
+
* ```
|
|
125
127
|
*/
|
|
126
128
|
function RowLevelSecurity(selector) {
|
|
127
129
|
return function (target) {
|