@yandjin-mikro-orm/knex 6.1.4-rc-sti-changes-1
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/AbstractSqlConnection.d.ts +58 -0
- package/AbstractSqlConnection.js +206 -0
- package/AbstractSqlDriver.d.ts +73 -0
- package/AbstractSqlDriver.js +1378 -0
- package/AbstractSqlPlatform.d.ts +25 -0
- package/AbstractSqlPlatform.js +86 -0
- package/LICENSE +21 -0
- package/MonkeyPatchable.d.ts +11 -0
- package/MonkeyPatchable.js +39 -0
- package/PivotCollectionPersister.d.ts +17 -0
- package/PivotCollectionPersister.js +131 -0
- package/README.md +383 -0
- package/SqlEntityManager.d.ts +25 -0
- package/SqlEntityManager.js +40 -0
- package/SqlEntityRepository.d.ts +24 -0
- package/SqlEntityRepository.js +36 -0
- package/index.d.ts +18 -0
- package/index.js +40 -0
- package/index.mjs +215 -0
- package/package.json +71 -0
- package/query/ArrayCriteriaNode.d.ts +10 -0
- package/query/ArrayCriteriaNode.js +25 -0
- package/query/CriteriaNode.d.ts +31 -0
- package/query/CriteriaNode.js +147 -0
- package/query/CriteriaNodeFactory.d.ts +12 -0
- package/query/CriteriaNodeFactory.js +90 -0
- package/query/ObjectCriteriaNode.d.ts +15 -0
- package/query/ObjectCriteriaNode.js +233 -0
- package/query/QueryBuilder.d.ts +291 -0
- package/query/QueryBuilder.js +1445 -0
- package/query/QueryBuilderHelper.d.ts +64 -0
- package/query/QueryBuilderHelper.js +747 -0
- package/query/ScalarCriteriaNode.d.ts +10 -0
- package/query/ScalarCriteriaNode.js +56 -0
- package/query/enums.d.ts +15 -0
- package/query/enums.js +20 -0
- package/query/index.d.ts +8 -0
- package/query/index.js +24 -0
- package/schema/DatabaseSchema.d.ts +29 -0
- package/schema/DatabaseSchema.js +140 -0
- package/schema/DatabaseTable.d.ts +61 -0
- package/schema/DatabaseTable.js +727 -0
- package/schema/SchemaComparator.d.ts +59 -0
- package/schema/SchemaComparator.js +603 -0
- package/schema/SchemaHelper.d.ts +56 -0
- package/schema/SchemaHelper.js +274 -0
- package/schema/SqlSchemaGenerator.d.ts +63 -0
- package/schema/SqlSchemaGenerator.js +598 -0
- package/schema/index.d.ts +5 -0
- package/schema/index.js +21 -0
- package/typings.d.ts +174 -0
- package/typings.js +2 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import mod from "./index.js";
|
|
2
|
+
|
|
3
|
+
export default mod;
|
|
4
|
+
export const ALIAS_REPLACEMENT = mod.ALIAS_REPLACEMENT;
|
|
5
|
+
export const ALIAS_REPLACEMENT_RE = mod.ALIAS_REPLACEMENT_RE;
|
|
6
|
+
export const ARRAY_OPERATORS = mod.ARRAY_OPERATORS;
|
|
7
|
+
export const AbstractNamingStrategy = mod.AbstractNamingStrategy;
|
|
8
|
+
export const AbstractSchemaGenerator = mod.AbstractSchemaGenerator;
|
|
9
|
+
export const AbstractSqlConnection = mod.AbstractSqlConnection;
|
|
10
|
+
export const AbstractSqlDriver = mod.AbstractSqlDriver;
|
|
11
|
+
export const AbstractSqlPlatform = mod.AbstractSqlPlatform;
|
|
12
|
+
export const AfterCreate = mod.AfterCreate;
|
|
13
|
+
export const AfterDelete = mod.AfterDelete;
|
|
14
|
+
export const AfterUpdate = mod.AfterUpdate;
|
|
15
|
+
export const AfterUpsert = mod.AfterUpsert;
|
|
16
|
+
export const ArrayCollection = mod.ArrayCollection;
|
|
17
|
+
export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
|
|
18
|
+
export const ArrayType = mod.ArrayType;
|
|
19
|
+
export const BaseEntity = mod.BaseEntity;
|
|
20
|
+
export const BeforeCreate = mod.BeforeCreate;
|
|
21
|
+
export const BeforeDelete = mod.BeforeDelete;
|
|
22
|
+
export const BeforeUpdate = mod.BeforeUpdate;
|
|
23
|
+
export const BeforeUpsert = mod.BeforeUpsert;
|
|
24
|
+
export const BigIntType = mod.BigIntType;
|
|
25
|
+
export const BlobType = mod.BlobType;
|
|
26
|
+
export const BooleanType = mod.BooleanType;
|
|
27
|
+
export const Cascade = mod.Cascade;
|
|
28
|
+
export const ChangeSet = mod.ChangeSet;
|
|
29
|
+
export const ChangeSetComputer = mod.ChangeSetComputer;
|
|
30
|
+
export const ChangeSetPersister = mod.ChangeSetPersister;
|
|
31
|
+
export const ChangeSetType = mod.ChangeSetType;
|
|
32
|
+
export const Check = mod.Check;
|
|
33
|
+
export const CheckConstraintViolationException = mod.CheckConstraintViolationException;
|
|
34
|
+
export const Collection = mod.Collection;
|
|
35
|
+
export const CommitOrderCalculator = mod.CommitOrderCalculator;
|
|
36
|
+
export const Config = mod.Config;
|
|
37
|
+
export const Configuration = mod.Configuration;
|
|
38
|
+
export const ConfigurationLoader = mod.ConfigurationLoader;
|
|
39
|
+
export const Connection = mod.Connection;
|
|
40
|
+
export const ConnectionException = mod.ConnectionException;
|
|
41
|
+
export const ConstraintViolationException = mod.ConstraintViolationException;
|
|
42
|
+
export const CreateRequestContext = mod.CreateRequestContext;
|
|
43
|
+
export const CriteriaNode = mod.CriteriaNode;
|
|
44
|
+
export const CriteriaNodeFactory = mod.CriteriaNodeFactory;
|
|
45
|
+
export const Cursor = mod.Cursor;
|
|
46
|
+
export const CursorError = mod.CursorError;
|
|
47
|
+
export const DatabaseDriver = mod.DatabaseDriver;
|
|
48
|
+
export const DatabaseObjectExistsException = mod.DatabaseObjectExistsException;
|
|
49
|
+
export const DatabaseObjectNotFoundException = mod.DatabaseObjectNotFoundException;
|
|
50
|
+
export const DatabaseSchema = mod.DatabaseSchema;
|
|
51
|
+
export const DatabaseTable = mod.DatabaseTable;
|
|
52
|
+
export const DataloaderType = mod.DataloaderType;
|
|
53
|
+
export const DataloaderUtils = mod.DataloaderUtils;
|
|
54
|
+
export const DateTimeType = mod.DateTimeType;
|
|
55
|
+
export const DateType = mod.DateType;
|
|
56
|
+
export const DeadlockException = mod.DeadlockException;
|
|
57
|
+
export const DecimalType = mod.DecimalType;
|
|
58
|
+
export const DefaultLogger = mod.DefaultLogger;
|
|
59
|
+
export const DoubleType = mod.DoubleType;
|
|
60
|
+
export const DriverException = mod.DriverException;
|
|
61
|
+
export const EagerProps = mod.EagerProps;
|
|
62
|
+
export const Embeddable = mod.Embeddable;
|
|
63
|
+
export const Embedded = mod.Embedded;
|
|
64
|
+
export const EnsureRequestContext = mod.EnsureRequestContext;
|
|
65
|
+
export const Entity = mod.Entity;
|
|
66
|
+
export const EntityAssigner = mod.EntityAssigner;
|
|
67
|
+
export const EntityCaseNamingStrategy = mod.EntityCaseNamingStrategy;
|
|
68
|
+
export const EntityComparator = mod.EntityComparator;
|
|
69
|
+
export const EntityFactory = mod.EntityFactory;
|
|
70
|
+
export const EntityHelper = mod.EntityHelper;
|
|
71
|
+
export const EntityIdentifier = mod.EntityIdentifier;
|
|
72
|
+
export const EntityLoader = mod.EntityLoader;
|
|
73
|
+
export const EntityManager = mod.EntityManager;
|
|
74
|
+
export const EntityManagerType = mod.EntityManagerType;
|
|
75
|
+
export const EntityMetadata = mod.EntityMetadata;
|
|
76
|
+
export const EntityRepository = mod.EntityRepository;
|
|
77
|
+
export const EntityRepositoryType = mod.EntityRepositoryType;
|
|
78
|
+
export const EntitySchema = mod.EntitySchema;
|
|
79
|
+
export const EntitySerializer = mod.EntitySerializer;
|
|
80
|
+
export const EntityTransformer = mod.EntityTransformer;
|
|
81
|
+
export const EntityValidator = mod.EntityValidator;
|
|
82
|
+
export const Enum = mod.Enum;
|
|
83
|
+
export const EnumArrayType = mod.EnumArrayType;
|
|
84
|
+
export const EnumType = mod.EnumType;
|
|
85
|
+
export const EventManager = mod.EventManager;
|
|
86
|
+
export const EventType = mod.EventType;
|
|
87
|
+
export const EventTypeMap = mod.EventTypeMap;
|
|
88
|
+
export const ExceptionConverter = mod.ExceptionConverter;
|
|
89
|
+
export const FileCacheAdapter = mod.FileCacheAdapter;
|
|
90
|
+
export const Filter = mod.Filter;
|
|
91
|
+
export const FloatType = mod.FloatType;
|
|
92
|
+
export const FlushMode = mod.FlushMode;
|
|
93
|
+
export const ForeignKeyConstraintViolationException = mod.ForeignKeyConstraintViolationException;
|
|
94
|
+
export const Formula = mod.Formula;
|
|
95
|
+
export const GeneratedCacheAdapter = mod.GeneratedCacheAdapter;
|
|
96
|
+
export const GroupOperator = mod.GroupOperator;
|
|
97
|
+
export const HiddenProps = mod.HiddenProps;
|
|
98
|
+
export const Hydrator = mod.Hydrator;
|
|
99
|
+
export const IdentityMap = mod.IdentityMap;
|
|
100
|
+
export const Index = mod.Index;
|
|
101
|
+
export const IntegerType = mod.IntegerType;
|
|
102
|
+
export const IntervalType = mod.IntervalType;
|
|
103
|
+
export const InvalidFieldNameException = mod.InvalidFieldNameException;
|
|
104
|
+
export const IsolationLevel = mod.IsolationLevel;
|
|
105
|
+
export const JoinType = mod.JoinType;
|
|
106
|
+
export const JsonProperty = mod.JsonProperty;
|
|
107
|
+
export const JsonType = mod.JsonType;
|
|
108
|
+
export const Knex = mod.Knex;
|
|
109
|
+
export const LoadStrategy = mod.LoadStrategy;
|
|
110
|
+
export const LockMode = mod.LockMode;
|
|
111
|
+
export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
|
|
112
|
+
export const ManyToMany = mod.ManyToMany;
|
|
113
|
+
export const ManyToOne = mod.ManyToOne;
|
|
114
|
+
export const MediumIntType = mod.MediumIntType;
|
|
115
|
+
export const MemoryCacheAdapter = mod.MemoryCacheAdapter;
|
|
116
|
+
export const MetadataDiscovery = mod.MetadataDiscovery;
|
|
117
|
+
export const MetadataError = mod.MetadataError;
|
|
118
|
+
export const MetadataProvider = mod.MetadataProvider;
|
|
119
|
+
export const MetadataStorage = mod.MetadataStorage;
|
|
120
|
+
export const MetadataValidator = mod.MetadataValidator;
|
|
121
|
+
export const MikroORM = mod.MikroORM;
|
|
122
|
+
export const MongoNamingStrategy = mod.MongoNamingStrategy;
|
|
123
|
+
export const MonkeyPatchable = mod.MonkeyPatchable;
|
|
124
|
+
export const NodeState = mod.NodeState;
|
|
125
|
+
export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
|
|
126
|
+
export const NotFoundError = mod.NotFoundError;
|
|
127
|
+
export const NotNullConstraintViolationException = mod.NotNullConstraintViolationException;
|
|
128
|
+
export const NullCacheAdapter = mod.NullCacheAdapter;
|
|
129
|
+
export const NullHighlighter = mod.NullHighlighter;
|
|
130
|
+
export const ObjectBindingPattern = mod.ObjectBindingPattern;
|
|
131
|
+
export const ObjectCriteriaNode = mod.ObjectCriteriaNode;
|
|
132
|
+
export const ObjectHydrator = mod.ObjectHydrator;
|
|
133
|
+
export const OnInit = mod.OnInit;
|
|
134
|
+
export const OnLoad = mod.OnLoad;
|
|
135
|
+
export const OneToMany = mod.OneToMany;
|
|
136
|
+
export const OneToOne = mod.OneToOne;
|
|
137
|
+
export const OptimisticLockError = mod.OptimisticLockError;
|
|
138
|
+
export const OptionalProps = mod.OptionalProps;
|
|
139
|
+
export const PlainObject = mod.PlainObject;
|
|
140
|
+
export const Platform = mod.Platform;
|
|
141
|
+
export const PopulateHint = mod.PopulateHint;
|
|
142
|
+
export const PrimaryKey = mod.PrimaryKey;
|
|
143
|
+
export const PrimaryKeyProp = mod.PrimaryKeyProp;
|
|
144
|
+
export const Property = mod.Property;
|
|
145
|
+
export const QueryBuilder = mod.QueryBuilder;
|
|
146
|
+
export const QueryBuilderHelper = mod.QueryBuilderHelper;
|
|
147
|
+
export const QueryFlag = mod.QueryFlag;
|
|
148
|
+
export const QueryHelper = mod.QueryHelper;
|
|
149
|
+
export const QueryOperator = mod.QueryOperator;
|
|
150
|
+
export const QueryOrder = mod.QueryOrder;
|
|
151
|
+
export const QueryOrderNumeric = mod.QueryOrderNumeric;
|
|
152
|
+
export const QueryType = mod.QueryType;
|
|
153
|
+
export const RawQueryFragment = mod.RawQueryFragment;
|
|
154
|
+
export const ReadOnlyException = mod.ReadOnlyException;
|
|
155
|
+
export const Ref = mod.Ref;
|
|
156
|
+
export const Reference = mod.Reference;
|
|
157
|
+
export const ReferenceKind = mod.ReferenceKind;
|
|
158
|
+
export const ReflectMetadataProvider = mod.ReflectMetadataProvider;
|
|
159
|
+
export const RequestContext = mod.RequestContext;
|
|
160
|
+
export const SCALAR_TYPES = mod.SCALAR_TYPES;
|
|
161
|
+
export const ScalarCriteriaNode = mod.ScalarCriteriaNode;
|
|
162
|
+
export const ScalarReference = mod.ScalarReference;
|
|
163
|
+
export const SchemaComparator = mod.SchemaComparator;
|
|
164
|
+
export const SchemaGenerator = mod.SchemaGenerator;
|
|
165
|
+
export const SchemaHelper = mod.SchemaHelper;
|
|
166
|
+
export const SerializationContext = mod.SerializationContext;
|
|
167
|
+
export const SerializedPrimaryKey = mod.SerializedPrimaryKey;
|
|
168
|
+
export const ServerException = mod.ServerException;
|
|
169
|
+
export const SimpleLogger = mod.SimpleLogger;
|
|
170
|
+
export const SmallIntType = mod.SmallIntType;
|
|
171
|
+
export const SqlEntityManager = mod.SqlEntityManager;
|
|
172
|
+
export const SqlEntityRepository = mod.SqlEntityRepository;
|
|
173
|
+
export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
|
|
174
|
+
export const StringType = mod.StringType;
|
|
175
|
+
export const SyntaxErrorException = mod.SyntaxErrorException;
|
|
176
|
+
export const TableExistsException = mod.TableExistsException;
|
|
177
|
+
export const TableNotFoundException = mod.TableNotFoundException;
|
|
178
|
+
export const TextType = mod.TextType;
|
|
179
|
+
export const TimeType = mod.TimeType;
|
|
180
|
+
export const TinyIntType = mod.TinyIntType;
|
|
181
|
+
export const TransactionContext = mod.TransactionContext;
|
|
182
|
+
export const TransactionEventBroadcaster = mod.TransactionEventBroadcaster;
|
|
183
|
+
export const Type = mod.Type;
|
|
184
|
+
export const Uint8ArrayType = mod.Uint8ArrayType;
|
|
185
|
+
export const UnderscoreNamingStrategy = mod.UnderscoreNamingStrategy;
|
|
186
|
+
export const Unique = mod.Unique;
|
|
187
|
+
export const UniqueConstraintViolationException = mod.UniqueConstraintViolationException;
|
|
188
|
+
export const UnitOfWork = mod.UnitOfWork;
|
|
189
|
+
export const UnknownType = mod.UnknownType;
|
|
190
|
+
export const Utils = mod.Utils;
|
|
191
|
+
export const UuidType = mod.UuidType;
|
|
192
|
+
export const ValidationError = mod.ValidationError;
|
|
193
|
+
export const WrappedEntity = mod.WrappedEntity;
|
|
194
|
+
export const assign = mod.assign;
|
|
195
|
+
export const colors = mod.colors;
|
|
196
|
+
export const compareArrays = mod.compareArrays;
|
|
197
|
+
export const compareBooleans = mod.compareBooleans;
|
|
198
|
+
export const compareBuffers = mod.compareBuffers;
|
|
199
|
+
export const compareObjects = mod.compareObjects;
|
|
200
|
+
export const createSqlFunction = mod.createSqlFunction;
|
|
201
|
+
export const defineConfig = mod.defineConfig;
|
|
202
|
+
export const equals = mod.equals;
|
|
203
|
+
export const getOnConflictFields = mod.getOnConflictFields;
|
|
204
|
+
export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
|
|
205
|
+
export const helper = mod.helper;
|
|
206
|
+
export const knex = mod.knex;
|
|
207
|
+
export const parseJsonSafe = mod.parseJsonSafe;
|
|
208
|
+
export const raw = mod.raw;
|
|
209
|
+
export const ref = mod.ref;
|
|
210
|
+
export const rel = mod.rel;
|
|
211
|
+
export const serialize = mod.serialize;
|
|
212
|
+
export const sql = mod.sql;
|
|
213
|
+
export const t = mod.t;
|
|
214
|
+
export const types = mod.types;
|
|
215
|
+
export const wrap = mod.wrap;
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yandjin-mikro-orm/knex",
|
|
3
|
+
"version": "6.1.4-rc-sti-changes-1",
|
|
4
|
+
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "index.mjs",
|
|
7
|
+
"typings": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"default": "./index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": "./index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"orm",
|
|
24
|
+
"mongo",
|
|
25
|
+
"mongodb",
|
|
26
|
+
"mysql",
|
|
27
|
+
"mariadb",
|
|
28
|
+
"postgresql",
|
|
29
|
+
"sqlite",
|
|
30
|
+
"sqlite3",
|
|
31
|
+
"ts",
|
|
32
|
+
"typescript",
|
|
33
|
+
"js",
|
|
34
|
+
"javascript",
|
|
35
|
+
"entity",
|
|
36
|
+
"ddd",
|
|
37
|
+
"mikro-orm",
|
|
38
|
+
"unit-of-work",
|
|
39
|
+
"data-mapper",
|
|
40
|
+
"identity-map"
|
|
41
|
+
],
|
|
42
|
+
"author": "Martin Adámek",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/mikro-orm/mikro-orm/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://mikro-orm.io",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">= 18.12.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "yarn clean && yarn compile && yarn copy && yarn run -T gen-esm-wrapper index.js index.mjs",
|
|
53
|
+
"clean": "yarn run -T rimraf ./dist",
|
|
54
|
+
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
55
|
+
"copy": "node ../../scripts/copy.mjs"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"fs-extra": "11.2.0",
|
|
62
|
+
"knex": "3.1.0",
|
|
63
|
+
"sqlstring": "2.3.3"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@yandjin-mikro-orm/core": "^6.1.4-rc-sti-changes-1"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@yandjin-mikro-orm/core": "^6.0.0"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CriteriaNode } from './CriteriaNode';
|
|
2
|
+
import type { IQueryBuilder, ICriteriaNodeProcessOptions } from '../typings';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class ArrayCriteriaNode<T extends object> extends CriteriaNode<T> {
|
|
7
|
+
process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
|
|
8
|
+
unwrap(): any;
|
|
9
|
+
willAutoJoin(qb: IQueryBuilder<T>, alias?: string): any;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayCriteriaNode = void 0;
|
|
4
|
+
const CriteriaNode_1 = require("./CriteriaNode");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
class ArrayCriteriaNode extends CriteriaNode_1.CriteriaNode {
|
|
9
|
+
process(qb, options) {
|
|
10
|
+
return this.payload.map((node) => {
|
|
11
|
+
return node.process(qb, options);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
unwrap() {
|
|
15
|
+
return this.payload.map((node) => {
|
|
16
|
+
return node.unwrap();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
willAutoJoin(qb, alias) {
|
|
20
|
+
return this.payload.some((node) => {
|
|
21
|
+
return node.willAutoJoin(qb, alias);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ArrayCriteriaNode = ArrayCriteriaNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { inspect } from "util";
|
|
3
|
+
import { type EntityKey, type EntityProperty, type MetadataStorage } from "@yandjin-mikro-orm/core";
|
|
4
|
+
import type { ICriteriaNode, ICriteriaNodeProcessOptions, IQueryBuilder } from "../typings";
|
|
5
|
+
/**
|
|
6
|
+
* Helper for working with deeply nested where/orderBy/having criteria. Uses composite pattern to build tree from the payload.
|
|
7
|
+
* Auto-joins relations and converts payload from { books: { publisher: { name: '...' } } } to { 'publisher_alias.name': '...' }
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class CriteriaNode<T extends object> implements ICriteriaNode<T> {
|
|
11
|
+
protected readonly metadata: MetadataStorage;
|
|
12
|
+
readonly entityName: string;
|
|
13
|
+
readonly parent?: ICriteriaNode<T> | undefined;
|
|
14
|
+
readonly key?: EntityKey<T> | undefined;
|
|
15
|
+
payload: any;
|
|
16
|
+
prop?: EntityProperty<T>;
|
|
17
|
+
index?: number;
|
|
18
|
+
constructor(metadata: MetadataStorage, entityName: string, parent?: ICriteriaNode<T> | undefined, key?: EntityKey<T> | undefined, validate?: boolean);
|
|
19
|
+
process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
|
|
20
|
+
unwrap(): any;
|
|
21
|
+
shouldInline(payload: any): boolean;
|
|
22
|
+
willAutoJoin(qb: IQueryBuilder<T>, alias?: string): boolean;
|
|
23
|
+
shouldRename(payload: any): boolean;
|
|
24
|
+
renameFieldToPK<T>(qb: IQueryBuilder<T>): string;
|
|
25
|
+
getPath(addIndex?: boolean): string;
|
|
26
|
+
private isPivotJoin;
|
|
27
|
+
getPivotPath(path: string): string;
|
|
28
|
+
aliased(field: string, alias?: string): string;
|
|
29
|
+
/** @ignore */
|
|
30
|
+
[inspect.custom](): string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CriteriaNode = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const core_1 = require("@yandjin-mikro-orm/core");
|
|
6
|
+
/**
|
|
7
|
+
* Helper for working with deeply nested where/orderBy/having criteria. Uses composite pattern to build tree from the payload.
|
|
8
|
+
* Auto-joins relations and converts payload from { books: { publisher: { name: '...' } } } to { 'publisher_alias.name': '...' }
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
class CriteriaNode {
|
|
12
|
+
metadata;
|
|
13
|
+
entityName;
|
|
14
|
+
parent;
|
|
15
|
+
key;
|
|
16
|
+
payload;
|
|
17
|
+
prop;
|
|
18
|
+
index;
|
|
19
|
+
constructor(metadata, entityName, parent, key, validate = true) {
|
|
20
|
+
this.metadata = metadata;
|
|
21
|
+
this.entityName = entityName;
|
|
22
|
+
this.parent = parent;
|
|
23
|
+
this.key = key;
|
|
24
|
+
const meta = parent && metadata.find(parent.entityName);
|
|
25
|
+
if (meta && key) {
|
|
26
|
+
const pks = core_1.Utils.splitPrimaryKeys(key);
|
|
27
|
+
if (pks.length > 1) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
pks.forEach((k) => {
|
|
31
|
+
this.prop = meta.props.find((prop) => prop.name === k ||
|
|
32
|
+
(prop.fieldNames?.length === 1 && prop.fieldNames[0] === k));
|
|
33
|
+
const isProp = this.prop ||
|
|
34
|
+
meta.props.find((prop) => (prop.fieldNames || []).includes(k));
|
|
35
|
+
// do not validate if the key is prefixed or type casted (e.g. `k::text`)
|
|
36
|
+
if (validate &&
|
|
37
|
+
!isProp &&
|
|
38
|
+
!k.includes(".") &&
|
|
39
|
+
!k.includes("::") &&
|
|
40
|
+
!core_1.Utils.isOperator(k) &&
|
|
41
|
+
!core_1.RawQueryFragment.isKnownFragment(k)) {
|
|
42
|
+
throw new Error(`Trying to query by not existing property ${entityName}.${k}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
process(qb, options) {
|
|
48
|
+
return this.payload;
|
|
49
|
+
}
|
|
50
|
+
unwrap() {
|
|
51
|
+
return this.payload;
|
|
52
|
+
}
|
|
53
|
+
shouldInline(payload) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
willAutoJoin(qb, alias) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
shouldRename(payload) {
|
|
60
|
+
const type = this.prop ? this.prop.kind : null;
|
|
61
|
+
const composite = this.prop?.joinColumns
|
|
62
|
+
? this.prop.joinColumns.length > 1
|
|
63
|
+
: false;
|
|
64
|
+
const customExpression = core_1.RawQueryFragment.isKnownFragment(this.key);
|
|
65
|
+
const scalar = payload === null ||
|
|
66
|
+
core_1.Utils.isPrimaryKey(payload) ||
|
|
67
|
+
payload instanceof RegExp ||
|
|
68
|
+
payload instanceof Date ||
|
|
69
|
+
customExpression;
|
|
70
|
+
const plainObject = core_1.Utils.isPlainObject(payload);
|
|
71
|
+
const keys = plainObject ? Object.keys(payload) : [];
|
|
72
|
+
const operator = plainObject && keys.every((k) => core_1.Utils.isOperator(k, false));
|
|
73
|
+
if (composite) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
switch (type) {
|
|
77
|
+
case core_1.ReferenceKind.MANY_TO_ONE:
|
|
78
|
+
return false;
|
|
79
|
+
case core_1.ReferenceKind.ONE_TO_ONE:
|
|
80
|
+
return !this.prop.owner;
|
|
81
|
+
case core_1.ReferenceKind.ONE_TO_MANY:
|
|
82
|
+
return scalar || operator;
|
|
83
|
+
case core_1.ReferenceKind.MANY_TO_MANY:
|
|
84
|
+
return scalar || operator;
|
|
85
|
+
default:
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
renameFieldToPK(qb) {
|
|
90
|
+
const joinAlias = qb.getAliasForJoinPath(this.getPath());
|
|
91
|
+
const alias = joinAlias ?? qb.alias;
|
|
92
|
+
if (this.prop.kind === core_1.ReferenceKind.MANY_TO_MANY) {
|
|
93
|
+
return core_1.Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map((col) => `${alias}.${col}`));
|
|
94
|
+
}
|
|
95
|
+
// if we found a matching join, we need to use the target table column names, as we use that alias instead of the root
|
|
96
|
+
if (!joinAlias && this.prop.owner && this.prop.joinColumns.length > 1) {
|
|
97
|
+
return core_1.Utils.getPrimaryKeyHash(this.prop.joinColumns.map((col) => `${alias}.${col}`));
|
|
98
|
+
}
|
|
99
|
+
return core_1.Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map((col) => `${alias}.${col}`));
|
|
100
|
+
}
|
|
101
|
+
getPath(addIndex = false) {
|
|
102
|
+
// use index on parent only if we are processing to-many relation
|
|
103
|
+
const addParentIndex = this.prop &&
|
|
104
|
+
[core_1.ReferenceKind.ONE_TO_MANY, core_1.ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
|
|
105
|
+
const parentPath = this.parent?.getPath(addParentIndex) ?? this.entityName;
|
|
106
|
+
const index = addIndex && this.index != null ? `[${this.index}]` : "";
|
|
107
|
+
// ignore group operators to allow easier mapping (e.g. for orderBy)
|
|
108
|
+
const key = this.key && !["$and", "$or", "$not"].includes(this.key)
|
|
109
|
+
? "." + this.key
|
|
110
|
+
: "";
|
|
111
|
+
const ret = parentPath + index + key;
|
|
112
|
+
if (this.isPivotJoin()) {
|
|
113
|
+
// distinguish pivot table join from target entity join
|
|
114
|
+
return this.getPivotPath(ret);
|
|
115
|
+
}
|
|
116
|
+
return ret;
|
|
117
|
+
}
|
|
118
|
+
isPivotJoin() {
|
|
119
|
+
if (!this.key || !this.prop) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const customExpression = core_1.RawQueryFragment.isKnownFragment(this.key);
|
|
123
|
+
const scalar = this.payload === null ||
|
|
124
|
+
core_1.Utils.isPrimaryKey(this.payload) ||
|
|
125
|
+
this.payload instanceof RegExp ||
|
|
126
|
+
this.payload instanceof Date ||
|
|
127
|
+
customExpression;
|
|
128
|
+
const operator = core_1.Utils.isObject(this.payload) &&
|
|
129
|
+
Object.keys(this.payload).every((k) => core_1.Utils.isOperator(k, false));
|
|
130
|
+
return (this.prop.kind === core_1.ReferenceKind.MANY_TO_MANY && (scalar || operator));
|
|
131
|
+
}
|
|
132
|
+
getPivotPath(path) {
|
|
133
|
+
return `${path}[pivot]`;
|
|
134
|
+
}
|
|
135
|
+
aliased(field, alias) {
|
|
136
|
+
return alias ? `${alias}.${field}` : field;
|
|
137
|
+
}
|
|
138
|
+
/** @ignore */
|
|
139
|
+
[util_1.inspect.custom]() {
|
|
140
|
+
const o = {};
|
|
141
|
+
["entityName", "key", "index", "payload"]
|
|
142
|
+
.filter((k) => this[k] !== undefined)
|
|
143
|
+
.forEach((k) => (o[k] = this[k]));
|
|
144
|
+
return `${this.constructor.name} ${(0, util_1.inspect)(o)}`;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.CriteriaNode = CriteriaNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Dictionary, type EntityKey, type EntityMetadata, type MetadataStorage } from "@yandjin-mikro-orm/core";
|
|
2
|
+
import type { ICriteriaNode } from "../typings";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class CriteriaNodeFactory {
|
|
7
|
+
static createNode<T extends object>(metadata: MetadataStorage, entityName: string, payload: any, parent?: ICriteriaNode<T>, key?: EntityKey<T>): ICriteriaNode<T>;
|
|
8
|
+
static createScalarNode<T extends object>(metadata: MetadataStorage, entityName: string, payload: any, parent?: ICriteriaNode<T>, key?: EntityKey<T>): ICriteriaNode<T>;
|
|
9
|
+
static createArrayNode<T extends object>(metadata: MetadataStorage, entityName: string, payload: any[], parent?: ICriteriaNode<T>, key?: EntityKey<T>): ICriteriaNode<T>;
|
|
10
|
+
static createObjectNode<T extends object>(metadata: MetadataStorage, entityName: string, payload: Dictionary, parent?: ICriteriaNode<T>, key?: EntityKey<T>): ICriteriaNode<T>;
|
|
11
|
+
static createObjectItemNode<T extends object>(metadata: MetadataStorage, entityName: string, node: ICriteriaNode<T>, payload: Dictionary, key: EntityKey<T>, meta?: EntityMetadata<T>): ICriteriaNode<T>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CriteriaNodeFactory = void 0;
|
|
4
|
+
const core_1 = require("@yandjin-mikro-orm/core");
|
|
5
|
+
const ObjectCriteriaNode_1 = require("./ObjectCriteriaNode");
|
|
6
|
+
const ArrayCriteriaNode_1 = require("./ArrayCriteriaNode");
|
|
7
|
+
const ScalarCriteriaNode_1 = require("./ScalarCriteriaNode");
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
class CriteriaNodeFactory {
|
|
12
|
+
static createNode(metadata, entityName, payload, parent, key) {
|
|
13
|
+
const customExpression = core_1.RawQueryFragment.isKnownFragment(key || "");
|
|
14
|
+
const scalar = core_1.Utils.isPrimaryKey(payload) ||
|
|
15
|
+
core_1.Utils.isRawSql(payload) ||
|
|
16
|
+
payload instanceof RegExp ||
|
|
17
|
+
payload instanceof Date ||
|
|
18
|
+
customExpression;
|
|
19
|
+
if (Array.isArray(payload) && !scalar) {
|
|
20
|
+
return this.createArrayNode(metadata, entityName, payload, parent, key);
|
|
21
|
+
}
|
|
22
|
+
if (core_1.Utils.isPlainObject(payload) && !scalar) {
|
|
23
|
+
return this.createObjectNode(metadata, entityName, payload, parent, key);
|
|
24
|
+
}
|
|
25
|
+
return this.createScalarNode(metadata, entityName, payload, parent, key);
|
|
26
|
+
}
|
|
27
|
+
static createScalarNode(metadata, entityName, payload, parent, key) {
|
|
28
|
+
const node = new ScalarCriteriaNode_1.ScalarCriteriaNode(metadata, entityName, parent, key);
|
|
29
|
+
node.payload = payload;
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
static createArrayNode(metadata, entityName, payload, parent, key) {
|
|
33
|
+
const node = new ArrayCriteriaNode_1.ArrayCriteriaNode(metadata, entityName, parent, key);
|
|
34
|
+
node.payload = payload.map((item, index) => {
|
|
35
|
+
const n = this.createNode(metadata, entityName, item, node);
|
|
36
|
+
// we care about branching only for $and
|
|
37
|
+
if (key === "$and" && payload.length > 1) {
|
|
38
|
+
n.index = index;
|
|
39
|
+
}
|
|
40
|
+
return n;
|
|
41
|
+
});
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
static createObjectNode(metadata, entityName, payload, parent, key) {
|
|
45
|
+
const meta = metadata.find(entityName);
|
|
46
|
+
const node = new ObjectCriteriaNode_1.ObjectCriteriaNode(metadata, entityName, parent, key);
|
|
47
|
+
node.payload = Object.keys(payload).reduce((o, item) => {
|
|
48
|
+
o[item] = this.createObjectItemNode(metadata, entityName, node, payload, item, meta);
|
|
49
|
+
return o;
|
|
50
|
+
}, {});
|
|
51
|
+
return node;
|
|
52
|
+
}
|
|
53
|
+
static createObjectItemNode(metadata, entityName, node, payload, key, meta) {
|
|
54
|
+
const prop = meta?.properties[key];
|
|
55
|
+
const childEntity = prop && prop.kind !== core_1.ReferenceKind.SCALAR ? prop.type : entityName;
|
|
56
|
+
if (prop?.kind !== core_1.ReferenceKind.EMBEDDED) {
|
|
57
|
+
return this.createNode(metadata, childEntity, payload[key], node, key);
|
|
58
|
+
}
|
|
59
|
+
if (payload[key] == null) {
|
|
60
|
+
const map = Object.keys(prop.embeddedProps).reduce((oo, k) => {
|
|
61
|
+
oo[prop.embeddedProps[k].name] = null;
|
|
62
|
+
return oo;
|
|
63
|
+
}, {});
|
|
64
|
+
return this.createNode(metadata, entityName, map, node, key);
|
|
65
|
+
}
|
|
66
|
+
// array operators can be used on embedded properties
|
|
67
|
+
const allowedOperators = ["$contains", "$contained", "$overlap"];
|
|
68
|
+
const operator = Object.keys(payload[key]).some((f) => core_1.Utils.isOperator(f) && !allowedOperators.includes(f));
|
|
69
|
+
if (operator) {
|
|
70
|
+
throw core_1.ValidationError.cannotUseOperatorsInsideEmbeddables(entityName, prop.name, payload);
|
|
71
|
+
}
|
|
72
|
+
const map = Object.keys(payload[key]).reduce((oo, k) => {
|
|
73
|
+
if (!prop.embeddedProps[k] && !allowedOperators.includes(k)) {
|
|
74
|
+
throw core_1.ValidationError.invalidEmbeddableQuery(entityName, k, prop.type);
|
|
75
|
+
}
|
|
76
|
+
if (prop.embeddedProps[k]) {
|
|
77
|
+
oo[prop.embeddedProps[k].name] = payload[key][k];
|
|
78
|
+
}
|
|
79
|
+
else if (typeof payload[key][k] === "object") {
|
|
80
|
+
oo[k] = JSON.stringify(payload[key][k]);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
oo[k] = payload[key][k];
|
|
84
|
+
}
|
|
85
|
+
return oo;
|
|
86
|
+
}, {});
|
|
87
|
+
return this.createNode(metadata, entityName, map, node, key);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.CriteriaNodeFactory = CriteriaNodeFactory;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CriteriaNode } from "./CriteriaNode";
|
|
2
|
+
import type { ICriteriaNodeProcessOptions, IQueryBuilder } from "../typings";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class ObjectCriteriaNode<T extends object> extends CriteriaNode<T> {
|
|
7
|
+
process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
|
|
8
|
+
unwrap(): any;
|
|
9
|
+
willAutoJoin(qb: IQueryBuilder<T>, alias?: string): boolean;
|
|
10
|
+
shouldInline(payload: any): boolean;
|
|
11
|
+
private inlineChildPayload;
|
|
12
|
+
private shouldAutoJoin;
|
|
13
|
+
private autoJoin;
|
|
14
|
+
private isPrefixed;
|
|
15
|
+
}
|