joist-orm 1.114.0 → 1.115.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/build/src/AliasAssigner.d.ts +6 -0
- package/build/src/AliasAssigner.d.ts.map +1 -0
- package/build/src/AliasAssigner.js +18 -0
- package/build/src/AliasAssigner.js.map +1 -0
- package/build/src/Aliases.d.ts +11 -3
- package/build/src/Aliases.d.ts.map +1 -1
- package/build/src/Aliases.js +25 -9
- package/build/src/Aliases.js.map +1 -1
- package/build/src/EntityManager.d.ts +17 -3
- package/build/src/EntityManager.d.ts.map +1 -1
- package/build/src/EntityManager.js +57 -74
- package/build/src/EntityManager.js.map +1 -1
- package/build/src/HintTree.d.ts +38 -0
- package/build/src/HintTree.d.ts.map +1 -0
- package/build/src/HintTree.js +47 -0
- package/build/src/HintTree.js.map +1 -0
- package/build/src/JoinRows.d.ts +2 -0
- package/build/src/JoinRows.d.ts.map +1 -1
- package/build/src/JoinRows.js +12 -0
- package/build/src/JoinRows.js.map +1 -1
- package/build/src/QueryParser.d.ts +11 -0
- package/build/src/QueryParser.d.ts.map +1 -1
- package/build/src/QueryParser.js +11 -3
- package/build/src/QueryParser.js.map +1 -1
- package/build/src/ReactionsManager.d.ts +24 -0
- package/build/src/ReactionsManager.d.ts.map +1 -1
- package/build/src/ReactionsManager.js +58 -11
- package/build/src/ReactionsManager.js.map +1 -1
- package/build/src/dataloaders/loadDataLoader.d.ts +5 -1
- package/build/src/dataloaders/loadDataLoader.d.ts.map +1 -1
- package/build/src/dataloaders/loadDataLoader.js +30 -21
- package/build/src/dataloaders/loadDataLoader.js.map +1 -1
- package/build/src/dataloaders/populateDataLoader.d.ts +12 -0
- package/build/src/dataloaders/populateDataLoader.d.ts.map +1 -0
- package/build/src/dataloaders/populateDataLoader.js +107 -0
- package/build/src/dataloaders/populateDataLoader.js.map +1 -0
- package/build/src/drivers/buildKnexQuery.d.ts.map +1 -1
- package/build/src/drivers/buildKnexQuery.js +3 -0
- package/build/src/drivers/buildKnexQuery.js.map +1 -1
- package/build/src/index.d.ts +16 -10
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +23 -10
- package/build/src/index.js.map +1 -1
- package/build/src/keywords.d.ts +1 -0
- package/build/src/keywords.d.ts.map +1 -1
- package/build/src/keywords.js +6 -1
- package/build/src/keywords.js.map +1 -1
- package/build/src/newTestInstance.d.ts +1 -0
- package/build/src/newTestInstance.d.ts.map +1 -1
- package/build/src/newTestInstance.js +2 -1
- package/build/src/newTestInstance.js.map +1 -1
- package/build/src/normalizeHints.d.ts +2 -0
- package/build/src/normalizeHints.d.ts.map +1 -1
- package/build/src/normalizeHints.js +14 -1
- package/build/src/normalizeHints.js.map +1 -1
- package/build/src/plugins/PreloadPlugin.d.ts +46 -0
- package/build/src/plugins/PreloadPlugin.d.ts.map +1 -0
- package/build/src/plugins/PreloadPlugin.js +3 -0
- package/build/src/plugins/PreloadPlugin.js.map +1 -0
- package/build/src/relations/CustomCollection.d.ts.map +1 -1
- package/build/src/relations/CustomCollection.js.map +1 -1
- package/build/src/relations/CustomReference.d.ts.map +1 -1
- package/build/src/relations/CustomReference.js.map +1 -1
- package/build/src/relations/ManyToManyCollection.d.ts +3 -0
- package/build/src/relations/ManyToManyCollection.d.ts.map +1 -1
- package/build/src/relations/ManyToManyCollection.js +15 -7
- package/build/src/relations/ManyToManyCollection.js.map +1 -1
- package/build/src/relations/ManyToOneReference.d.ts +3 -1
- package/build/src/relations/ManyToOneReference.d.ts.map +1 -1
- package/build/src/relations/ManyToOneReference.js +35 -8
- package/build/src/relations/ManyToOneReference.js.map +1 -1
- package/build/src/relations/OneToManyCollection.d.ts +3 -0
- package/build/src/relations/OneToManyCollection.d.ts.map +1 -1
- package/build/src/relations/OneToManyCollection.js +41 -15
- package/build/src/relations/OneToManyCollection.js.map +1 -1
- package/build/src/relations/OneToOneReference.d.ts +3 -0
- package/build/src/relations/OneToOneReference.d.ts.map +1 -1
- package/build/src/relations/OneToOneReference.js +17 -2
- package/build/src/relations/OneToOneReference.js.map +1 -1
- package/build/src/relations/hasPersistedAsyncProperty.d.ts.map +1 -1
- package/build/src/relations/hasPersistedAsyncProperty.js +1 -4
- package/build/src/relations/hasPersistedAsyncProperty.js.map +1 -1
- package/build/src/serde.d.ts +14 -0
- package/build/src/serde.d.ts.map +1 -1
- package/build/src/serde.js +38 -0
- package/build/src/serde.js.map +1 -1
- package/build/src/utils.d.ts +5 -2
- package/build/src/utils.d.ts.map +1 -1
- package/build/src/utils.js +16 -1
- package/build/src/utils.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -13,6 +13,16 @@ const reactiveHints_1 = require("./reactiveHints");
|
|
|
13
13
|
class ReactionsManager {
|
|
14
14
|
/** Stores all source `ReactiveField`s that have been marked for later traversal. */
|
|
15
15
|
pendingFieldReactions = new Map();
|
|
16
|
+
/**
|
|
17
|
+
* A map of entity tagName -> fields that have been marked as dirty.
|
|
18
|
+
*
|
|
19
|
+
* The key of the map is "just" the tag name, instead of a specific entity, b/c at the time of
|
|
20
|
+
* being marked dirty, we only have the upstream/source entity + fieldName that has changed, and
|
|
21
|
+
* not the 1-or-more downstream/target entities that will actually recalc.
|
|
22
|
+
*
|
|
23
|
+
* Instead, we just track the dirty fields by type-of-entity, which is enough for `isPendingRecalc`.
|
|
24
|
+
*/
|
|
25
|
+
dirtyFields = new Map();
|
|
16
26
|
/**
|
|
17
27
|
* Queue all downstream reactive fields that depend on `fieldName` as a source field.
|
|
18
28
|
*
|
|
@@ -33,7 +43,8 @@ class ReactionsManager {
|
|
|
33
43
|
// - if we skip re-queuing firstName's RFs, we will miss that initials needs
|
|
34
44
|
// its `.load()` called again so that it's `setField` marks `initials` as
|
|
35
45
|
// dirty, otherwise it will be left out of any INSERTs/UPDATEs.
|
|
36
|
-
this.getPending(rf).add(entity);
|
|
46
|
+
this.getPending(rf).todo.add(entity);
|
|
47
|
+
this.getDirtyFields((0, EntityMetadata_1.getMetadata)(rf.cstr)).add(rf.name);
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
}
|
|
@@ -44,12 +55,22 @@ class ReactionsManager {
|
|
|
44
55
|
for (const rf of rfs) {
|
|
45
56
|
if (rf.fields.includes(fieldName)) {
|
|
46
57
|
const pending = this.getPending(rf);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
if (pending.done.has(entity)) {
|
|
59
|
+
// Ironically, if we've already run this RF, asking to dequeue probably means
|
|
60
|
+
// we need run it again (to recalc its value), b/c this could be a mid-flush change, i.e.:
|
|
61
|
+
// - firstName = a1 from db
|
|
62
|
+
// - firstName is changed to a2, triggers initials RF
|
|
63
|
+
// - firstName is changed back to a1, which is the original value, so setField
|
|
64
|
+
// thinks we can dequeue the RF
|
|
65
|
+
// - but actually our RF needs to be re-run with the restored value
|
|
66
|
+
pending.todo.add(entity);
|
|
67
|
+
}
|
|
68
|
+
else if (rf.fields.length === 1) {
|
|
69
|
+
// We can only delete/dequeue a reaction if `fieldName` is the only or last field
|
|
70
|
+
// that had triggered `rf` to run. Since we don't track that currently, i.e. we'd
|
|
71
|
+
// need to have a `Pending.dirtyFields`, for now just only dequeue if `rf` only
|
|
72
|
+
// has one field (which is us) anyway.
|
|
73
|
+
pending.todo.delete(entity);
|
|
53
74
|
}
|
|
54
75
|
}
|
|
55
76
|
}
|
|
@@ -58,9 +79,25 @@ class ReactionsManager {
|
|
|
58
79
|
queueAllDownstreamFields(entity) {
|
|
59
80
|
const rfs = (0, EntityMetadata_1.getAllMetas)((0, EntityMetadata_1.getMetadata)(entity)).flatMap((m) => m.config.__data.reactiveDerivedValues);
|
|
60
81
|
for (const rf of rfs) {
|
|
61
|
-
this.getPending(rf).add(entity);
|
|
82
|
+
this.getPending(rf).todo.add(entity);
|
|
83
|
+
this.getDirtyFields((0, EntityMetadata_1.getMetadata)(rf.cstr)).add(rf.name);
|
|
62
84
|
}
|
|
63
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns whether this field might be pending recalc.
|
|
88
|
+
*
|
|
89
|
+
* This is technically a guess, b/c our reaction infra may not yet have crawled up an upstream
|
|
90
|
+
* source field down to the `N` specific target entities that need recalced, and instead just
|
|
91
|
+
* knows "it will need to do that soon" i.e. at the next `em.flush`.
|
|
92
|
+
*
|
|
93
|
+
* So, instead this is a heuristic that says this `fieldName` has been marked dirty for _some_
|
|
94
|
+
* entities, but we don't technically know if it's _this_ entity.
|
|
95
|
+
*
|
|
96
|
+
* I.e. this might return false positives, but should never return false negatives.
|
|
97
|
+
*/
|
|
98
|
+
isMaybePendingRecalc(entity, fieldName) {
|
|
99
|
+
return this.getDirtyFields((0, EntityMetadata_1.getMetadata)(entity)).has(fieldName);
|
|
100
|
+
}
|
|
64
101
|
/**
|
|
65
102
|
* Given source `ReactiveField` "reverse indexes" that have been queued as dirty by calls
|
|
66
103
|
* to setters, `em.register`, or `em.delete`, asynchronously walks/crawls to the downstream
|
|
@@ -75,13 +112,15 @@ class ReactionsManager {
|
|
|
75
112
|
scanPending = false;
|
|
76
113
|
const relations = await Promise.all([...this.pendingFieldReactions.entries()].map(async ([rf, pending]) => {
|
|
77
114
|
// Copy pending and clear it
|
|
78
|
-
const todo = [...pending];
|
|
79
|
-
pending.clear();
|
|
115
|
+
const todo = [...pending.todo];
|
|
116
|
+
pending.todo.clear();
|
|
80
117
|
// If we found any pending, loop again b/c we might be a dependency of another field,
|
|
81
118
|
// which our `.load()` will have marked as pending by calling `queueDownstreamReactiveFields`.
|
|
82
119
|
if (todo.length > 0) {
|
|
83
120
|
scanPending = true;
|
|
84
121
|
}
|
|
122
|
+
for (const doing of todo)
|
|
123
|
+
pending.done.add(doing);
|
|
85
124
|
// Walk back from the source to any downstream fields
|
|
86
125
|
return (await (0, reactiveHints_1.followReverseHint)(todo, rf.path))
|
|
87
126
|
.filter((entity) => !entity.isDeletedEntity)
|
|
@@ -107,11 +146,19 @@ class ReactionsManager {
|
|
|
107
146
|
getPending(rf) {
|
|
108
147
|
let pending = this.pendingFieldReactions.get(rf);
|
|
109
148
|
if (!pending) {
|
|
110
|
-
pending = new Set();
|
|
149
|
+
pending = { todo: new Set(), done: new Set() };
|
|
111
150
|
this.pendingFieldReactions.set(rf, pending);
|
|
112
151
|
}
|
|
113
152
|
return pending;
|
|
114
153
|
}
|
|
154
|
+
getDirtyFields(meta) {
|
|
155
|
+
let dirty = this.dirtyFields.get(meta.tagName);
|
|
156
|
+
if (!dirty) {
|
|
157
|
+
dirty = new Set();
|
|
158
|
+
this.dirtyFields.set(meta.tagName, dirty);
|
|
159
|
+
}
|
|
160
|
+
return dirty;
|
|
161
|
+
}
|
|
115
162
|
}
|
|
116
163
|
exports.ReactionsManager = ReactionsManager;
|
|
117
164
|
//# sourceMappingURL=ReactionsManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactionsManager.js","sourceRoot":"","sources":["../../src/ReactionsManager.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"ReactionsManager.js","sourceRoot":"","sources":["../../src/ReactionsManager.ts"],"names":[],"mappings":";;;AAEA,qDAA4E;AAC5E,mDAAoD;AAEpD;;;;;;GAMG;AACH,MAAa,gBAAgB;IAC3B,oFAAoF;IAC5E,qBAAqB,GAAiE,IAAI,GAAG,EAAE,CAAC;IACxG;;;;;;;;OAQG;IACK,WAAW,GAA6B,IAAI,GAAG,EAAE,CAAC;IAE1D;;;;;;OAMG;IACH,6BAA6B,CAAC,MAAc,EAAE,SAAiB;QAC7D,yEAAyE;QACzE,MAAM,GAAG,GAAG,IAAA,4BAAW,EAAC,IAAA,4BAAW,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACnG,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE;YACpB,IAA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AC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;YAC/C,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;SAC7C;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,cAAc,CAAC,IAAyB;QAC9C,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;YAClB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA7JD,4CA6JC"}
|
|
@@ -2,5 +2,9 @@ import DataLoader from "dataloader";
|
|
|
2
2
|
import { Entity } from "../Entity";
|
|
3
3
|
import { EntityManager } from "../EntityManager";
|
|
4
4
|
import { EntityMetadata } from "../EntityMetadata";
|
|
5
|
-
|
|
5
|
+
import { LoadHint } from "../loadHints";
|
|
6
|
+
export declare function loadDataLoader<T extends Entity>(em: EntityManager, meta: EntityMetadata<T>): DataLoader<{
|
|
7
|
+
entity: string;
|
|
8
|
+
hint: LoadHint<T> | undefined;
|
|
9
|
+
}, T | undefined>;
|
|
6
10
|
//# sourceMappingURL=loadDataLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDataLoader.d.ts","sourceRoot":"","sources":["../../../src/dataloaders/loadDataLoader.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"loadDataLoader.d.ts","sourceRoot":"","sources":["../../../src/dataloaders/loadDataLoader.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,EAAE,EAAE,aAAa,EACjB,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GACtB,UAAU,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;CAAE,EAAE,CAAC,GAAG,SAAS,CAAC,CA0C9E"}
|
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadDataLoader = void 0;
|
|
4
|
+
const EntityManager_1 = require("../EntityManager");
|
|
5
|
+
const HintTree_1 = require("../HintTree");
|
|
4
6
|
const QueryBuilder_1 = require("../QueryBuilder");
|
|
5
7
|
const QueryParser_1 = require("../QueryParser");
|
|
6
8
|
const keys_1 = require("../keys");
|
|
7
9
|
const utils_1 = require("../utils");
|
|
8
10
|
function loadDataLoader(em, meta) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
// Batch different populate hints together and defer to the hint tree to do the right thing
|
|
12
|
+
return em.getLoader("load", meta.type, async (loads) => {
|
|
13
|
+
let entities;
|
|
14
|
+
const { preloader } = (0, EntityManager_1.getEmInternalApi)(em);
|
|
15
|
+
if (preloader) {
|
|
16
|
+
const rootTree = (0, HintTree_1.buildHintTree)(loads);
|
|
17
|
+
entities = await preloader.preloadLoad(em, meta, rootTree);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const keys = loads.map((l) => (0, keys_1.keyToNumber)(meta, l.entity));
|
|
21
|
+
const alias = (0, QueryBuilder_1.abbreviation)(meta.tableName);
|
|
22
|
+
const query = {
|
|
23
|
+
selects: [`"${alias}".*`],
|
|
24
|
+
tables: [{ alias, join: "primary", table: meta.tableName }],
|
|
25
|
+
conditions: [{ alias, column: "id", dbType: meta.idType, cond: { kind: "in", value: keys } }],
|
|
26
|
+
orderBys: [{ alias, column: "id", order: "ASC" }],
|
|
27
|
+
};
|
|
28
|
+
(0, QueryParser_1.addTablePerClassJoinsAndClassTag)(query, meta, alias, true);
|
|
29
|
+
// Skip maybeAddOrderBy?
|
|
30
|
+
// maybeAddNotSoftDeleted(conditions, meta, alias, "include");
|
|
31
|
+
const rows = await em.driver.executeFind(em, query, {});
|
|
32
|
+
// Pass overwriteExisting (which is the default anyway) because it might be EntityManager.refresh calling us.
|
|
33
|
+
entities = rows.map((row) => em.hydrate(meta.cstr, row, { overwriteExisting: true }));
|
|
34
|
+
}
|
|
27
35
|
// Return the results back in the same order as the keys
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const entitiesById = (0, utils_1.indexBy)(entities, (e) => e.idTagged);
|
|
37
|
+
return loads.map(({ entity: id }) => {
|
|
38
|
+
const entity = entitiesById.get(id);
|
|
30
39
|
// We generally expect all of our entities to be found, but they may not for API calls like
|
|
31
40
|
// `findOneOrFail` or for `EntityManager.refresh` when the entity has been deleted out from
|
|
32
41
|
// under us.
|
|
33
42
|
if (entity === undefined) {
|
|
34
|
-
const existingEntity = em.findExistingInstance(
|
|
43
|
+
const existingEntity = em.findExistingInstance(id);
|
|
35
44
|
if (existingEntity) {
|
|
36
45
|
existingEntity.__orm.deleted = "deleted";
|
|
37
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDataLoader.js","sourceRoot":"","sources":["../../../src/dataloaders/loadDataLoader.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"loadDataLoader.js","sourceRoot":"","sources":["../../../src/dataloaders/loadDataLoader.ts"],"names":[],"mappings":";;;AAEA,oDAAmE;AAEnE,0CAA4C;AAC5C,kDAA+C;AAC/C,gDAAmF;AACnF,kCAAsC;AAEtC,oCAAmC;AAEnC,SAAgB,cAAc,CAC5B,EAAiB,EACjB,IAAuB;IAEvB,2FAA2F;IAC3F,OAAO,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrD,IAAI,QAAa,CAAC;QAElB,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,gCAAgB,EAAC,EAAE,CAAC,CAAC;QAC3C,IAAI,SAAS,EAAE;YACb,MAAM,QAAQ,GAAG,IAAA,wBAAa,EAAS,KAAK,CAAC,CAAC;YAC9C,QAAQ,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;SAC5D;aAAM;YACL,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,kBAAW,EAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3D,MAAM,KAAK,GAAG,IAAA,2BAAY,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3C,MAAM,KAAK,GAAoB;gBAC7B,OAAO,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC;gBACzB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CA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,GAAG,SAAS,CAAC;iBAC1C;aACF;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA7CD,wCA6CC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { Entity } from "../Entity";
|
|
3
|
+
import { EntityMetadata } from "../EntityMetadata";
|
|
4
|
+
import { EntityManager } from "../index";
|
|
5
|
+
import { LoadHint } from "../loadHints";
|
|
6
|
+
export declare function populateDataLoader(em: EntityManager, meta: EntityMetadata<any>, hint: LoadHint<any>, mode: "preload" | "intermixed", opts?: {
|
|
7
|
+
forceReload?: boolean;
|
|
8
|
+
}): DataLoader<{
|
|
9
|
+
entity: Entity;
|
|
10
|
+
hint: LoadHint<any>;
|
|
11
|
+
}, any>;
|
|
12
|
+
//# sourceMappingURL=populateDataLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populateDataLoader.d.ts","sourceRoot":"","sources":["../../../src/dataloaders/populateDataLoader.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,cAAc,EAAS,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAgE,MAAM,UAAU,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAKxD,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,aAAa,EACjB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,EACzB,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,EACnB,IAAI,EAAE,SAAS,GAAG,YAAY,EAC9B,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,UAAU,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;CAAE,EAAE,GAAG,CAAC,CAiH1D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.populateDataLoader = void 0;
|
|
4
|
+
const HintTree_1 = require("../HintTree");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const hasPersistedAsyncProperty_1 = require("../relations/hasPersistedAsyncProperty");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
function populateDataLoader(em, meta, hint, mode, opts = {}) {
|
|
9
|
+
// For batching populates, we want different levels of course-ness:
|
|
10
|
+
// - preloading populates that are only SQL should be batched together as much as possible, but
|
|
11
|
+
// - intermixed populates (some with custom relations) should be batched as separately as possible
|
|
12
|
+
// (while still batching identical populates together) to reduce the chance of promise deadlocks.
|
|
13
|
+
//
|
|
14
|
+
// I.e. if we know this is a sql-only hint, we can batch all loads for a given entity
|
|
15
|
+
// together do leverage join-based preloading.
|
|
16
|
+
//
|
|
17
|
+
// However, intermixed batches can be prone to promise deadlocking (one relation .load getting
|
|
18
|
+
// stuck in a batch that is asking for its own dependencies to load), so if this is an intermixed
|
|
19
|
+
// hint, then use a batch key that includes the hint itself, which will make it unlikely
|
|
20
|
+
// for non-sql relations to deadlock on each other/themselves.
|
|
21
|
+
const batchKey = mode === "preload"
|
|
22
|
+
? `${meta.tagName}:${opts.forceReload}`
|
|
23
|
+
: `${meta.tagName}:${JSON.stringify(hint)}:${opts.forceReload}`;
|
|
24
|
+
return em.getLoader("populate", batchKey, async (populates) => {
|
|
25
|
+
async function populateLayer(layerMeta, layerNode) {
|
|
26
|
+
// Skip join-based preloading if nothing in this layer needs loading. If any entity in the list
|
|
27
|
+
// needs loading, just load everything
|
|
28
|
+
const { preloader } = (0, index_1.getEmInternalApi)(em);
|
|
29
|
+
// We may not have a layerMeta if we're going through non-field properties
|
|
30
|
+
if (preloader && layerMeta) {
|
|
31
|
+
const preloadThisLayer = Object.entries(layerNode.subHints).some(([key, hint]) => {
|
|
32
|
+
return [...hint.entities].some((entity) => !!entity[key] && !entity[key].isLoaded && !entity[key].isPreloaded);
|
|
33
|
+
});
|
|
34
|
+
if (preloadThisLayer) {
|
|
35
|
+
await preloader.preloadPopulate(em, layerMeta, layerNode);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// One breadth-width pass (only 1 level deep, our 2nd pass recurses) to ensure each relation is loaded
|
|
39
|
+
const loadPromises = Object.entries(layerNode.subHints).flatMap(([key, tree]) => {
|
|
40
|
+
return [...tree.entities].map((entity) => {
|
|
41
|
+
const relation = entity[key];
|
|
42
|
+
if (!relation || typeof relation.load !== "function") {
|
|
43
|
+
throw new Error(`Invalid load hint '${key}' on ${entity}`);
|
|
44
|
+
}
|
|
45
|
+
// If we're populating a hasPersistedAsyncProperty, don't bother loading it
|
|
46
|
+
// if it's already been calculated (i.e. we have no reason to believe its value
|
|
47
|
+
// is stale, so we should avoid pulling all of its data into memory).
|
|
48
|
+
// _Unless_ the ReactionsManager has noticed a change that might have invalidated it.
|
|
49
|
+
if ((relation instanceof hasPersistedAsyncProperty_1.PersistedAsyncPropertyImpl || relation instanceof index_1.PersistedAsyncReferenceImpl) &&
|
|
50
|
+
relation.isSet &&
|
|
51
|
+
!(0, index_1.getEmInternalApi)(em).rm.isMaybePendingRecalc(entity, key))
|
|
52
|
+
return;
|
|
53
|
+
if (relation.isLoaded && !opts.forceReload)
|
|
54
|
+
return undefined;
|
|
55
|
+
// Avoid creating a promise for preloaded relations
|
|
56
|
+
if (relation.isPreloaded) {
|
|
57
|
+
relation.preload();
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return relation.load(opts);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
// 2nd breadth-width pass to do nested load hints, this will fan out at the sibling level.
|
|
64
|
+
// i.e. populateLayer(...reviews...) & populateLayer(...comments...)
|
|
65
|
+
return Promise.all(loadPromises).then(() => {
|
|
66
|
+
// Each of these keys will be fanning out to a new entity, like book -> reviews or book -> comments
|
|
67
|
+
const nestedLoadPromises = Object.entries(layerNode.subHints).map(([key, tree]) => {
|
|
68
|
+
if (Object.keys(tree.subHints).length === 0)
|
|
69
|
+
return;
|
|
70
|
+
// Get the children we found, i.e. [a1, a2, a3] -> all of their books
|
|
71
|
+
const childrenByParent = new Map([...tree.entities].map((entity) => [entity, (0, utils_1.toArray)(getEvenDeleted(entity[key]))]));
|
|
72
|
+
if (childrenByParent.size === 0)
|
|
73
|
+
return;
|
|
74
|
+
// Rewrite our node.entities to be the next layer of children, i.e. children will be all books, for all of
|
|
75
|
+
// `[a1, a2, a3]`, but only the books of `a2` need to recurse into `book: reviews` and only the books of
|
|
76
|
+
// `a3` need to recurse into `book: comments`, so swap `node.entities` (which is currently authors)
|
|
77
|
+
// with the books. This is what prevents our dataloader-merged TreeHint from over-fetching and loading
|
|
78
|
+
// the superset load hint for all entities.
|
|
79
|
+
function rewrite(node) {
|
|
80
|
+
node.entities = new Set(Array.from(node.entities).flatMap((entity) => childrenByParent.get(entity) ?? []));
|
|
81
|
+
Object.values(node.subHints).forEach((node) => rewrite(node));
|
|
82
|
+
}
|
|
83
|
+
rewrite(tree);
|
|
84
|
+
const nextMeta = layerMeta?.allFields[key]?.otherMetadata?.();
|
|
85
|
+
return populateLayer(nextMeta, tree);
|
|
86
|
+
});
|
|
87
|
+
return Promise.all(nestedLoadPromises);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return populateLayer(meta, (0, HintTree_1.buildHintTree)(populates)).then(() => populates);
|
|
91
|
+
},
|
|
92
|
+
// We always disable caching, because during a UoW, having called `populate(author, nestedHint1)`
|
|
93
|
+
// once doesn't mean that, on the 2nd call to `populate(author, nestedHint1)`, we can completely
|
|
94
|
+
// skip it b/c author's relations may have been changed/mutated to different not-yet-loaded
|
|
95
|
+
// entities.
|
|
96
|
+
//
|
|
97
|
+
// Even though having `{ cache: false }` looks weird here, i.e. why use dataloader at all?, it
|
|
98
|
+
// still helps us fan-in resolvers callers that are happening ~simultaneously into the same
|
|
99
|
+
// effort.
|
|
100
|
+
{ cache: false });
|
|
101
|
+
}
|
|
102
|
+
exports.populateDataLoader = populateDataLoader;
|
|
103
|
+
/** Probes `relation` to see if it's a m2o/o2m/m2m relation that supports `getWithDeleted`, otherwise calls `get`. */
|
|
104
|
+
function getEvenDeleted(relation) {
|
|
105
|
+
return "getWithDeleted" in relation ? relation.getWithDeleted : relation.get;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=populateDataLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populateDataLoader.js","sourceRoot":"","sources":["../../../src/dataloaders/populateDataLoader.ts"],"names":[],"mappings":";;;AAGA,0CAAsD;AACtD,oCAAuG;AAGvG,sFAAoF;AACpF,oCAAmC;AAEnC,SAAgB,kBAAkB,CAChC,EAAiB,EACjB,IAAyB,EACzB,IAAmB,EACnB,IAA8B,EAC9B,OAAkC,EAAE;IAEpC,mEAAmE;IACnE,+FAA+F;IAC/F,kGAAkG;IAClG,mGAAmG;IACnG,EAAE;IACF,qFAAqF;IACrF,8CAA8C;IAC9C,EAAE;IACF,8FAA8F;IAC9F,iGAAiG;IACjG,wFAAwF;IACxF,8DAA8D;IAC9D,MAAM,QAAQ,GACZ,IAAI,KAAK,SAAS;QAChB,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;QACvC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;IACpE,OAAO,EAAE,CAAC,SAAS,CACjB,UAAU,EACV,QAAQ,EACR,KAAK,EAAE,SAAS,EAAE,EAAE;QAClB,KAAK,UAAU,aAAa,CAC1B,SAA0C,EAC1C,SAA2B;YAE3B,+FAA+F;YAC/F,sCAAsC;YACtC,MAAM,EAAE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|
|
1
|
-
{"version":3,"file":"buildKnexQuery.d.ts","sourceRoot":"","sources":["../../../src/drivers/buildKnexQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAA2C,eAAe,EAAe,MAAM,gBAAgB,CAAC;AAGvG,OAAO,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;AAExC;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"buildKnexQuery.d.ts","sourceRoot":"","sources":["../../../src/drivers/buildKnexQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAA2C,eAAe,EAAe,MAAM,gBAAgB,CAAC;AAGvG,OAAO,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;AAExC;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CA+D7B"}
|
|
@@ -40,6 +40,9 @@ function buildKnexQuery(knex, parsed, settings) {
|
|
|
40
40
|
(0, utils_1.assertNever)(t);
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
if (parsed.lateralJoins) {
|
|
44
|
+
query.joinRaw(parsed.lateralJoins.joins.join("\n"), parsed.lateralJoins.bindings);
|
|
45
|
+
}
|
|
43
46
|
parsed.conditions.forEach((c) => {
|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AAK,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACtC,MAAM;QACR,KAAK,KAAK;YACR,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACzC,MAAM;QACR,KAAK,SAAS;YACZ,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC9B,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YACnC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YACnC,MAAM;QACR;YACE,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;KACrB;AACH,CAAC"}
|
package/build/src/index.d.ts
CHANGED
|
@@ -8,31 +8,36 @@ export declare const testing: {
|
|
|
8
8
|
isAllSqlPaths: typeof isAllSqlPaths;
|
|
9
9
|
};
|
|
10
10
|
export { newPgConnectionConfig } from "joist-utils";
|
|
11
|
+
export { AliasAssigner } from "./AliasAssigner";
|
|
11
12
|
export * from "./Aliases";
|
|
12
13
|
export { BaseEntity } from "./BaseEntity";
|
|
13
|
-
export * from "./changes";
|
|
14
|
-
export { ConfigApi, EntityHook } from "./config";
|
|
15
|
-
export { DeepPartialOrNull } from "./createOrUpdatePartial";
|
|
16
|
-
export * from "./drivers";
|
|
17
14
|
export { Entity, EntityOrmField, isEntity } from "./Entity";
|
|
18
15
|
export * from "./EntityFilter";
|
|
19
16
|
export * from "./EntityGraphQLFilter";
|
|
20
17
|
export * from "./EntityManager";
|
|
21
18
|
export * from "./EntityMetadata";
|
|
22
19
|
export { EnumMetadata } from "./EnumMetadata";
|
|
20
|
+
export { EntityOrId, HintNode } from "./HintTree";
|
|
21
|
+
export * from "./QueryBuilder";
|
|
22
|
+
export * from "./QueryParser";
|
|
23
|
+
export * from "./changes";
|
|
24
|
+
export { ConfigApi, EntityHook } from "./config";
|
|
25
|
+
export { DeepPartialOrNull } from "./createOrUpdatePartial";
|
|
26
|
+
export * from "./drivers";
|
|
23
27
|
export * from "./getProperties";
|
|
24
28
|
export * from "./keys";
|
|
25
|
-
export {
|
|
29
|
+
export { kq, kqDot, kqStar } from "./keywords";
|
|
30
|
+
export { DeepNew, LoadHint, Loadable, Loaded, MarkLoaded, NestedLoadHint, New, RelationsIn, assertLoaded, ensureLoaded, isLoaded, isNew, maybePopulateThen, } from "./loadHints";
|
|
26
31
|
export * from "./loadLens";
|
|
27
32
|
export * from "./newTestInstance";
|
|
28
|
-
export
|
|
29
|
-
export
|
|
33
|
+
export { deepNormalizeHint, normalizeHint } from "./normalizeHints";
|
|
34
|
+
export { PreloadPlugin } from "./plugins/PreloadPlugin";
|
|
30
35
|
export { Reactable, Reacted, ReactiveHint, reverseReactiveHint } from "./reactiveHints";
|
|
31
36
|
export * from "./relations";
|
|
32
|
-
export {
|
|
37
|
+
export { GenericError, ValidationError, ValidationErrors, ValidationRule, ValidationRuleResult, cannotBeUpdated, maxValueRule, minValueRule, newRequiredRule, rangeValueRule, } from "./rules";
|
|
33
38
|
export * from "./serde";
|
|
34
|
-
export { asNew, cleanStringValue, fail } from "./utils";
|
|
35
|
-
export { ensureWithLoaded, withLoaded
|
|
39
|
+
export { asNew, assertNever, cleanStringValue, fail, indexBy } from "./utils";
|
|
40
|
+
export { WithLoaded, ensureWithLoaded, withLoaded } from "./withLoaded";
|
|
36
41
|
interface Flavoring<FlavorT> {
|
|
37
42
|
_type?: FlavorT;
|
|
38
43
|
}
|
|
@@ -67,6 +72,7 @@ export declare function getRequiredKeys<T extends Entity>(type: EntityConstructo
|
|
|
67
72
|
export declare function configureMetadata(metas: EntityMetadata<any>[]): void;
|
|
68
73
|
export declare function getEm(entity: Entity): EntityManager<any>;
|
|
69
74
|
export declare function getRelations(entity: Entity): AbstractRelationImpl<any>[];
|
|
75
|
+
export declare function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any>][];
|
|
70
76
|
export declare function getConstructorFromTaggedId(id: string): MaybeAbstractEntityConstructor<any>;
|
|
71
77
|
export declare function maybeGetConstructorFromReference(value: string | Entity | Reference<any, any, any> | undefined): MaybeAbstractEntityConstructor<any> | undefined;
|
|
72
78
|
/** Casts a "maybe abstract" cstr to a concrete cstr when the calling code knows it's safe. */
|
package/build/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAY,MAAM,UAAU,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAY,MAAM,UAAU,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAA4B,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAKxE,eAAO,MAAM,OAAO;;CAAoB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC5D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,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,CAAC,EAAE,GAAG,IAAI,CA6FpE;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAExD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAExE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,CAExF;AAED,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM,GAAG,8BAA8B,CAAC,GAAG,CAAC,CAG1F;AAED,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,GAC5D,8BAA8B,CAAC,GAAG,CAAC,GAAG,SAAS,CAGjD;AAeD,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,8BAA8B,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAE9G"}
|
package/build/src/index.js
CHANGED
|
@@ -14,14 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.asConcreteCstr = exports.maybeGetConstructorFromReference = exports.getConstructorFromTaggedId = exports.getRelations = exports.getEm = exports.configureMetadata = exports.getRequiredKeys = exports.ensureNotDeleted = exports.setOpts = exports.setField = exports.withLoaded = exports.ensureWithLoaded = exports.fail = exports.cleanStringValue = exports.
|
|
17
|
+
exports.asConcreteCstr = exports.maybeGetConstructorFromReference = exports.getConstructorFromTaggedId = exports.getRelationEntries = exports.getRelations = exports.getEm = exports.configureMetadata = exports.getRequiredKeys = exports.ensureNotDeleted = exports.setOpts = exports.setField = exports.withLoaded = exports.ensureWithLoaded = exports.indexBy = exports.fail = exports.cleanStringValue = exports.assertNever = exports.asNew = exports.rangeValueRule = exports.newRequiredRule = exports.minValueRule = exports.maxValueRule = exports.cannotBeUpdated = exports.ValidationErrors = exports.reverseReactiveHint = exports.normalizeHint = exports.deepNormalizeHint = exports.maybePopulateThen = exports.isNew = exports.isLoaded = exports.ensureLoaded = exports.assertLoaded = exports.kqStar = exports.kqDot = exports.kq = exports.ConfigApi = exports.isEntity = exports.EntityOrmField = exports.BaseEntity = exports.AliasAssigner = exports.newPgConnectionConfig = exports.testing = void 0;
|
|
18
18
|
const Entity_1 = require("./Entity");
|
|
19
19
|
const EntityManager_1 = require("./EntityManager");
|
|
20
20
|
const EntityMetadata_1 = require("./EntityMetadata");
|
|
21
21
|
const getProperties_1 = require("./getProperties");
|
|
22
22
|
const keys_1 = require("./keys");
|
|
23
23
|
const loadLens_1 = require("./loadLens");
|
|
24
|
-
const QueryBuilder_1 = require("./QueryBuilder");
|
|
25
24
|
const reactiveHints_1 = require("./reactiveHints");
|
|
26
25
|
const AbstractRelationImpl_1 = require("./relations/AbstractRelationImpl");
|
|
27
26
|
const rules_1 = require("./rules");
|
|
@@ -29,13 +28,11 @@ const utils_1 = require("./utils");
|
|
|
29
28
|
exports.testing = { isAllSqlPaths: loadLens_1.isAllSqlPaths };
|
|
30
29
|
var joist_utils_1 = require("joist-utils");
|
|
31
30
|
Object.defineProperty(exports, "newPgConnectionConfig", { enumerable: true, get: function () { return joist_utils_1.newPgConnectionConfig; } });
|
|
31
|
+
var AliasAssigner_1 = require("./AliasAssigner");
|
|
32
|
+
Object.defineProperty(exports, "AliasAssigner", { enumerable: true, get: function () { return AliasAssigner_1.AliasAssigner; } });
|
|
32
33
|
__exportStar(require("./Aliases"), exports);
|
|
33
34
|
var BaseEntity_1 = require("./BaseEntity");
|
|
34
35
|
Object.defineProperty(exports, "BaseEntity", { enumerable: true, get: function () { return BaseEntity_1.BaseEntity; } });
|
|
35
|
-
__exportStar(require("./changes"), exports);
|
|
36
|
-
var config_1 = require("./config");
|
|
37
|
-
Object.defineProperty(exports, "ConfigApi", { enumerable: true, get: function () { return config_1.ConfigApi; } });
|
|
38
|
-
__exportStar(require("./drivers"), exports);
|
|
39
36
|
var Entity_2 = require("./Entity");
|
|
40
37
|
Object.defineProperty(exports, "EntityOrmField", { enumerable: true, get: function () { return Entity_2.EntityOrmField; } });
|
|
41
38
|
Object.defineProperty(exports, "isEntity", { enumerable: true, get: function () { return Entity_2.isEntity; } });
|
|
@@ -43,8 +40,18 @@ __exportStar(require("./EntityFilter"), exports);
|
|
|
43
40
|
__exportStar(require("./EntityGraphQLFilter"), exports);
|
|
44
41
|
__exportStar(require("./EntityManager"), exports);
|
|
45
42
|
__exportStar(require("./EntityMetadata"), exports);
|
|
43
|
+
__exportStar(require("./QueryBuilder"), exports);
|
|
44
|
+
__exportStar(require("./QueryParser"), exports);
|
|
45
|
+
__exportStar(require("./changes"), exports);
|
|
46
|
+
var config_1 = require("./config");
|
|
47
|
+
Object.defineProperty(exports, "ConfigApi", { enumerable: true, get: function () { return config_1.ConfigApi; } });
|
|
48
|
+
__exportStar(require("./drivers"), exports);
|
|
46
49
|
__exportStar(require("./getProperties"), exports);
|
|
47
50
|
__exportStar(require("./keys"), exports);
|
|
51
|
+
var keywords_1 = require("./keywords");
|
|
52
|
+
Object.defineProperty(exports, "kq", { enumerable: true, get: function () { return keywords_1.kq; } });
|
|
53
|
+
Object.defineProperty(exports, "kqDot", { enumerable: true, get: function () { return keywords_1.kqDot; } });
|
|
54
|
+
Object.defineProperty(exports, "kqStar", { enumerable: true, get: function () { return keywords_1.kqStar; } });
|
|
48
55
|
var loadHints_1 = require("./loadHints");
|
|
49
56
|
Object.defineProperty(exports, "assertLoaded", { enumerable: true, get: function () { return loadHints_1.assertLoaded; } });
|
|
50
57
|
Object.defineProperty(exports, "ensureLoaded", { enumerable: true, get: function () { return loadHints_1.ensureLoaded; } });
|
|
@@ -53,23 +60,26 @@ Object.defineProperty(exports, "isNew", { enumerable: true, get: function () { r
|
|
|
53
60
|
Object.defineProperty(exports, "maybePopulateThen", { enumerable: true, get: function () { return loadHints_1.maybePopulateThen; } });
|
|
54
61
|
__exportStar(require("./loadLens"), exports);
|
|
55
62
|
__exportStar(require("./newTestInstance"), exports);
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
var normalizeHints_1 = require("./normalizeHints");
|
|
64
|
+
Object.defineProperty(exports, "deepNormalizeHint", { enumerable: true, get: function () { return normalizeHints_1.deepNormalizeHint; } });
|
|
65
|
+
Object.defineProperty(exports, "normalizeHint", { enumerable: true, get: function () { return normalizeHints_1.normalizeHint; } });
|
|
58
66
|
var reactiveHints_2 = require("./reactiveHints");
|
|
59
67
|
Object.defineProperty(exports, "reverseReactiveHint", { enumerable: true, get: function () { return reactiveHints_2.reverseReactiveHint; } });
|
|
60
68
|
__exportStar(require("./relations"), exports);
|
|
61
69
|
var rules_2 = require("./rules");
|
|
70
|
+
Object.defineProperty(exports, "ValidationErrors", { enumerable: true, get: function () { return rules_2.ValidationErrors; } });
|
|
62
71
|
Object.defineProperty(exports, "cannotBeUpdated", { enumerable: true, get: function () { return rules_2.cannotBeUpdated; } });
|
|
63
72
|
Object.defineProperty(exports, "maxValueRule", { enumerable: true, get: function () { return rules_2.maxValueRule; } });
|
|
64
73
|
Object.defineProperty(exports, "minValueRule", { enumerable: true, get: function () { return rules_2.minValueRule; } });
|
|
65
74
|
Object.defineProperty(exports, "newRequiredRule", { enumerable: true, get: function () { return rules_2.newRequiredRule; } });
|
|
66
75
|
Object.defineProperty(exports, "rangeValueRule", { enumerable: true, get: function () { return rules_2.rangeValueRule; } });
|
|
67
|
-
Object.defineProperty(exports, "ValidationErrors", { enumerable: true, get: function () { return rules_2.ValidationErrors; } });
|
|
68
76
|
__exportStar(require("./serde"), exports);
|
|
69
77
|
var utils_2 = require("./utils");
|
|
70
78
|
Object.defineProperty(exports, "asNew", { enumerable: true, get: function () { return utils_2.asNew; } });
|
|
79
|
+
Object.defineProperty(exports, "assertNever", { enumerable: true, get: function () { return utils_2.assertNever; } });
|
|
71
80
|
Object.defineProperty(exports, "cleanStringValue", { enumerable: true, get: function () { return utils_2.cleanStringValue; } });
|
|
72
81
|
Object.defineProperty(exports, "fail", { enumerable: true, get: function () { return utils_2.fail; } });
|
|
82
|
+
Object.defineProperty(exports, "indexBy", { enumerable: true, get: function () { return utils_2.indexBy; } });
|
|
73
83
|
var withLoaded_1 = require("./withLoaded");
|
|
74
84
|
Object.defineProperty(exports, "ensureWithLoaded", { enumerable: true, get: function () { return withLoaded_1.ensureWithLoaded; } });
|
|
75
85
|
Object.defineProperty(exports, "withLoaded", { enumerable: true, get: function () { return withLoaded_1.withLoaded; } });
|
|
@@ -247,7 +257,6 @@ function configureMetadata(metas) {
|
|
|
247
257
|
}, {});
|
|
248
258
|
// Setup subTypes/baseTypes
|
|
249
259
|
metas.forEach((m) => {
|
|
250
|
-
const abbr = `${(0, QueryBuilder_1.abbreviation)(m.tableName)}0`;
|
|
251
260
|
// This is basically m.fields.mapValues to assign the primary alias
|
|
252
261
|
m.allFields = Object.fromEntries(Object.entries(m.fields).map(([name, field]) => [name, { ...field, aliasSuffix: "" }]));
|
|
253
262
|
// Only supporting one level of inheritance for now, ideally would loop `while current !== null`
|
|
@@ -317,6 +326,10 @@ function getRelations(entity) {
|
|
|
317
326
|
return Object.values(entity).filter((v) => v instanceof AbstractRelationImpl_1.AbstractRelationImpl);
|
|
318
327
|
}
|
|
319
328
|
exports.getRelations = getRelations;
|
|
329
|
+
function getRelationEntries(entity) {
|
|
330
|
+
return Object.entries(entity).filter(([_, v]) => v instanceof AbstractRelationImpl_1.AbstractRelationImpl);
|
|
331
|
+
}
|
|
332
|
+
exports.getRelationEntries = getRelationEntries;
|
|
320
333
|
function getConstructorFromTaggedId(id) {
|
|
321
334
|
const tag = (0, keys_1.tagFromId)(id);
|
|
322
335
|
return tagToConstructorMap.get(tag) ?? (0, utils_1.fail)(`Unknown tag: "${tag}" `);
|