ts-prorm-orm 1.2.3 → 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 +331 -1
- package/README.md +32 -24
- 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 +4 -0
- package/dist/compliance/index.js +15 -1
- 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/connection-manager.js +13 -1
- package/dist/core/expressions.d.ts +58 -0
- package/dist/core/expressions.js +83 -0
- package/dist/core/hooks-manager.d.ts +179 -0
- package/dist/core/hooks-manager.js +291 -0
- package/dist/core/types.d.ts +235 -0
- package/dist/core/types.js +9 -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/index.d.ts +2 -0
- package/dist/decorators/index.js +11 -1
- 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/diagrams/chen-diagram.d.ts +15 -12
- package/dist/diagrams/chen-diagram.js +76 -85
- package/dist/diagrams/class-diagram.d.ts +9 -8
- package/dist/diagrams/class-diagram.js +60 -82
- package/dist/diagrams/core/index.d.ts +13 -0
- package/dist/diagrams/core/index.js +33 -0
- package/dist/diagrams/core/layout.d.ts +104 -0
- package/dist/diagrams/core/layout.js +223 -0
- package/dist/diagrams/{svg-dom.d.ts → core/svg.d.ts} +8 -20
- package/dist/diagrams/{svg-dom.js → core/svg.js} +21 -29
- package/dist/diagrams/core/theme.d.ts +84 -0
- package/dist/diagrams/core/theme.js +62 -0
- package/dist/diagrams/dependency-diagram.d.ts +15 -14
- package/dist/diagrams/dependency-diagram.js +71 -105
- package/dist/diagrams/er-diagram.d.ts +13 -26
- package/dist/diagrams/er-diagram.js +180 -259
- package/dist/diagrams/flow-diagram.d.ts +16 -11
- package/dist/diagrams/flow-diagram.js +96 -91
- package/dist/diagrams/gantt-diagram.d.ts +10 -5
- package/dist/diagrams/gantt-diagram.js +77 -103
- package/dist/diagrams/index-diagram.d.ts +10 -10
- package/dist/diagrams/index-diagram.js +106 -116
- package/dist/diagrams/index.d.ts +6 -9
- package/dist/diagrams/index.js +9 -24
- package/dist/diagrams/migration-diagram.d.ts +8 -4
- package/dist/diagrams/migration-diagram.js +189 -161
- package/dist/diagrams/model-diagram.d.ts +34 -34
- package/dist/diagrams/model-diagram.js +106 -485
- package/dist/diagrams/package-diagram.d.ts +9 -6
- package/dist/diagrams/package-diagram.js +64 -101
- package/dist/diagrams/relational-diagram.d.ts +12 -10
- package/dist/diagrams/relational-diagram.js +87 -114
- package/dist/diagrams/schemadoc-diagram.d.ts +8 -8
- package/dist/diagrams/schemadoc-diagram.js +71 -93
- package/dist/diagrams/sequence-diagram.d.ts +10 -10
- package/dist/diagrams/sequence-diagram.js +64 -89
- package/dist/diagrams/state-diagram.d.ts +10 -9
- package/dist/diagrams/state-diagram.js +69 -92
- package/dist/diagrams/tree-diagram.d.ts +11 -5
- package/dist/diagrams/tree-diagram.js +41 -65
- package/dist/dialects/clickhouse/index.js +15 -0
- package/dist/dialects/cockroachdb/index.d.ts +1 -1
- package/dist/dialects/cockroachdb/index.js +32 -63
- package/dist/dialects/db2/index.js +23 -8
- package/dist/dialects/dialect.d.ts +141 -5
- package/dist/dialects/duckdb/index.js +9 -2
- package/dist/dialects/hana/index.js +22 -5
- package/dist/dialects/lock-clause-helper.d.ts +167 -0
- package/dist/dialects/lock-clause-helper.js +316 -0
- package/dist/dialects/mariadb/index.d.ts +7 -4
- package/dist/dialects/mariadb/index.js +36 -60
- package/dist/dialects/mssql/index.js +34 -3
- package/dist/dialects/mysql/index.d.ts +1 -1
- package/dist/dialects/mysql/index.js +17 -45
- package/dist/dialects/oracle/index.d.ts +14 -3
- package/dist/dialects/oracle/index.js +66 -36
- package/dist/dialects/order-expression-helper.d.ts +72 -0
- package/dist/dialects/order-expression-helper.js +154 -0
- package/dist/dialects/partial-index.d.ts +52 -0
- package/dist/dialects/partial-index.js +251 -0
- package/dist/dialects/postgres/index.d.ts +1 -1
- package/dist/dialects/postgres/index.js +43 -68
- package/dist/dialects/redshift/index.js +9 -2
- package/dist/dialects/snowflake/index.js +17 -0
- package/dist/dialects/spanner/index.js +7 -2
- package/dist/dialects/sqlite/driver.d.ts +55 -0
- package/dist/dialects/sqlite/driver.js +102 -0
- package/dist/dialects/sqlite/index.d.ts +1 -1
- package/dist/dialects/sqlite/index.js +49 -27
- package/dist/external-fields/decorator.d.ts +2 -0
- package/dist/external-fields/decorator.js +2 -0
- package/dist/graph/base-graph-dialect.d.ts +24 -3
- package/dist/graph/base-graph-dialect.js +43 -2
- package/dist/graph/dgraph/index.js +6 -0
- package/dist/graph/gremlin/index.d.ts +6 -0
- package/dist/graph/gremlin/index.js +12 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/neo4j/index.d.ts +2 -0
- package/dist/graph/neo4j/index.js +6 -1
- package/dist/graph/types.d.ts +12 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.js +53 -7
- package/dist/logging/index.d.ts +10 -0
- package/dist/logging/index.js +23 -0
- package/dist/logging/query-logging.d.ts +82 -0
- package/dist/logging/query-logging.js +102 -0
- package/dist/models/associations.d.ts +38 -0
- package/dist/models/associations.js +16 -0
- package/dist/models/decorators.d.ts +55 -19
- package/dist/models/decorators.js +95 -19
- package/dist/models/eager-load.d.ts +99 -0
- package/dist/models/eager-load.js +348 -5
- package/dist/models/indexes.d.ts +3 -2
- package/dist/models/indexes.js +7 -1
- package/dist/models/model.js +69 -43
- package/dist/prorm.d.ts +175 -409
- package/dist/prorm.js +1132 -553
- package/dist/query-builders/order-limit-builder.js +12 -10
- package/dist/query-builders/sql-compiler.d.ts +10 -3
- package/dist/query-builders/sql-compiler.js +14 -43
- package/dist/query-interface.d.ts +2 -1
- package/dist/schema-objects.d.ts +42 -0
- package/dist/schema-objects.js +28 -0
- package/dist/sql-constants.d.ts +44 -0
- package/dist/sql-constants.js +138 -1
- package/dist/types/index.d.ts +387 -17
- package/dist/types/index.js +10 -15
- package/dist/types/query-types.d.ts +26 -0
- package/dist/types/query-types.js +30 -0
- package/package.json +39 -8
- package/dist/decorators/belongs-to-many.js +0 -115
- package/dist/decorators/belongs-to.js +0 -115
- package/dist/decorators/has-many.js +0 -127
- package/dist/decorators/has-one.js +0 -116
- package/dist/diagrams/palette.d.ts +0 -138
- package/dist/diagrams/palette.js +0 -194
- package/dist/hooks/hooks-manager.d.ts +0 -189
- package/dist/hooks/hooks-manager.js +0 -350
- package/dist/hooks/index.d.ts +0 -8
- package/dist/hooks/index.js +0 -37
- /package/dist/{logging.d.ts → logging/logger.d.ts} +0 -0
- /package/dist/{logging.js → logging/logger.js} +0 -0
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,11 +67,12 @@
|
|
|
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;
|
|
72
74
|
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;
|
|
75
|
+
exports.applyLineageHooks = exports.createComputedRecord = exports.createDerivedRecord = exports.getLineageOptions = exports.getLineageFields = exports.LineageTrack = exports.DataLineage = 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
76
|
// Audit Trail
|
|
75
77
|
var audit_trail_1 = require("./audit-trail");
|
|
76
78
|
Object.defineProperty(exports, "ComplianceAuditTrail", { enumerable: true, get: function () { return audit_trail_1.ComplianceAuditTrail; } });
|
|
@@ -258,3 +260,15 @@ Object.defineProperty(exports, "MSSQLFirewall", { enumerable: true, get: functio
|
|
|
258
260
|
Object.defineProperty(exports, "OracleFirewall", { enumerable: true, get: function () { return query_firewall_1.OracleFirewall; } });
|
|
259
261
|
Object.defineProperty(exports, "SQLiteFirewall", { enumerable: true, get: function () { return query_firewall_1.SQLiteFirewall; } });
|
|
260
262
|
Object.defineProperty(exports, "applyFirewallRulesToModel", { enumerable: true, get: function () { return query_firewall_1.applyFirewallRulesToModel; } });
|
|
263
|
+
// Data Lineage
|
|
264
|
+
// `applyHooks` is aliased to `applyLineageHooks` for the same reason
|
|
265
|
+
// data-masker's and pseudonymization's are: three modules in this barrel each
|
|
266
|
+
// export a function by that name.
|
|
267
|
+
var data_lineage_1 = require("./data-lineage");
|
|
268
|
+
Object.defineProperty(exports, "DataLineage", { enumerable: true, get: function () { return data_lineage_1.DataLineage; } });
|
|
269
|
+
Object.defineProperty(exports, "LineageTrack", { enumerable: true, get: function () { return data_lineage_1.LineageTrack; } });
|
|
270
|
+
Object.defineProperty(exports, "getLineageFields", { enumerable: true, get: function () { return data_lineage_1.getLineageFields; } });
|
|
271
|
+
Object.defineProperty(exports, "getLineageOptions", { enumerable: true, get: function () { return data_lineage_1.getLineageOptions; } });
|
|
272
|
+
Object.defineProperty(exports, "createDerivedRecord", { enumerable: true, get: function () { return data_lineage_1.createDerivedRecord; } });
|
|
273
|
+
Object.defineProperty(exports, "createComputedRecord", { enumerable: true, get: function () { return data_lineage_1.createComputedRecord; } });
|
|
274
|
+
Object.defineProperty(exports, "applyLineageHooks", { enumerable: true, get: function () { return data_lineage_1.applyHooks; } });
|
|
@@ -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) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* based on a list of security frameworks. Works with the 12 compliance classes.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
|
+
* ```ts
|
|
8
9
|
* @Security({
|
|
9
10
|
* frameworks: ['GDPR', 'HIPAA', 'PCI_DSS'],
|
|
10
11
|
* audit: true,
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
* immutable: true,
|
|
20
21
|
* })
|
|
21
22
|
* class FinancialRecord extends Model { ... }
|
|
23
|
+
* ```
|
|
22
24
|
*/
|
|
23
25
|
import { RetentionDuration } from './data-retention';
|
|
24
26
|
/**
|
|
@@ -260,6 +262,7 @@ export interface SecurityOptions {
|
|
|
260
262
|
* @param options - Security configuration
|
|
261
263
|
*
|
|
262
264
|
* @example
|
|
265
|
+
* ```ts
|
|
263
266
|
* @Security({
|
|
264
267
|
* frameworks: ['GDPR', 'HIPAA', 'PCI_DSS'],
|
|
265
268
|
* audit: true,
|
|
@@ -269,6 +272,7 @@ export interface SecurityOptions {
|
|
|
269
272
|
* autoClassify: true,
|
|
270
273
|
* })
|
|
271
274
|
* class Patient extends Model { ... }
|
|
275
|
+
* ```
|
|
272
276
|
*/
|
|
273
277
|
export declare function Security(options: SecurityOptions): (target: any) => void;
|
|
274
278
|
/**
|
|
@@ -313,12 +317,14 @@ export interface TableSecurityOptions {
|
|
|
313
317
|
* Apply table-level security metadata.
|
|
314
318
|
*
|
|
315
319
|
* @example
|
|
320
|
+
* ```ts
|
|
316
321
|
* @Table({
|
|
317
322
|
* schema: 'financial',
|
|
318
323
|
* classification: 'CONFIDENTIAL',
|
|
319
324
|
* rlsEnabled: true,
|
|
320
325
|
* })
|
|
321
326
|
* class Transaction extends Model { ... }
|
|
327
|
+
* ```
|
|
322
328
|
*/
|
|
323
329
|
export declare function Table(options?: TableSecurityOptions): (target: any) => void;
|
|
324
330
|
export interface DatabaseSecurityOptions {
|
|
@@ -355,6 +361,7 @@ export interface DatabaseSecurityOptions {
|
|
|
355
361
|
* Apply database-level security metadata.
|
|
356
362
|
*
|
|
357
363
|
* @example
|
|
364
|
+
* ```ts
|
|
358
365
|
* @Database({
|
|
359
366
|
* name: 'healthcare_db',
|
|
360
367
|
* region: 'us-east-1',
|
|
@@ -364,6 +371,7 @@ export interface DatabaseSecurityOptions {
|
|
|
364
371
|
* allowedCountries: ['US'],
|
|
365
372
|
* })
|
|
366
373
|
* class HealthcareDB extends Model { ... }
|
|
374
|
+
* ```
|
|
367
375
|
*/
|
|
368
376
|
export declare function Database(options: DatabaseSecurityOptions): (target: any) => void;
|
|
369
377
|
/**
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* based on a list of security frameworks. Works with the 12 compliance classes.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
+
* ```ts
|
|
9
10
|
* @Security({
|
|
10
11
|
* frameworks: ['GDPR', 'HIPAA', 'PCI_DSS'],
|
|
11
12
|
* audit: true,
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
* immutable: true,
|
|
21
22
|
* })
|
|
22
23
|
* class FinancialRecord extends Model { ... }
|
|
24
|
+
* ```
|
|
23
25
|
*/
|
|
24
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
27
|
exports.FrameworkRequirements = exports.FrameworkCount = exports.FrameworkCategories = exports.AllFrameworks = exports.SecurityFramework = void 0;
|
|
@@ -324,6 +326,7 @@ exports.FrameworkRequirements = {
|
|
|
324
326
|
* @param options - Security configuration
|
|
325
327
|
*
|
|
326
328
|
* @example
|
|
329
|
+
* ```ts
|
|
327
330
|
* @Security({
|
|
328
331
|
* frameworks: ['GDPR', 'HIPAA', 'PCI_DSS'],
|
|
329
332
|
* audit: true,
|
|
@@ -333,6 +336,7 @@ exports.FrameworkRequirements = {
|
|
|
333
336
|
* autoClassify: true,
|
|
334
337
|
* })
|
|
335
338
|
* class Patient extends Model { ... }
|
|
339
|
+
* ```
|
|
336
340
|
*/
|
|
337
341
|
function Security(options) {
|
|
338
342
|
return function (target) {
|
|
@@ -510,12 +514,14 @@ function setupAllSecurity(prorm) {
|
|
|
510
514
|
* Apply table-level security metadata.
|
|
511
515
|
*
|
|
512
516
|
* @example
|
|
517
|
+
* ```ts
|
|
513
518
|
* @Table({
|
|
514
519
|
* schema: 'financial',
|
|
515
520
|
* classification: 'CONFIDENTIAL',
|
|
516
521
|
* rlsEnabled: true,
|
|
517
522
|
* })
|
|
518
523
|
* class Transaction extends Model { ... }
|
|
524
|
+
* ```
|
|
519
525
|
*/
|
|
520
526
|
function Table(options = {}) {
|
|
521
527
|
return function (target) {
|
|
@@ -526,6 +532,7 @@ function Table(options = {}) {
|
|
|
526
532
|
* Apply database-level security metadata.
|
|
527
533
|
*
|
|
528
534
|
* @example
|
|
535
|
+
* ```ts
|
|
529
536
|
* @Database({
|
|
530
537
|
* name: 'healthcare_db',
|
|
531
538
|
* region: 'us-east-1',
|
|
@@ -535,6 +542,7 @@ function Table(options = {}) {
|
|
|
535
542
|
* allowedCountries: ['US'],
|
|
536
543
|
* })
|
|
537
544
|
* class HealthcareDB extends Model { ... }
|
|
545
|
+
* ```
|
|
538
546
|
*/
|
|
539
547
|
function Database(options) {
|
|
540
548
|
return function (target) {
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
* return db.User.findAll();
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
|
+
* ```ts
|
|
31
32
|
* // Use the decorator on models:
|
|
32
33
|
* @TenantIsolation({ tenantId: 'tenantId', auditEnabled: true })
|
|
33
34
|
* class Document extends Model { ... }
|
|
35
|
+
* ```
|
|
34
36
|
*/
|
|
35
37
|
export interface TenantContext {
|
|
36
38
|
/** The tenant identifier */
|
|
@@ -234,11 +236,13 @@ export declare class SessionIsolation {
|
|
|
234
236
|
/**
|
|
235
237
|
* Decorator to apply tenant isolation to a model.
|
|
236
238
|
*
|
|
239
|
+
* ```ts
|
|
237
240
|
* @TenantIsolation({ tenantId: 'tenantId', auditEnabled: true })
|
|
238
241
|
* class Document extends Model {
|
|
239
242
|
* tenantId: string;
|
|
240
243
|
* title: string;
|
|
241
244
|
* }
|
|
245
|
+
* ```
|
|
242
246
|
*
|
|
243
247
|
* @param options - Tenant isolation options
|
|
244
248
|
*/
|
|
@@ -29,9 +29,11 @@
|
|
|
29
29
|
* return db.User.findAll();
|
|
30
30
|
* });
|
|
31
31
|
*
|
|
32
|
+
* ```ts
|
|
32
33
|
* // Use the decorator on models:
|
|
33
34
|
* @TenantIsolation({ tenantId: 'tenantId', auditEnabled: true })
|
|
34
35
|
* class Document extends Model { ... }
|
|
36
|
+
* ```
|
|
35
37
|
*/
|
|
36
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
39
|
exports.TenantIsolationManager = exports.SessionIsolation = void 0;
|
|
@@ -347,11 +349,13 @@ exports.SessionIsolation = SessionIsolation;
|
|
|
347
349
|
/**
|
|
348
350
|
* Decorator to apply tenant isolation to a model.
|
|
349
351
|
*
|
|
352
|
+
* ```ts
|
|
350
353
|
* @TenantIsolation({ tenantId: 'tenantId', auditEnabled: true })
|
|
351
354
|
* class Document extends Model {
|
|
352
355
|
* tenantId: string;
|
|
353
356
|
* title: string;
|
|
354
357
|
* }
|
|
358
|
+
* ```
|
|
355
359
|
*
|
|
356
360
|
* @param options - Tenant isolation options
|
|
357
361
|
*/
|
|
@@ -30,9 +30,11 @@
|
|
|
30
30
|
* // Enforce retention policy:
|
|
31
31
|
* await WORMStorage.enforceRetention(FinancialRecord, prorm);
|
|
32
32
|
*
|
|
33
|
+
* ```ts
|
|
33
34
|
* // Using the decorator:
|
|
34
35
|
* @WORM({ retentionPeriod: { years: 7 }, tamperEvident: true })
|
|
35
36
|
* class FinancialRecord extends Model { ... }
|
|
37
|
+
* ```
|
|
36
38
|
*/
|
|
37
39
|
import { ModelStatic, Prorm } from '../prorm';
|
|
38
40
|
import { RetentionDuration } from './data-retention';
|
|
@@ -91,8 +93,10 @@ interface WORMConfig {
|
|
|
91
93
|
/**
|
|
92
94
|
* Decorator to mark a model for WORM storage.
|
|
93
95
|
*
|
|
96
|
+
* ```ts
|
|
94
97
|
* @WORM({ retentionPeriod: { years: 7 }, tamperEvident: true })
|
|
95
98
|
* class FinancialRecord extends Model { ... }
|
|
99
|
+
* ```
|
|
96
100
|
*/
|
|
97
101
|
export declare function WORM(options: WORMOptions): (target: Function) => void;
|
|
98
102
|
/**
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
* // Enforce retention policy:
|
|
32
32
|
* await WORMStorage.enforceRetention(FinancialRecord, prorm);
|
|
33
33
|
*
|
|
34
|
+
* ```ts
|
|
34
35
|
* // Using the decorator:
|
|
35
36
|
* @WORM({ retentionPeriod: { years: 7 }, tamperEvident: true })
|
|
36
37
|
* class FinancialRecord extends Model { ... }
|
|
38
|
+
* ```
|
|
37
39
|
*/
|
|
38
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
41
|
exports.WORMStorage = void 0;
|
|
@@ -173,8 +175,10 @@ function createWORMTamperLogModel(prorm, tableName) {
|
|
|
173
175
|
/**
|
|
174
176
|
* Decorator to mark a model for WORM storage.
|
|
175
177
|
*
|
|
178
|
+
* ```ts
|
|
176
179
|
* @WORM({ retentionPeriod: { years: 7 }, tamperEvident: true })
|
|
177
180
|
* class FinancialRecord extends Model { ... }
|
|
181
|
+
* ```
|
|
178
182
|
*/
|
|
179
183
|
function WORM(options) {
|
|
180
184
|
return function (target) {
|
|
@@ -37,6 +37,12 @@ class ConnectionManager {
|
|
|
37
37
|
throw new Error(`Connection with name '${name}' already exists`);
|
|
38
38
|
}
|
|
39
39
|
const prorm = new prorm_1.Prorm(options);
|
|
40
|
+
// Let the instance find its siblings. This is what makes
|
|
41
|
+
// `Model.findAll({ using: 'other' })` resolvable: the query path looks the
|
|
42
|
+
// target connection up through `prorm.connectionManager`, which nothing
|
|
43
|
+
// used to set, so `using` failed with "Available: none" no matter how many
|
|
44
|
+
// connections had been added.
|
|
45
|
+
prorm.connectionManager = this;
|
|
40
46
|
this.connections.set(name, prorm);
|
|
41
47
|
// Set as default if it's the first connection
|
|
42
48
|
if (this._defaultConnection === null) {
|
|
@@ -78,8 +84,11 @@ class ConnectionManager {
|
|
|
78
84
|
if (!prorm) {
|
|
79
85
|
return false;
|
|
80
86
|
}
|
|
81
|
-
// Close the connection
|
|
87
|
+
// Close the connection and detach it from this manager, so a model still
|
|
88
|
+
// holding a reference to it can't route a `using` query through a
|
|
89
|
+
// registry it is no longer a member of.
|
|
82
90
|
await prorm.close();
|
|
91
|
+
prorm.connectionManager = null;
|
|
83
92
|
this.connections.delete(name);
|
|
84
93
|
// Update default if needed
|
|
85
94
|
if (this._defaultConnection === name) {
|
|
@@ -167,6 +176,9 @@ class ConnectionManager {
|
|
|
167
176
|
async closeAll() {
|
|
168
177
|
const closePromises = Array.from(this.connections.values()).map((seq) => seq.close());
|
|
169
178
|
await Promise.all(closePromises);
|
|
179
|
+
for (const prorm of this.connections.values()) {
|
|
180
|
+
prorm.connectionManager = null;
|
|
181
|
+
}
|
|
170
182
|
this.connections.clear();
|
|
171
183
|
this._defaultConnection = null;
|
|
172
184
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw SQL expression wrappers used by the Prorm instance API.
|
|
3
|
+
*
|
|
4
|
+
* `Literal` embeds SQL verbatim; `Col` references a column without quoting it
|
|
5
|
+
* as a value. Note that `src/operators.ts` also exposes `literal()`/`col()`
|
|
6
|
+
* factories producing a different shape - the dialects consume the operators
|
|
7
|
+
* form, so prefer those in new code.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Represents a raw SQL literal value
|
|
11
|
+
* Used for inserting raw SQL expressions into queries
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Use in default values
|
|
15
|
+
* createdAt: { type: DATE, defaultValue: prorm.literal('NOW()') }
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Use in updates
|
|
19
|
+
* User.update({ count: prorm.literal('count + 1') }, {...})
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Use in select with calculations
|
|
23
|
+
* User.findAll({ attributes: [[prorm.literal('1 + 1'), 'two']] })
|
|
24
|
+
*/
|
|
25
|
+
export declare class Literal {
|
|
26
|
+
readonly val: string;
|
|
27
|
+
constructor(sql: string);
|
|
28
|
+
/**
|
|
29
|
+
* Get the raw SQL string
|
|
30
|
+
*/
|
|
31
|
+
toString(): string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Class representing a column reference for use with Prorm functions
|
|
35
|
+
* Used to create properly quoted column identifiers
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Single column: col('name') -> "name"
|
|
39
|
+
* // Table and column: col('User', 'name') -> "User"."name"
|
|
40
|
+
* // Dot notation: col('table.column') -> "table"."column"
|
|
41
|
+
*/
|
|
42
|
+
export declare class Col {
|
|
43
|
+
private readonly col;
|
|
44
|
+
/**
|
|
45
|
+
* Create a column reference
|
|
46
|
+
* @param tableOrColumn - Table name (if second param provided) or column name
|
|
47
|
+
* @param column - Column name (if first param is table name)
|
|
48
|
+
*/
|
|
49
|
+
constructor(tableOrColumn: string, column?: string);
|
|
50
|
+
/**
|
|
51
|
+
* Get the SQL representation of the column
|
|
52
|
+
*/
|
|
53
|
+
toSql(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Get the column as a string
|
|
56
|
+
*/
|
|
57
|
+
toString(): string;
|
|
58
|
+
}
|