Skip to content

Commit fc92a6c

Browse files
committed
fix: ignore certain fields when showing partial models debugging text
1 parent f597ebd commit fc92a6c

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

dist/index.cjs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ debug.adapter = (level, ...args) => {
7878
}
7979
};
8080

81+
const IGNORED_KEYS = ['Symbol(', '_', '$', '#'];
8182
class Parser {
8283
resolved = {};
8384
constructor(data, included = []) {
@@ -140,9 +141,12 @@ class Parser {
140141
return true;
141142
}
142143
if (prop in target) {
143-
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
144144
return target[prop];
145145
}
146+
const propString = prop.toString();
147+
if (IGNORED_KEYS.some(k => propString.startsWith(k))) {
148+
return undefined;
149+
}
146150
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
147151
return undefined;
148152
}

dist/index.esm.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ debug.adapter = (level, ...args) => {
7474
}
7575
};
7676

77+
const IGNORED_KEYS = ['Symbol(', '_', '$', '#'];
7778
class Parser {
7879
resolved = {};
7980
constructor(data, included = []) {
@@ -136,9 +137,12 @@ class Parser {
136137
return true;
137138
}
138139
if (prop in target) {
139-
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
140140
return target[prop];
141141
}
142+
const propString = prop.toString();
143+
if (IGNORED_KEYS.some(k => propString.startsWith(k))) {
144+
return undefined;
145+
}
142146
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
143147
return undefined;
144148
}

src/Parser.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { Model } from "./Model";
66
import { $registeredAttributes, $registeredModels, $registeredRelationships } from "./data";
77
import { debug } from "./utils";
88

9+
const IGNORED_KEYS = ['Symbol(', '_', '$', '#'];
10+
911
export class Parser {
1012
readonly resolved: Record<string, Model> = {};
1113

@@ -95,9 +97,12 @@ export class Parser {
9597
return true;
9698
}
9799
if (prop in target) {
98-
debug('warn', `Trying to call property ${prop.toString()} to a model that is not included ("${loadedElement.type}"). Maybe you mean't to include it?`);
99100
return target[prop];
100101
}
102+
const propString = prop.toString();
103+
if (IGNORED_KEYS.some((k) => propString.startsWith(k))) {
104+
return undefined;
105+
}
101106
debug('error', `Trying to call property "${prop.toString()}" to a model that is not included. Add "${loadedElement.type}" to included models.`);
102107
return undefined;
103108
},

0 commit comments

Comments
 (0)