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/types/index.js
CHANGED
|
@@ -110,15 +110,20 @@ var ValidateOn;
|
|
|
110
110
|
})(ValidateOn || (exports.ValidateOn = ValidateOn = {}));
|
|
111
111
|
/**
|
|
112
112
|
* Lock types for row-level locking
|
|
113
|
-
* - 'UPDATE': FOR UPDATE (PostgreSQL/MySQL) - prevents other transactions from modifying the rows
|
|
114
|
-
* - 'SHARE': FOR SHARE (PostgreSQL) / LOCK IN SHARE MODE (MySQL) - allows other transactions to read but not modify
|
|
115
|
-
* - 'KEY SHARE': FOR KEY SHARE (PostgreSQL only) - prevents key updates but allows row updates
|
|
113
|
+
* - 'UPDATE': FOR UPDATE (PostgreSQL/MySQL/MariaDB/Oracle/Db2/HANA, UPDLOCK on SQL Server) - prevents other transactions from modifying the rows
|
|
114
|
+
* - 'SHARE': FOR SHARE (PostgreSQL) / LOCK IN SHARE MODE (MySQL/MariaDB, or FOR SHARE when a modifier is used) / HOLDLOCK (SQL Server) - allows other transactions to read but not modify
|
|
115
|
+
* - 'KEY SHARE': FOR KEY SHARE (PostgreSQL/CockroachDB only) - prevents key updates but allows row updates
|
|
116
|
+
* - 'NO KEY UPDATE': FOR NO KEY UPDATE (PostgreSQL/CockroachDB only) - like UPDATE but does not block KEY SHARE lockers
|
|
117
|
+
*
|
|
118
|
+
* A dialect that cannot express the requested level throws when the query is
|
|
119
|
+
* built, rather than silently falling back to a weaker lock (or to none).
|
|
116
120
|
*/
|
|
117
121
|
var LockLevel;
|
|
118
122
|
(function (LockLevel) {
|
|
119
123
|
LockLevel["Share"] = "SHARE";
|
|
120
124
|
LockLevel["Update"] = "UPDATE";
|
|
121
125
|
LockLevel["KeyShare"] = "KEY SHARE";
|
|
126
|
+
LockLevel["NoKeyUpdate"] = "NO KEY UPDATE";
|
|
122
127
|
})(LockLevel || (exports.LockLevel = LockLevel = {}));
|
|
123
128
|
// ==================== Transaction Options ====================
|
|
124
129
|
/**
|
|
@@ -166,15 +171,5 @@ var IsolationLevel;
|
|
|
166
171
|
* prorm.query('SELECT * FROM users', { type: QueryTypes.SELECT })
|
|
167
172
|
* prorm.query('INSERT INTO users VALUES(...)', { type: QueryTypes.INSERT })
|
|
168
173
|
*/
|
|
169
|
-
|
|
170
|
-
(function (
|
|
171
|
-
QueryTypes["SELECT"] = "SELECT";
|
|
172
|
-
QueryTypes["INSERT"] = "INSERT";
|
|
173
|
-
QueryTypes["UPDATE"] = "UPDATE";
|
|
174
|
-
QueryTypes["DELETE"] = "DELETE";
|
|
175
|
-
QueryTypes["BULKINSERT"] = "BULKINSERT";
|
|
176
|
-
QueryTypes["BULKUPDATE"] = "BULKUPDATE";
|
|
177
|
-
QueryTypes["BULKDELETE"] = "BULKDELETE";
|
|
178
|
-
QueryTypes["RAW"] = "RAW";
|
|
179
|
-
QueryTypes["CALL"] = "CALL";
|
|
180
|
-
})(QueryTypes || (exports.QueryTypes = QueryTypes = {}));
|
|
174
|
+
const query_types_1 = require("./query-types");
|
|
175
|
+
Object.defineProperty(exports, "QueryTypes", { enumerable: true, get: function () { return query_types_1.QueryTypes; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query type discriminator, used by `prorm.query()` to decide how to shape a
|
|
3
|
+
* raw result.
|
|
4
|
+
*
|
|
5
|
+
* This enum existed twice with *different members*: `src/prorm.ts` declared
|
|
6
|
+
* UPSERT/VERSION/SHOWTABLES/DESCRIBE, while `src/types/index.ts` declared
|
|
7
|
+
* BULKUPDATE/CALL. The package root explicitly re-exported the prorm.ts one, so
|
|
8
|
+
* `QueryTypes.CALL` and `QueryTypes.BULKUPDATE` were unreachable for consumers
|
|
9
|
+
* even though internal code in types/index.ts referred to them. This is the
|
|
10
|
+
* union of both, defined once; both modules now re-export it.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum QueryTypes {
|
|
13
|
+
SELECT = "SELECT",
|
|
14
|
+
INSERT = "INSERT",
|
|
15
|
+
UPDATE = "UPDATE",
|
|
16
|
+
DELETE = "DELETE",
|
|
17
|
+
UPSERT = "UPSERT",
|
|
18
|
+
BULKINSERT = "BULKINSERT",
|
|
19
|
+
BULKUPDATE = "BULKUPDATE",
|
|
20
|
+
BULKDELETE = "BULKDELETE",
|
|
21
|
+
VERSION = "VERSION",
|
|
22
|
+
SHOWTABLES = "SHOWTABLES",
|
|
23
|
+
DESCRIBE = "DESCRIBE",
|
|
24
|
+
CALL = "CALL",
|
|
25
|
+
RAW = "RAW"
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryTypes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Query type discriminator, used by `prorm.query()` to decide how to shape a
|
|
6
|
+
* raw result.
|
|
7
|
+
*
|
|
8
|
+
* This enum existed twice with *different members*: `src/prorm.ts` declared
|
|
9
|
+
* UPSERT/VERSION/SHOWTABLES/DESCRIBE, while `src/types/index.ts` declared
|
|
10
|
+
* BULKUPDATE/CALL. The package root explicitly re-exported the prorm.ts one, so
|
|
11
|
+
* `QueryTypes.CALL` and `QueryTypes.BULKUPDATE` were unreachable for consumers
|
|
12
|
+
* even though internal code in types/index.ts referred to them. This is the
|
|
13
|
+
* union of both, defined once; both modules now re-export it.
|
|
14
|
+
*/
|
|
15
|
+
var QueryTypes;
|
|
16
|
+
(function (QueryTypes) {
|
|
17
|
+
QueryTypes["SELECT"] = "SELECT";
|
|
18
|
+
QueryTypes["INSERT"] = "INSERT";
|
|
19
|
+
QueryTypes["UPDATE"] = "UPDATE";
|
|
20
|
+
QueryTypes["DELETE"] = "DELETE";
|
|
21
|
+
QueryTypes["UPSERT"] = "UPSERT";
|
|
22
|
+
QueryTypes["BULKINSERT"] = "BULKINSERT";
|
|
23
|
+
QueryTypes["BULKUPDATE"] = "BULKUPDATE";
|
|
24
|
+
QueryTypes["BULKDELETE"] = "BULKDELETE";
|
|
25
|
+
QueryTypes["VERSION"] = "VERSION";
|
|
26
|
+
QueryTypes["SHOWTABLES"] = "SHOWTABLES";
|
|
27
|
+
QueryTypes["DESCRIBE"] = "DESCRIBE";
|
|
28
|
+
QueryTypes["CALL"] = "CALL";
|
|
29
|
+
QueryTypes["RAW"] = "RAW";
|
|
30
|
+
})(QueryTypes || (exports.QueryTypes = QueryTypes = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-prorm-orm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Malcolm Stone",
|
|
@@ -29,16 +29,36 @@
|
|
|
29
29
|
"require": "./dist/index.js",
|
|
30
30
|
"types": "./dist/index.d.ts"
|
|
31
31
|
},
|
|
32
|
+
"./cache": {
|
|
33
|
+
"types": "./dist/cache/index.d.ts",
|
|
34
|
+
"import": "./dist/cache/index.js",
|
|
35
|
+
"require": "./dist/cache/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./audit": {
|
|
38
|
+
"types": "./dist/audit/index.d.ts",
|
|
39
|
+
"import": "./dist/audit/index.js",
|
|
40
|
+
"require": "./dist/audit/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./graph": {
|
|
43
|
+
"types": "./dist/graph/index.d.ts",
|
|
44
|
+
"import": "./dist/graph/index.js",
|
|
45
|
+
"require": "./dist/graph/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./prisma-migrate": {
|
|
48
|
+
"types": "./dist/prisma-migrate/index.d.ts",
|
|
49
|
+
"import": "./dist/prisma-migrate/index.js",
|
|
50
|
+
"require": "./dist/prisma-migrate/index.js"
|
|
51
|
+
},
|
|
32
52
|
"./package.json": "./package.json"
|
|
33
53
|
},
|
|
34
54
|
"scripts": {
|
|
35
|
-
"build": "tsc",
|
|
55
|
+
"build": "npm run clean && tsc",
|
|
36
56
|
"clean": "rm -rf dist",
|
|
37
57
|
"dev": "tsc --watch",
|
|
38
58
|
"test": "jest",
|
|
39
59
|
"test:legacy": "node dist/test.js",
|
|
40
60
|
"test:watch": "jest --watch",
|
|
41
|
-
"test:coverage": "jest --coverage",
|
|
61
|
+
"test:coverage": "jest --coverage --maxWorkers=50%",
|
|
42
62
|
"model:create": "ts-node src/cli.ts model:create",
|
|
43
63
|
"model:create:help": "ts-node src/cli.ts help",
|
|
44
64
|
"diagram:model": "ts-node src/cli.ts diagram:model",
|
|
@@ -55,7 +75,8 @@
|
|
|
55
75
|
"prepublishOnly": "npm run build && npm run check:package && npm run test",
|
|
56
76
|
"prepare": "husky",
|
|
57
77
|
"docs:reference": "typedoc",
|
|
58
|
-
"check:package": "node scripts/check-package.mjs"
|
|
78
|
+
"check:package": "node scripts/check-package.mjs",
|
|
79
|
+
"build:incremental": "tsc"
|
|
59
80
|
},
|
|
60
81
|
"bin": {
|
|
61
82
|
"prorm": "dist/cli.js",
|
|
@@ -80,7 +101,7 @@
|
|
|
80
101
|
"@libsql/client": "^0.17.4",
|
|
81
102
|
"@opensearch-project/opensearch": "^3.6.0",
|
|
82
103
|
"@pinecone-database/pinecone": "^8.0.0",
|
|
83
|
-
"@qdrant/js-client-rest": "
|
|
104
|
+
"@qdrant/js-client-rest": "~1.18.0",
|
|
84
105
|
"@xmldom/xmldom": "^0.9.10",
|
|
85
106
|
"@zilliz/milvus2-sdk-node": "^3.0.3",
|
|
86
107
|
"arangojs": "^10.3.1",
|
|
@@ -101,7 +122,6 @@
|
|
|
101
122
|
"pg-hstore": "^2.3.4",
|
|
102
123
|
"reflect-metadata": "^0.2.2",
|
|
103
124
|
"snowflake-sdk": "^3.0.0",
|
|
104
|
-
"sqlite3": "^5.1.7",
|
|
105
125
|
"tedious": "^18.0.0",
|
|
106
126
|
"weaviate-client": "^3.13.1"
|
|
107
127
|
},
|
|
@@ -180,7 +200,13 @@
|
|
|
180
200
|
"jest-junit"
|
|
181
201
|
],
|
|
182
202
|
"workerIdleMemoryLimit": "256MB",
|
|
183
|
-
"coverageProvider": "v8"
|
|
203
|
+
"coverageProvider": "v8",
|
|
204
|
+
"collectCoverageFrom": [
|
|
205
|
+
"src/**/*.ts",
|
|
206
|
+
"!src/test.ts",
|
|
207
|
+
"!src/models/virtual-field-example.ts",
|
|
208
|
+
"!src/**/*.d.ts"
|
|
209
|
+
]
|
|
184
210
|
},
|
|
185
211
|
"jest-junit": {
|
|
186
212
|
"outputDirectory": ".",
|
|
@@ -200,7 +226,12 @@
|
|
|
200
226
|
"pg-copy-streams": "^7.0.0"
|
|
201
227
|
},
|
|
202
228
|
"allowScripts": {
|
|
203
|
-
"better-sqlite3@12.8.0": true,
|
|
229
|
+
"better-sqlite3@12.8.0 || 12.11.1": true,
|
|
204
230
|
"duckdb@1.4.4": true
|
|
231
|
+
},
|
|
232
|
+
"overrides": {
|
|
233
|
+
"adm-zip": "^0.6.0",
|
|
234
|
+
"node-gyp": "^11.4.2",
|
|
235
|
+
"toml": "^5.0.0"
|
|
205
236
|
}
|
|
206
237
|
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* BelongsToMany decorator for the ORM.
|
|
4
|
-
*
|
|
5
|
-
* Defines a many-to-many relationship between models via a join table/model.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* @BelongsToMany(() => Role, { through: 'user_roles' })
|
|
10
|
-
* roles: Role[];
|
|
11
|
-
*
|
|
12
|
-
* @BelongsToMany(() => Role, { through: UserRole, as: 'assignedRoles' })
|
|
13
|
-
* assignedRoles: Role[];
|
|
14
|
-
*
|
|
15
|
-
* // With options
|
|
16
|
-
* @BelongsToMany(() => Tag, {
|
|
17
|
-
* through: 'post_tags',
|
|
18
|
-
* foreignKey: 'post_id',
|
|
19
|
-
* otherKey: 'tag_id',
|
|
20
|
-
* onDelete: 'CASCADE'
|
|
21
|
-
* })
|
|
22
|
-
* tags: Tag[];
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.getBelongsToMany = getBelongsToMany;
|
|
26
|
-
exports.getAllBelongsToMany = getAllBelongsToMany;
|
|
27
|
-
exports.BelongsToMany = BelongsToMany;
|
|
28
|
-
exports.processBelongsToManyDecorators = processBelongsToManyDecorators;
|
|
29
|
-
// ==================== Metadata Storage ====================
|
|
30
|
-
const BELONGS_TO_MANY_KEY = '__orm_belongs_to_many__';
|
|
31
|
-
/**
|
|
32
|
-
* Get all @BelongsToMany annotations attached to a model constructor.
|
|
33
|
-
*/
|
|
34
|
-
function getBelongsToMany(target) {
|
|
35
|
-
return target[BELONGS_TO_MANY_KEY] || [];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get all belongsToMany associations including inherited ones.
|
|
39
|
-
*/
|
|
40
|
-
function getAllBelongsToMany(target) {
|
|
41
|
-
const associations = [];
|
|
42
|
-
let current = target;
|
|
43
|
-
while (current && current.prototype) {
|
|
44
|
-
const meta = getBelongsToMany(current);
|
|
45
|
-
associations.push(...meta);
|
|
46
|
-
current = Object.getPrototypeOf(current);
|
|
47
|
-
if (current === Object.prototype)
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
return associations;
|
|
51
|
-
}
|
|
52
|
-
// ==================== Decorator ====================
|
|
53
|
-
/**
|
|
54
|
-
* Define a many-to-many relationship.
|
|
55
|
-
*
|
|
56
|
-
* This decorator stores metadata on the model class that can be used
|
|
57
|
-
* by the ORM to establish the association at model initialization time.
|
|
58
|
-
*
|
|
59
|
-
* @param target - A function that returns the target model class
|
|
60
|
-
* @param options - Configuration for the association (through is required)
|
|
61
|
-
*/
|
|
62
|
-
function BelongsToMany(target, options) {
|
|
63
|
-
return function (prototype, propertyKey) {
|
|
64
|
-
const ModelClass = prototype.constructor;
|
|
65
|
-
if (!ModelClass[BELONGS_TO_MANY_KEY]) {
|
|
66
|
-
ModelClass[BELONGS_TO_MANY_KEY] = [];
|
|
67
|
-
}
|
|
68
|
-
ModelClass[BELONGS_TO_MANY_KEY].push({
|
|
69
|
-
target,
|
|
70
|
-
options: {
|
|
71
|
-
as: options.as || propertyKey.toString(),
|
|
72
|
-
through: options.through,
|
|
73
|
-
foreignKey: options.foreignKey,
|
|
74
|
-
otherKey: options.otherKey,
|
|
75
|
-
constraints: options.constraints,
|
|
76
|
-
onDelete: options.onDelete,
|
|
77
|
-
onUpdate: options.onUpdate,
|
|
78
|
-
targetKey: options.targetKey,
|
|
79
|
-
sourceKey: options.sourceKey,
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Process @BelongsToMany decorators and create association configuration.
|
|
86
|
-
*
|
|
87
|
-
* Call this to get the raw association definitions from decorators.
|
|
88
|
-
*
|
|
89
|
-
* @param ModelClass - The model class with @BelongsToMany decorators
|
|
90
|
-
* @returns Array of association configurations
|
|
91
|
-
*/
|
|
92
|
-
function processBelongsToManyDecorators(ModelClass) {
|
|
93
|
-
const decorators = getAllBelongsToMany(ModelClass);
|
|
94
|
-
return decorators.map(({ target, options }) => {
|
|
95
|
-
const targetModel = target();
|
|
96
|
-
const foreignKey = typeof options.foreignKey === 'string'
|
|
97
|
-
? options.foreignKey
|
|
98
|
-
: options.foreignKey?.name
|
|
99
|
-
? options.foreignKey.name
|
|
100
|
-
: `${ModelClass.name}Id`;
|
|
101
|
-
return {
|
|
102
|
-
source: ModelClass,
|
|
103
|
-
target: targetModel,
|
|
104
|
-
foreignKey,
|
|
105
|
-
as: options.as || '',
|
|
106
|
-
options,
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
exports.default = {
|
|
111
|
-
BelongsToMany,
|
|
112
|
-
getBelongsToMany,
|
|
113
|
-
getAllBelongsToMany,
|
|
114
|
-
processBelongsToManyDecorators,
|
|
115
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* BelongsTo decorator for the ORM.
|
|
4
|
-
*
|
|
5
|
-
* Defines a many-to-one (inverse of hasOne/hasMany) relationship between models.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* @BelongsTo(() => User)
|
|
10
|
-
* user: User;
|
|
11
|
-
*
|
|
12
|
-
* @BelongsTo(() => User, { as: 'author' })
|
|
13
|
-
* author: User;
|
|
14
|
-
*
|
|
15
|
-
* // With options
|
|
16
|
-
* @BelongsTo(() => Category, {
|
|
17
|
-
* foreignKey: { name: 'category_id', allowNull: false },
|
|
18
|
-
* onDelete: 'CASCADE'
|
|
19
|
-
* })
|
|
20
|
-
* category: Category;
|
|
21
|
-
*
|
|
22
|
-
* // Self-referential
|
|
23
|
-
* @BelongsTo(() => User, { as: 'manager', foreignKey: 'manager_id' })
|
|
24
|
-
* manager: User;
|
|
25
|
-
*/
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.getBelongsTo = getBelongsTo;
|
|
28
|
-
exports.getAllBelongsTo = getAllBelongsTo;
|
|
29
|
-
exports.BelongsTo = BelongsTo;
|
|
30
|
-
exports.processBelongsToDecorators = processBelongsToDecorators;
|
|
31
|
-
// ==================== Metadata Storage ====================
|
|
32
|
-
const BELONGS_TO_KEY = '__orm_belongs_to__';
|
|
33
|
-
/**
|
|
34
|
-
* Get all @BelongsTo annotations attached to a model constructor.
|
|
35
|
-
*/
|
|
36
|
-
function getBelongsTo(target) {
|
|
37
|
-
return target[BELONGS_TO_KEY] || [];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get all belongsTo associations including inherited ones.
|
|
41
|
-
*/
|
|
42
|
-
function getAllBelongsTo(target) {
|
|
43
|
-
const associations = [];
|
|
44
|
-
let current = target;
|
|
45
|
-
while (current && current.prototype) {
|
|
46
|
-
const meta = getBelongsTo(current);
|
|
47
|
-
associations.push(...meta);
|
|
48
|
-
current = Object.getPrototypeOf(current);
|
|
49
|
-
if (current === Object.prototype)
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
return associations;
|
|
53
|
-
}
|
|
54
|
-
// ==================== Decorator ====================
|
|
55
|
-
/**
|
|
56
|
-
* Define a many-to-one relationship.
|
|
57
|
-
*
|
|
58
|
-
* This decorator stores metadata on the model class that can be used
|
|
59
|
-
* by the ORM to establish the association at model initialization time.
|
|
60
|
-
*
|
|
61
|
-
* @param target - A function that returns the target model class
|
|
62
|
-
* @param options - Optional configuration for the association
|
|
63
|
-
*/
|
|
64
|
-
function BelongsTo(target, options = {}) {
|
|
65
|
-
return function (prototype, propertyKey) {
|
|
66
|
-
const ModelClass = prototype.constructor;
|
|
67
|
-
if (!ModelClass[BELONGS_TO_KEY]) {
|
|
68
|
-
ModelClass[BELONGS_TO_KEY] = [];
|
|
69
|
-
}
|
|
70
|
-
ModelClass[BELONGS_TO_KEY].push({
|
|
71
|
-
target,
|
|
72
|
-
options: {
|
|
73
|
-
as: options.as || propertyKey.toString(),
|
|
74
|
-
foreignKey: options.foreignKey,
|
|
75
|
-
constraints: options.constraints,
|
|
76
|
-
onDelete: options.onDelete,
|
|
77
|
-
onUpdate: options.onUpdate,
|
|
78
|
-
targetKey: options.targetKey,
|
|
79
|
-
sourceKey: options.sourceKey,
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Process @BelongsTo decorators and create association configuration.
|
|
86
|
-
*
|
|
87
|
-
* Call this to get the raw association definitions from decorators.
|
|
88
|
-
*
|
|
89
|
-
* @param ModelClass - The model class with @BelongsTo decorators
|
|
90
|
-
* @returns Array of association configurations
|
|
91
|
-
*/
|
|
92
|
-
function processBelongsToDecorators(ModelClass) {
|
|
93
|
-
const decorators = getAllBelongsTo(ModelClass);
|
|
94
|
-
return decorators.map(({ target, options }) => {
|
|
95
|
-
const targetModel = target();
|
|
96
|
-
const foreignKey = typeof options.foreignKey === 'string'
|
|
97
|
-
? options.foreignKey
|
|
98
|
-
: options.foreignKey?.name
|
|
99
|
-
? options.foreignKey.name
|
|
100
|
-
: `${targetModel.name}Id`;
|
|
101
|
-
return {
|
|
102
|
-
source: ModelClass,
|
|
103
|
-
target: targetModel,
|
|
104
|
-
foreignKey,
|
|
105
|
-
as: options.as || '',
|
|
106
|
-
options,
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
exports.default = {
|
|
111
|
-
BelongsTo,
|
|
112
|
-
getBelongsTo,
|
|
113
|
-
getAllBelongsTo,
|
|
114
|
-
processBelongsToDecorators,
|
|
115
|
-
};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* HasMany decorator for the ORM.
|
|
4
|
-
*
|
|
5
|
-
* Defines a one-to-many relationship between models.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* @HasMany(() => Post)
|
|
10
|
-
* posts: Post[];
|
|
11
|
-
*
|
|
12
|
-
* @HasMany(() => Post, { as: 'articles' })
|
|
13
|
-
* articles: Post[];
|
|
14
|
-
*
|
|
15
|
-
* // With options
|
|
16
|
-
* @HasMany(() => Order, {
|
|
17
|
-
* foreignKey: { name: 'user_id', allowNull: false },
|
|
18
|
-
* onDelete: 'CASCADE',
|
|
19
|
-
* through: 'user_orders' // For belongsToMany
|
|
20
|
-
* })
|
|
21
|
-
* orders: Order[];
|
|
22
|
-
*
|
|
23
|
-
* // Self-referential
|
|
24
|
-
* @HasMany(() => Category, { as: 'children', foreignKey: 'parent_id' })
|
|
25
|
-
* children: Category[];
|
|
26
|
-
*
|
|
27
|
-
* // Nested hasMany with scope
|
|
28
|
-
* @HasMany(() => Comment, {
|
|
29
|
-
* as: 'replies',
|
|
30
|
-
* foreignKey: 'parent_id',
|
|
31
|
-
* scope: { deleted: false }
|
|
32
|
-
* })
|
|
33
|
-
* replies: Comment[];
|
|
34
|
-
*/
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getHasMany = getHasMany;
|
|
37
|
-
exports.getAllHasMany = getAllHasMany;
|
|
38
|
-
exports.HasMany = HasMany;
|
|
39
|
-
exports.processHasManyDecorators = processHasManyDecorators;
|
|
40
|
-
// ==================== Metadata Storage ====================
|
|
41
|
-
const HAS_MANY_KEY = '__orm_has_many__';
|
|
42
|
-
/**
|
|
43
|
-
* Get all @HasMany annotations attached to a model constructor.
|
|
44
|
-
*/
|
|
45
|
-
function getHasMany(target) {
|
|
46
|
-
return target[HAS_MANY_KEY] || [];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get all hasMany associations including inherited ones.
|
|
50
|
-
*/
|
|
51
|
-
function getAllHasMany(target) {
|
|
52
|
-
const associations = [];
|
|
53
|
-
let current = target;
|
|
54
|
-
while (current && current.prototype) {
|
|
55
|
-
const meta = getHasMany(current);
|
|
56
|
-
associations.push(...meta);
|
|
57
|
-
current = Object.getPrototypeOf(current);
|
|
58
|
-
if (current === Object.prototype)
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
return associations;
|
|
62
|
-
}
|
|
63
|
-
// ==================== Decorator ====================
|
|
64
|
-
/**
|
|
65
|
-
* Define a one-to-many relationship.
|
|
66
|
-
*
|
|
67
|
-
* This decorator stores metadata on the model class that can be used
|
|
68
|
-
* by the ORM to establish the association at model initialization time.
|
|
69
|
-
*
|
|
70
|
-
* @param target - A function that returns the target model class
|
|
71
|
-
* @param options - Optional configuration for the association
|
|
72
|
-
*/
|
|
73
|
-
function HasMany(target, options = {}) {
|
|
74
|
-
return function (prototype, propertyKey) {
|
|
75
|
-
const ModelClass = prototype.constructor;
|
|
76
|
-
if (!ModelClass[HAS_MANY_KEY]) {
|
|
77
|
-
ModelClass[HAS_MANY_KEY] = [];
|
|
78
|
-
}
|
|
79
|
-
ModelClass[HAS_MANY_KEY].push({
|
|
80
|
-
target,
|
|
81
|
-
options: {
|
|
82
|
-
as: options.as || propertyKey.toString(),
|
|
83
|
-
foreignKey: options.foreignKey,
|
|
84
|
-
constraints: options.constraints,
|
|
85
|
-
onDelete: options.onDelete,
|
|
86
|
-
onUpdate: options.onUpdate,
|
|
87
|
-
targetKey: options.targetKey,
|
|
88
|
-
sourceKey: options.sourceKey,
|
|
89
|
-
scope: options.scope,
|
|
90
|
-
through: options.through,
|
|
91
|
-
inverse: options.inverse,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Process @HasMany decorators and create association configuration.
|
|
98
|
-
*
|
|
99
|
-
* Call this to get the raw association definitions from decorators.
|
|
100
|
-
*
|
|
101
|
-
* @param ModelClass - The model class with @HasMany decorators
|
|
102
|
-
* @returns Array of association configurations
|
|
103
|
-
*/
|
|
104
|
-
function processHasManyDecorators(ModelClass) {
|
|
105
|
-
const decorators = getAllHasMany(ModelClass);
|
|
106
|
-
return decorators.map(({ target, options }) => {
|
|
107
|
-
const targetModel = target();
|
|
108
|
-
const foreignKey = typeof options.foreignKey === 'string'
|
|
109
|
-
? options.foreignKey
|
|
110
|
-
: options.foreignKey?.name
|
|
111
|
-
? options.foreignKey.name
|
|
112
|
-
: `${ModelClass.name}Id`;
|
|
113
|
-
return {
|
|
114
|
-
source: ModelClass,
|
|
115
|
-
target: targetModel,
|
|
116
|
-
foreignKey,
|
|
117
|
-
as: options.as || '',
|
|
118
|
-
options,
|
|
119
|
-
};
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
exports.default = {
|
|
123
|
-
HasMany,
|
|
124
|
-
getHasMany,
|
|
125
|
-
getAllHasMany,
|
|
126
|
-
processHasManyDecorators,
|
|
127
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* HasOne decorator for the ORM.
|
|
4
|
-
*
|
|
5
|
-
* Defines a one-to-one relationship between models.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* @HasOne(() => Profile)
|
|
10
|
-
* profile: Profile;
|
|
11
|
-
*
|
|
12
|
-
* @HasOne(() => Profile, { as: 'userProfile' })
|
|
13
|
-
* userProfile: Profile;
|
|
14
|
-
*
|
|
15
|
-
* // With options
|
|
16
|
-
* @HasOne(() => Profile, {
|
|
17
|
-
* foreignKey: { name: 'user_id', allowNull: false },
|
|
18
|
-
* onDelete: 'CASCADE'
|
|
19
|
-
* })
|
|
20
|
-
* profile: Profile;
|
|
21
|
-
*
|
|
22
|
-
* // Self-referential
|
|
23
|
-
* @HasOne(() => User, { as: 'manager', foreignKey: 'manager_id' })
|
|
24
|
-
* manager: User;
|
|
25
|
-
*/
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.getHasOne = getHasOne;
|
|
28
|
-
exports.getAllHasOne = getAllHasOne;
|
|
29
|
-
exports.HasOne = HasOne;
|
|
30
|
-
exports.processHasOneDecorators = processHasOneDecorators;
|
|
31
|
-
// ==================== Metadata Storage ====================
|
|
32
|
-
const HAS_ONE_KEY = '__orm_has_one__';
|
|
33
|
-
/**
|
|
34
|
-
* Get all @HasOne annotations attached to a model constructor.
|
|
35
|
-
*/
|
|
36
|
-
function getHasOne(target) {
|
|
37
|
-
return target[HAS_ONE_KEY] || [];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get all hasOne associations including inherited ones.
|
|
41
|
-
*/
|
|
42
|
-
function getAllHasOne(target) {
|
|
43
|
-
const associations = [];
|
|
44
|
-
let current = target;
|
|
45
|
-
while (current && current.prototype) {
|
|
46
|
-
const meta = getHasOne(current);
|
|
47
|
-
associations.push(...meta);
|
|
48
|
-
current = Object.getPrototypeOf(current);
|
|
49
|
-
if (current === Object.prototype)
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
return associations;
|
|
53
|
-
}
|
|
54
|
-
// ==================== Decorator ====================
|
|
55
|
-
/**
|
|
56
|
-
* Define a one-to-one relationship.
|
|
57
|
-
*
|
|
58
|
-
* This decorator stores metadata on the model class that can be used
|
|
59
|
-
* by the ORM to establish the association at model initialization time.
|
|
60
|
-
*
|
|
61
|
-
* @param target - A function that returns the target model class
|
|
62
|
-
* @param options - Optional configuration for the association
|
|
63
|
-
*/
|
|
64
|
-
function HasOne(target, options = {}) {
|
|
65
|
-
return function (prototype, propertyKey) {
|
|
66
|
-
const ModelClass = prototype.constructor;
|
|
67
|
-
if (!ModelClass[HAS_ONE_KEY]) {
|
|
68
|
-
ModelClass[HAS_ONE_KEY] = [];
|
|
69
|
-
}
|
|
70
|
-
ModelClass[HAS_ONE_KEY].push({
|
|
71
|
-
target,
|
|
72
|
-
options: {
|
|
73
|
-
as: options.as || propertyKey.toString(),
|
|
74
|
-
foreignKey: options.foreignKey,
|
|
75
|
-
constraints: options.constraints,
|
|
76
|
-
onDelete: options.onDelete,
|
|
77
|
-
onUpdate: options.onUpdate,
|
|
78
|
-
targetKey: options.targetKey,
|
|
79
|
-
sourceKey: options.sourceKey,
|
|
80
|
-
inverse: options.inverse,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Process @HasOne decorators and create association configuration.
|
|
87
|
-
*
|
|
88
|
-
* Call this to get the raw association definitions from decorators.
|
|
89
|
-
*
|
|
90
|
-
* @param ModelClass - The model class with @HasOne decorators
|
|
91
|
-
* @returns Array of association configurations
|
|
92
|
-
*/
|
|
93
|
-
function processHasOneDecorators(ModelClass) {
|
|
94
|
-
const decorators = getAllHasOne(ModelClass);
|
|
95
|
-
return decorators.map(({ target, options }) => {
|
|
96
|
-
const targetModel = target();
|
|
97
|
-
const foreignKey = typeof options.foreignKey === 'string'
|
|
98
|
-
? options.foreignKey
|
|
99
|
-
: options.foreignKey?.name
|
|
100
|
-
? options.foreignKey.name
|
|
101
|
-
: `${ModelClass.name}Id`;
|
|
102
|
-
return {
|
|
103
|
-
source: ModelClass,
|
|
104
|
-
target: targetModel,
|
|
105
|
-
foreignKey,
|
|
106
|
-
as: options.as || '',
|
|
107
|
-
options,
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
exports.default = {
|
|
112
|
-
HasOne,
|
|
113
|
-
getHasOne,
|
|
114
|
-
getAllHasOne,
|
|
115
|
-
processHasOneDecorators,
|
|
116
|
-
};
|