@sprucelabs/schema 31.0.1 → 31.0.3
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.
|
@@ -217,19 +217,20 @@ class SchemaField extends AbstractField {
|
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
else {
|
|
220
|
-
const
|
|
221
|
-
|
|
220
|
+
const matches = schemas.filter((schema) => schema.id === id &&
|
|
221
|
+
(!version || schema.version === version));
|
|
222
|
+
if (matches.length !== 1) {
|
|
222
223
|
errors.push({
|
|
223
224
|
name: this.name,
|
|
224
225
|
label: this.label,
|
|
225
226
|
code: 'INVALID_PARAMETER',
|
|
226
227
|
friendlyMessage: `Could not find a schema by id '${id}'${version
|
|
227
228
|
? ` and version '${version}'`
|
|
228
|
-
: ' with no version'}.`,
|
|
229
|
+
: ' with no version. Try adding a version to disambiguate.'}.`,
|
|
229
230
|
});
|
|
230
231
|
}
|
|
231
232
|
else {
|
|
232
|
-
instance = this.Schema(
|
|
233
|
+
instance = this.Schema(matches[0], values);
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
}
|
|
@@ -259,7 +260,6 @@ class SchemaField extends AbstractField {
|
|
|
259
260
|
}
|
|
260
261
|
toValueType(value, options) {
|
|
261
262
|
const { createEntityInstances, schemasById: schemasById = {} } = options || {};
|
|
262
|
-
debugger;
|
|
263
263
|
// try and pull the schema definition from the options and by id
|
|
264
264
|
const destinationSchemas = SchemaField.mapFieldDefinitionToSchemas(this.definition, {
|
|
265
265
|
schemasById,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Schema, SchemaPartialValues, SchemaGetValuesOptions, SchemaFieldNames, SchemaPublicFieldNames, IsDynamicSchema, DynamicSchemaAllValues, SchemaValues } from '../schemas.static.types';
|
|
2
2
|
import { ValuesWithPaths } from '../types/utilities.types';
|
|
3
|
-
export default function normalizeSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, IsDynamic extends boolean = IsDynamicSchema<S>, ShouldIncludeNullAndUndefinedFields extends boolean = true>(schema: S, values: ValuesWithPaths<SchemaPartialValues<S
|
|
3
|
+
export default function normalizeSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, IsDynamic extends boolean = IsDynamicSchema<S>, ShouldIncludeNullAndUndefinedFields extends boolean = true>(schema: S, values: ValuesWithPaths<SchemaPartialValues<S>> | SchemaValues<S>, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields, ShouldIncludeNullAndUndefinedFields>): IsDynamic extends true ? DynamicSchemaAllValues<S, CreateEntityInstances> : IncludePrivateFields extends true ? Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, F> : Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, PF>;
|
|
@@ -221,19 +221,20 @@ class SchemaField extends AbstractField_1.default {
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
else {
|
|
224
|
-
const
|
|
225
|
-
|
|
224
|
+
const matches = schemas.filter((schema) => schema.id === id &&
|
|
225
|
+
(!version || schema.version === version));
|
|
226
|
+
if (matches.length !== 1) {
|
|
226
227
|
errors.push({
|
|
227
228
|
name: this.name,
|
|
228
229
|
label: this.label,
|
|
229
230
|
code: 'INVALID_PARAMETER',
|
|
230
231
|
friendlyMessage: `Could not find a schema by id '${id}'${version
|
|
231
232
|
? ` and version '${version}'`
|
|
232
|
-
: ' with no version'}.`,
|
|
233
|
+
: ' with no version. Try adding a version to disambiguate.'}.`,
|
|
233
234
|
});
|
|
234
235
|
}
|
|
235
236
|
else {
|
|
236
|
-
instance = this.Schema(
|
|
237
|
+
instance = this.Schema(matches[0], values);
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
}
|
|
@@ -263,7 +264,6 @@ class SchemaField extends AbstractField_1.default {
|
|
|
263
264
|
}
|
|
264
265
|
toValueType(value, options) {
|
|
265
266
|
const { createEntityInstances, schemasById: schemasById = {} } = options || {};
|
|
266
|
-
debugger;
|
|
267
267
|
// try and pull the schema definition from the options and by id
|
|
268
268
|
const destinationSchemas = SchemaField.mapFieldDefinitionToSchemas(this.definition, {
|
|
269
269
|
schemasById,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Schema, SchemaPartialValues, SchemaGetValuesOptions, SchemaFieldNames, SchemaPublicFieldNames, IsDynamicSchema, DynamicSchemaAllValues, SchemaValues } from '../schemas.static.types';
|
|
2
2
|
import { ValuesWithPaths } from '../types/utilities.types';
|
|
3
|
-
export default function normalizeSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, IsDynamic extends boolean = IsDynamicSchema<S>, ShouldIncludeNullAndUndefinedFields extends boolean = true>(schema: S, values: ValuesWithPaths<SchemaPartialValues<S
|
|
3
|
+
export default function normalizeSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, IsDynamic extends boolean = IsDynamicSchema<S>, ShouldIncludeNullAndUndefinedFields extends boolean = true>(schema: S, values: ValuesWithPaths<SchemaPartialValues<S>> | SchemaValues<S>, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields, ShouldIncludeNullAndUndefinedFields>): IsDynamic extends true ? DynamicSchemaAllValues<S, CreateEntityInstances> : IncludePrivateFields extends true ? Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, F> : Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, PF>;
|