@snowtop/ent 0.0.32-alpha.3 → 0.0.32-alpha.4
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/package.json +1 -1
- package/schema/field.js +5 -4
- package/schema/schema.d.ts +2 -2
package/package.json
CHANGED
package/schema/field.js
CHANGED
|
@@ -81,8 +81,9 @@ class UUIDField extends BaseField {
|
|
|
81
81
|
];
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
if (options.fieldEdge?.enforceSchema &&
|
|
85
|
-
|
|
84
|
+
if (options.fieldEdge?.enforceSchema &&
|
|
85
|
+
!options.fieldEdge.getLoaderOptions) {
|
|
86
|
+
throw new Error(`cannot enforceSchema if getLoaderOptions wasn't passed in`);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
isBuilder(val) {
|
|
@@ -92,8 +93,8 @@ class UUIDField extends BaseField {
|
|
|
92
93
|
if (!this.options.fieldEdge?.enforceSchema) {
|
|
93
94
|
return true;
|
|
94
95
|
}
|
|
95
|
-
const
|
|
96
|
-
const loadRowOptions =
|
|
96
|
+
const getLoaderOptions = this.options.fieldEdge.getLoaderOptions;
|
|
97
|
+
const loadRowOptions = getLoaderOptions(this.options.fieldEdge.schema);
|
|
97
98
|
if (this.isBuilder(val)) {
|
|
98
99
|
// if builder, the ent type of the builder and the ent type returned by the load constructor should match
|
|
99
100
|
return val.ent === loadRowOptions.ent;
|
package/schema/schema.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export interface ForeignKey {
|
|
|
102
102
|
disableIndex?: boolean;
|
|
103
103
|
disableBuilderType?: boolean;
|
|
104
104
|
}
|
|
105
|
-
declare type
|
|
105
|
+
declare type getLoaderOptionsFn = (type: any) => LoadEntOptions<Ent>;
|
|
106
106
|
export interface InverseFieldEdge {
|
|
107
107
|
name: string;
|
|
108
108
|
edgeConstName?: string;
|
|
@@ -113,7 +113,7 @@ export interface FieldEdge {
|
|
|
113
113
|
schema: string;
|
|
114
114
|
inverseEdge?: string | InverseFieldEdge;
|
|
115
115
|
enforceSchema?: boolean;
|
|
116
|
-
|
|
116
|
+
getLoaderOptions?: getLoaderOptionsFn;
|
|
117
117
|
disableBuilderType?: boolean;
|
|
118
118
|
}
|
|
119
119
|
export interface FieldOptions {
|