@sprucelabs/schema 30.0.109 → 30.0.110
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/esm/AbstractSchemaTest.js +4 -18
- package/build/esm/DynamicSchemaEntityImplementation.js +2 -2
- package/build/esm/StaticSchemaEntityImpl.js +9 -3
- package/build/esm/fields/SchemaField.js +5 -1
- package/build/esm/tests/AbstractDateFieldTest.js +3 -17
- package/build/esm/utilities/defaultSchemaValues.js +4 -1
- package/build/esm/utilities/dropFields.js +3 -1
- package/build/esm/utilities/dropPrivateFields.js +3 -1
- package/build/esm/utilities/isSchemaValid.js +1 -1
- package/build/esm/utilities/makeFieldsOptional.js +4 -1
- package/build/esm/utilities/mapFieldErrorsToParameterErrors.js +12 -3
- package/build/esm/utilities/normalizeFieldValue.js +13 -15
- package/build/esm/utilities/normalizePartialSchemaValues.d.ts +3 -1
- package/build/esm/utilities/normalizePartialSchemaValues.js +4 -1
- package/build/esm/utilities/normalizeSchemaValues.js +5 -13
- package/build/esm/utilities/registerFieldType.js +14 -3
- package/build/esm/utilities/validateSchemaValues.js +1 -12
- package/build/fields/DateField.js +1 -2
- package/build/fields/DurationField.js +2 -3
- package/build/utilities/areSchemaValuesValid.js +1 -1
- package/build/utilities/areSchemasTheSame.js +1 -1
- package/build/utilities/assertOptions.js +1 -1
- package/build/utilities/buildErrorSchema.js +1 -1
- package/build/utilities/buildSchema.js +1 -1
- package/build/utilities/cloneDeep.js +1 -1
- package/build/utilities/cloneDeepPreservingInstances.js +1 -1
- package/build/utilities/defaultSchemaValues.js +1 -1
- package/build/utilities/dropFields.js +1 -1
- package/build/utilities/dropPrivateFields.js +1 -1
- package/build/utilities/formatPhoneNumber.js +3 -4
- package/build/utilities/getFields.js +1 -1
- package/build/utilities/getStartOfDay.js +1 -1
- package/build/utilities/isIdWithVersion.js +1 -1
- package/build/utilities/isSchemaValid.js +1 -1
- package/build/utilities/isUndefinedOrNull.js +1 -1
- package/build/utilities/makeFieldsOptional.js +1 -1
- package/build/utilities/mapFieldErrorsToParameterErrors.js +1 -1
- package/build/utilities/normalizeFieldValue.js +2 -3
- package/build/utilities/normalizePartialSchemaValues.d.ts +3 -1
- package/build/utilities/normalizePartialSchemaValues.js +1 -1
- package/build/utilities/normalizeSchemaToIdWithVersion.js +1 -1
- package/build/utilities/normalizeSchemaValues.js +1 -1
- package/build/utilities/pickFields.js +1 -1
- package/build/utilities/registerFieldType.js +2 -3
- package/build/utilities/selectChoicesToHash.js +2 -3
- package/build/utilities/validateSchema.js +1 -1
- package/build/utilities/validateSchemaValues.js +1 -1
- package/package.json +10 -13
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import AbstractSpruceTest from '@sprucelabs/test-utils';
|
|
11
2
|
import { SchemaRegistry } from './index.js';
|
|
12
3
|
export default class AbstractSchemaTest extends AbstractSpruceTest {
|
|
13
|
-
static beforeEach() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
yield _super.beforeEach.call(this);
|
|
19
|
-
this.registry = SchemaRegistry.getInstance();
|
|
20
|
-
this.registry.forgetAllSchemas();
|
|
21
|
-
});
|
|
4
|
+
static async beforeEach() {
|
|
5
|
+
await super.beforeEach();
|
|
6
|
+
this.registry = SchemaRegistry.getInstance();
|
|
7
|
+
this.registry.forgetAllSchemas();
|
|
22
8
|
}
|
|
23
9
|
}
|
|
@@ -46,7 +46,7 @@ export default class DynamicSchemaEntityImplementation extends AbstractEntity {
|
|
|
46
46
|
this.validate(options);
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
|
-
catch
|
|
49
|
+
catch {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -65,7 +65,7 @@ export default class DynamicSchemaEntityImplementation extends AbstractEntity {
|
|
|
65
65
|
return values;
|
|
66
66
|
}
|
|
67
67
|
setValues(values) {
|
|
68
|
-
this.values =
|
|
68
|
+
this.values = { ...this.values, ...values };
|
|
69
69
|
return this;
|
|
70
70
|
}
|
|
71
71
|
getNamedFields(options = {}) {
|
|
@@ -10,7 +10,10 @@ class StaticSchemaEntityImpl extends AbstractEntity {
|
|
|
10
10
|
this.schema = schema;
|
|
11
11
|
this.fields = {};
|
|
12
12
|
this.buildFields();
|
|
13
|
-
const v =
|
|
13
|
+
const v = {
|
|
14
|
+
...this.values,
|
|
15
|
+
...values,
|
|
16
|
+
};
|
|
14
17
|
this.values = cloneDeepPreservingInstances(v);
|
|
15
18
|
}
|
|
16
19
|
buildFields() {
|
|
@@ -30,7 +33,10 @@ class StaticSchemaEntityImpl extends AbstractEntity {
|
|
|
30
33
|
normalizeValue(forField, value, options) {
|
|
31
34
|
var _a, _b;
|
|
32
35
|
const field = this.fields[forField];
|
|
33
|
-
const overrideOptions =
|
|
36
|
+
const overrideOptions = {
|
|
37
|
+
...(options !== null && options !== void 0 ? options : {}),
|
|
38
|
+
...((_b = (_a = options === null || options === void 0 ? void 0 : options.byField) === null || _a === void 0 ? void 0 : _a[forField]) !== null && _b !== void 0 ? _b : {}),
|
|
39
|
+
};
|
|
34
40
|
return normalizeFieldValue(this.schemaId, this.name, {}, field, value, overrideOptions);
|
|
35
41
|
}
|
|
36
42
|
get(fieldName, options = {}) {
|
|
@@ -49,7 +55,7 @@ class StaticSchemaEntityImpl extends AbstractEntity {
|
|
|
49
55
|
this.validate(options);
|
|
50
56
|
return true;
|
|
51
57
|
}
|
|
52
|
-
catch
|
|
58
|
+
catch {
|
|
53
59
|
return false;
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -317,7 +317,11 @@ class SchemaField extends AbstractField {
|
|
|
317
317
|
if (createEntityInstances) {
|
|
318
318
|
return instance;
|
|
319
319
|
}
|
|
320
|
-
const getValueOptions =
|
|
320
|
+
const getValueOptions = {
|
|
321
|
+
validate: false,
|
|
322
|
+
...options,
|
|
323
|
+
fields: undefined,
|
|
324
|
+
};
|
|
321
325
|
if (isUnion) {
|
|
322
326
|
return {
|
|
323
327
|
schemaId: instance.schemaId,
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { assert } from '@sprucelabs/test-utils';
|
|
11
2
|
import { validationErrorAssert } from '../index.js';
|
|
12
3
|
import AbstractSchemaTest from '../AbstractSchemaTest.js';
|
|
13
4
|
import SchemaEntityFactory from '../factories/SchemaEntityFactory.js';
|
|
14
5
|
export default class AbstractDateFieldTest extends AbstractSchemaTest {
|
|
15
|
-
static beforeEach() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
yield _super.beforeEach.call(this);
|
|
21
|
-
this.entity = SchemaEntityFactory.Entity(this.schema);
|
|
22
|
-
});
|
|
6
|
+
static async beforeEach() {
|
|
7
|
+
await super.beforeEach();
|
|
8
|
+
this.entity = SchemaEntityFactory.Entity(this.schema);
|
|
23
9
|
}
|
|
24
10
|
static canSetDateAsDateObject() {
|
|
25
11
|
//@ts-ignore
|
|
@@ -2,5 +2,8 @@ import StaticSchemaEntityImpl from '../StaticSchemaEntityImpl.js';
|
|
|
2
2
|
export default function defaultSchemaValues(definition, options = {}) {
|
|
3
3
|
const instance = new StaticSchemaEntityImpl(definition);
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
return instance.getDefaultValues(
|
|
5
|
+
return instance.getDefaultValues({
|
|
6
|
+
shouldCreateEntityInstances: false,
|
|
7
|
+
...options,
|
|
8
|
+
});
|
|
6
9
|
}
|
|
@@ -2,7 +2,9 @@ export default function dropFields(fields, dropFields) {
|
|
|
2
2
|
const optionalFields = {};
|
|
3
3
|
Object.keys(fields).forEach((name) => {
|
|
4
4
|
if (!dropFields || dropFields.indexOf(name) === -1) {
|
|
5
|
-
optionalFields[name] =
|
|
5
|
+
optionalFields[name] = {
|
|
6
|
+
...fields[name],
|
|
7
|
+
};
|
|
6
8
|
}
|
|
7
9
|
});
|
|
8
10
|
return optionalFields;
|
|
@@ -2,7 +2,9 @@ export default function dropPrivateFields(fields) {
|
|
|
2
2
|
const optionalFields = {};
|
|
3
3
|
Object.keys(fields).forEach((name) => {
|
|
4
4
|
if (!fields[name].isPrivate) {
|
|
5
|
-
optionalFields[name] =
|
|
5
|
+
optionalFields[name] = {
|
|
6
|
+
...fields[name],
|
|
7
|
+
};
|
|
6
8
|
}
|
|
7
9
|
});
|
|
8
10
|
return optionalFields;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export default function makeFieldsOptional(fields) {
|
|
2
2
|
const optionalFields = {};
|
|
3
3
|
Object.keys(fields).forEach((name) => {
|
|
4
|
-
optionalFields[name] =
|
|
4
|
+
optionalFields[name] = {
|
|
5
|
+
...fields[name],
|
|
6
|
+
isRequired: false,
|
|
7
|
+
};
|
|
5
8
|
});
|
|
6
9
|
return optionalFields;
|
|
7
10
|
}
|
|
@@ -40,13 +40,22 @@ function pullParamaterIssues(errors, prefix = '') {
|
|
|
40
40
|
unexpectedParamaters.push(...u);
|
|
41
41
|
}
|
|
42
42
|
else if (fieldError.code === 'MISSING_PARAMETER') {
|
|
43
|
-
missingParameters.push(
|
|
43
|
+
missingParameters.push({
|
|
44
|
+
...fieldError,
|
|
45
|
+
name: fieldName,
|
|
46
|
+
});
|
|
44
47
|
}
|
|
45
48
|
else if (fieldError.code === 'INVALID_PARAMETER') {
|
|
46
|
-
invalidParameters.push(
|
|
49
|
+
invalidParameters.push({
|
|
50
|
+
...fieldError,
|
|
51
|
+
name: fieldName,
|
|
52
|
+
});
|
|
47
53
|
}
|
|
48
54
|
else if (fieldError.code === 'UNEXPECTED_PARAMETER') {
|
|
49
|
-
unexpectedParamaters.push(
|
|
55
|
+
unexpectedParamaters.push({
|
|
56
|
+
...fieldError,
|
|
57
|
+
name: fieldName,
|
|
58
|
+
});
|
|
50
59
|
}
|
|
51
60
|
});
|
|
52
61
|
return { missingParameters, invalidParameters, unexpectedParamaters };
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import SpruceError from '../errors/SpruceError.js';
|
|
13
2
|
export default function normalizeFieldValue(schemaId, schemaName, schemasById, field, value, options) {
|
|
14
3
|
var _a;
|
|
@@ -20,8 +9,12 @@ export default function normalizeFieldValue(schemaId, schemaName, schemasById, f
|
|
|
20
9
|
friendlyMessages: [`I was expecting an array for ${field.name}.`],
|
|
21
10
|
});
|
|
22
11
|
}
|
|
23
|
-
const
|
|
24
|
-
const baseOptions =
|
|
12
|
+
const { shouldValidate: validate = true, shouldCreateEntityInstances: createEntityInstances = true, ...extraOptions } = options !== null && options !== void 0 ? options : {};
|
|
13
|
+
const baseOptions = {
|
|
14
|
+
schemasById,
|
|
15
|
+
...((_a = field.definition.options) !== null && _a !== void 0 ? _a : {}),
|
|
16
|
+
...extraOptions,
|
|
17
|
+
};
|
|
25
18
|
if (value === null || typeof value === 'undefined') {
|
|
26
19
|
if (field && (!validate || !field.isRequired)) {
|
|
27
20
|
return value;
|
|
@@ -39,7 +32,9 @@ export default function normalizeFieldValue(schemaId, schemaName, schemasById, f
|
|
|
39
32
|
localValue.forEach((value) => {
|
|
40
33
|
errors = [
|
|
41
34
|
...errors,
|
|
42
|
-
...field.validate(value,
|
|
35
|
+
...field.validate(value, {
|
|
36
|
+
...baseOptions,
|
|
37
|
+
}),
|
|
43
38
|
];
|
|
44
39
|
});
|
|
45
40
|
}
|
|
@@ -54,7 +49,10 @@ export default function normalizeFieldValue(schemaId, schemaName, schemasById, f
|
|
|
54
49
|
if (localValue.length > 0) {
|
|
55
50
|
localValue = localValue.map((value) => typeof value === 'undefined'
|
|
56
51
|
? undefined
|
|
57
|
-
: field.toValueType(value,
|
|
52
|
+
: field.toValueType(value, {
|
|
53
|
+
createEntityInstances,
|
|
54
|
+
...baseOptions,
|
|
55
|
+
}));
|
|
58
56
|
}
|
|
59
57
|
return (field.isArray ? localValue : localValue[0]);
|
|
60
58
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { Schema, SchemaPartialValues, SchemaGetValuesOptions, SchemaFieldNames, SchemaPublicFieldNames, SchemaValues } from '../schemas.static.types';
|
|
2
|
-
export default function normalizePartialSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, Values extends SchemaPartialValues<S, CreateEntityInstances> = SchemaPartialValues<S, CreateEntityInstances>, Fields extends keyof Values = keyof Values>(schema: S, values: Values, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields>): Required<Pick<SchemaValues<S, CreateEntityInstances>,
|
|
2
|
+
export default function normalizePartialSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, Values extends SchemaPartialValues<S, CreateEntityInstances> = SchemaPartialValues<S, CreateEntityInstances>, Fields extends keyof Values = keyof Values>(schema: S, values: Values, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields>): Required<Pick<SchemaValues<S, CreateEntityInstances>,
|
|
3
|
+
/** @ts-ignore */
|
|
4
|
+
Fields>>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import normalizeSchemaValues from './normalizeSchemaValues.js';
|
|
2
2
|
export default function normalizePartialSchemaValues(schema, values, options) {
|
|
3
|
-
const normalized = normalizeSchemaValues(schema, values,
|
|
3
|
+
const normalized = normalizeSchemaValues(schema, values, {
|
|
4
|
+
...options,
|
|
5
|
+
shouldIncludeNullAndUndefinedFields: false,
|
|
6
|
+
});
|
|
4
7
|
return normalized;
|
|
5
8
|
}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import EntityFactory from '../factories/SchemaEntityFactory.js';
|
|
13
2
|
export default function normalizeSchemaValues(schema, values, options) {
|
|
14
3
|
const instance = EntityFactory.Entity(schema, values);
|
|
15
|
-
const
|
|
16
|
-
const normalizedOptions =
|
|
4
|
+
const { shouldCreateEntityInstances = false, ...rest } = options || {};
|
|
5
|
+
const normalizedOptions = {
|
|
6
|
+
shouldCreateEntityInstances,
|
|
7
|
+
...rest,
|
|
8
|
+
};
|
|
17
9
|
return instance.getValues(normalizedOptions);
|
|
18
10
|
}
|
|
@@ -24,15 +24,26 @@ export function validateFieldRegistration(registration) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
if (errors.length > 0) {
|
|
27
|
-
throw new SpruceError(
|
|
27
|
+
throw new SpruceError({
|
|
28
|
+
code: 'INVALID_FIELD_REGISTRATION',
|
|
29
|
+
...builtRegistration,
|
|
30
|
+
});
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
/** Register a new type of field */
|
|
31
34
|
export default function registerFieldType(options) {
|
|
32
|
-
const registration =
|
|
35
|
+
const registration = {
|
|
36
|
+
package: options.package,
|
|
37
|
+
className: options.class.name,
|
|
38
|
+
type: options.type,
|
|
39
|
+
importAs: options.importAs,
|
|
40
|
+
// TODO change this up when typescript supports typing static methods on a class
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
description: options.class.description,
|
|
33
43
|
// TODO change this up when typescript supports typing static methods on a class
|
|
34
44
|
// @ts-ignore
|
|
35
|
-
|
|
45
|
+
...options.class.generateTypeDetails(),
|
|
46
|
+
};
|
|
36
47
|
validateFieldRegistration(registration);
|
|
37
48
|
return registration;
|
|
38
49
|
}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import set from 'just-safe-set';
|
|
13
2
|
import { validateSchema } from '../index.js';
|
|
14
3
|
import EntityFactory from '../factories/SchemaEntityFactory.js';
|
|
15
4
|
export default function validateSchemaValues(schema, values, options) {
|
|
16
|
-
const opts =
|
|
5
|
+
const { ...opts } = options !== null && options !== void 0 ? options : {};
|
|
17
6
|
validateSchema(schema);
|
|
18
7
|
const mapped = Object.keys(values).reduce((mapped, key) => {
|
|
19
8
|
//@ts-ignore
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateDateValue =
|
|
6
|
+
exports.validateDateValue = validateDateValue;
|
|
7
7
|
const getStartOfDay_1 = __importDefault(require("../utilities/getStartOfDay"));
|
|
8
8
|
const isUndefinedOrNull_1 = __importDefault(require("../utilities/isUndefinedOrNull"));
|
|
9
9
|
const AbstractField_1 = __importDefault(require("./AbstractField"));
|
|
@@ -52,4 +52,3 @@ function validateDateValue(options) {
|
|
|
52
52
|
},
|
|
53
53
|
];
|
|
54
54
|
}
|
|
55
|
-
exports.validateDateValue = validateDateValue;
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.reduceDurationToMs = reduceDurationToMs;
|
|
7
|
+
exports.buildDuration = buildDuration;
|
|
7
8
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
8
9
|
const AbstractField_1 = __importDefault(require("./AbstractField"));
|
|
9
10
|
function reduceDurationToMs(duration) {
|
|
@@ -15,7 +16,6 @@ function reduceDurationToMs(duration) {
|
|
|
15
16
|
ms += d.hours * 60 * 60 * 1000;
|
|
16
17
|
return ms;
|
|
17
18
|
}
|
|
18
|
-
exports.reduceDurationToMs = reduceDurationToMs;
|
|
19
19
|
function buildDuration(value) {
|
|
20
20
|
let totalMs = 0;
|
|
21
21
|
if (typeof value === 'string') {
|
|
@@ -47,7 +47,6 @@ function buildDuration(value) {
|
|
|
47
47
|
const hours = (totalMs - minutes) / 60;
|
|
48
48
|
return { hours, minutes, seconds, ms };
|
|
49
49
|
}
|
|
50
|
-
exports.buildDuration = buildDuration;
|
|
51
50
|
class DurationField extends AbstractField_1.default {
|
|
52
51
|
static generateTemplateDetails(options) {
|
|
53
52
|
return {
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = areSchemaValuesValid;
|
|
6
7
|
const SchemaEntityFactory_1 = __importDefault(require("../factories/SchemaEntityFactory"));
|
|
7
8
|
function areSchemaValuesValid(definition, values, options) {
|
|
8
9
|
const instance = SchemaEntityFactory_1.default.Entity(definition, values);
|
|
9
10
|
return instance.isValid(options);
|
|
10
11
|
}
|
|
11
|
-
exports.default = areSchemaValuesValid;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = areSchemasTheSame;
|
|
3
4
|
function areSchemasTheSame(left, right) {
|
|
4
5
|
var _a, _b;
|
|
5
6
|
if (left.id !== right.id) {
|
|
@@ -13,4 +14,3 @@ function areSchemasTheSame(left, right) {
|
|
|
13
14
|
// TODO let fields compare their definitions
|
|
14
15
|
return true;
|
|
15
16
|
}
|
|
16
|
-
exports.default = areSchemasTheSame;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = assertOptions;
|
|
6
7
|
const just_safe_get_1 = __importDefault(require("just-safe-get"));
|
|
7
8
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
8
9
|
function assertOptions(options, toCheck, friendlyMessage) {
|
|
@@ -23,4 +24,3 @@ function assertOptions(options, toCheck, friendlyMessage) {
|
|
|
23
24
|
}
|
|
24
25
|
return options;
|
|
25
26
|
}
|
|
26
|
-
exports.default = assertOptions;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = buildSchema;
|
|
6
7
|
const SchemaRegistry_1 = __importDefault(require("../singletons/SchemaRegistry"));
|
|
7
8
|
function buildSchema(schema) {
|
|
8
9
|
SchemaRegistry_1.default.getInstance().trackSchema(schema);
|
|
9
10
|
return schema;
|
|
10
11
|
}
|
|
11
|
-
exports.default = buildSchema;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = cloneDeep;
|
|
3
4
|
function cloneDeep(obj, transformer) {
|
|
4
5
|
var _a;
|
|
5
6
|
const o = obj;
|
|
@@ -33,7 +34,6 @@ function cloneDeep(obj, transformer) {
|
|
|
33
34
|
// primitives and non-supported objects (e.g. functions) land here
|
|
34
35
|
return result;
|
|
35
36
|
}
|
|
36
|
-
exports.default = cloneDeep;
|
|
37
37
|
function getRegExpFlags(regExp) {
|
|
38
38
|
if (typeof regExp.source.flags == 'string') {
|
|
39
39
|
return regExp.source.flags;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = cloneDeepPreservingInstances;
|
|
6
7
|
const cloneDeep_1 = __importDefault(require("./cloneDeep"));
|
|
7
8
|
function cloneDeepPreservingInstances(v) {
|
|
8
9
|
return (0, cloneDeep_1.default)(v, (value) => {
|
|
@@ -13,4 +14,3 @@ function cloneDeepPreservingInstances(v) {
|
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
|
-
exports.default = cloneDeepPreservingInstances;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = defaultSchemaValues;
|
|
6
7
|
const StaticSchemaEntityImpl_1 = __importDefault(require("../StaticSchemaEntityImpl"));
|
|
7
8
|
function defaultSchemaValues(definition, options = {}) {
|
|
8
9
|
const instance = new StaticSchemaEntityImpl_1.default(definition);
|
|
@@ -12,4 +13,3 @@ function defaultSchemaValues(definition, options = {}) {
|
|
|
12
13
|
...options,
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
|
-
exports.default = defaultSchemaValues;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = dropFields;
|
|
3
4
|
function dropFields(fields, dropFields) {
|
|
4
5
|
const optionalFields = {};
|
|
5
6
|
Object.keys(fields).forEach((name) => {
|
|
@@ -11,4 +12,3 @@ function dropFields(fields, dropFields) {
|
|
|
11
12
|
});
|
|
12
13
|
return optionalFields;
|
|
13
14
|
}
|
|
14
|
-
exports.default = dropFields;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = dropPrivateFields;
|
|
3
4
|
function dropPrivateFields(fields) {
|
|
4
5
|
const optionalFields = {};
|
|
5
6
|
Object.keys(fields).forEach((name) => {
|
|
@@ -11,4 +12,3 @@ function dropPrivateFields(fields) {
|
|
|
11
12
|
});
|
|
12
13
|
return optionalFields;
|
|
13
14
|
}
|
|
14
|
-
exports.default = dropPrivateFields;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isValidNumber = isValidNumber;
|
|
4
|
+
exports.default = formatPhoneNumber;
|
|
5
|
+
exports.isDummyNumber = isDummyNumber;
|
|
4
6
|
function formatNumberWithCode(phoneNumberString, code = '1') {
|
|
5
7
|
if (phoneNumberString.match(/[a-zA-Z]/g)) {
|
|
6
8
|
return null;
|
|
@@ -33,7 +35,6 @@ function isValidNumber(number) {
|
|
|
33
35
|
const formatted = (_a = formatNumberWithCode(number, code)) === null || _a === void 0 ? void 0 : _a.replace(/[^0-9]/g, '');
|
|
34
36
|
return (formatted === null || formatted === void 0 ? void 0 : formatted.length) === 11 || (formatted === null || formatted === void 0 ? void 0 : formatted.length) === 12;
|
|
35
37
|
}
|
|
36
|
-
exports.isValidNumber = isValidNumber;
|
|
37
38
|
function stripCode(number) {
|
|
38
39
|
let code = `1`; // Default to North American country code
|
|
39
40
|
const cleaned = number.replace(/(?!^\+)[^\d]/g, '');
|
|
@@ -67,9 +68,7 @@ function formatPhoneNumber(val, shouldFailSilently = true) {
|
|
|
67
68
|
const cleaned = formatted.replace(/\s+$/, '');
|
|
68
69
|
return cleaned;
|
|
69
70
|
}
|
|
70
|
-
exports.default = formatPhoneNumber;
|
|
71
71
|
function isDummyNumber(phone) {
|
|
72
72
|
const cleanedValue = phone.replace(/\D/g, '');
|
|
73
73
|
return cleanedValue.startsWith('1555') || cleanedValue.startsWith('555');
|
|
74
74
|
}
|
|
75
|
-
exports.isDummyNumber = isDummyNumber;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getFields;
|
|
6
7
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
7
8
|
function getFields(schema) {
|
|
8
9
|
var _a;
|
|
@@ -15,4 +16,3 @@ function getFields(schema) {
|
|
|
15
16
|
}
|
|
16
17
|
return names;
|
|
17
18
|
}
|
|
18
|
-
exports.default = getFields;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getStartOfDay;
|
|
3
4
|
function getStartOfDay(timestamp) {
|
|
4
5
|
if (!timestamp) {
|
|
5
6
|
timestamp = new Date().getTime();
|
|
@@ -8,4 +9,3 @@ function getStartOfDay(timestamp) {
|
|
|
8
9
|
date.setUTCHours(0, 0, 0, 0);
|
|
9
10
|
return date.getTime();
|
|
10
11
|
}
|
|
11
|
-
exports.default = getStartOfDay;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = isIdWithVersion;
|
|
3
4
|
function isIdWithVersion(item) {
|
|
4
5
|
return (typeof item.id === 'string' &&
|
|
5
6
|
typeof item.fields === 'undefined' &&
|
|
6
7
|
typeof item.dynamicFieldSignature === 'undefined');
|
|
7
8
|
}
|
|
8
|
-
exports.default = isIdWithVersion;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = isSchemaValid;
|
|
6
7
|
const validateSchema_1 = __importDefault(require("./validateSchema"));
|
|
7
8
|
function isSchemaValid(definition) {
|
|
8
9
|
try {
|
|
@@ -13,4 +14,3 @@ function isSchemaValid(definition) {
|
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
exports.default = isSchemaValid;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = makeFieldsOptional;
|
|
3
4
|
function makeFieldsOptional(fields) {
|
|
4
5
|
const optionalFields = {};
|
|
5
6
|
Object.keys(fields).forEach((name) => {
|
|
@@ -10,4 +11,3 @@ function makeFieldsOptional(fields) {
|
|
|
10
11
|
});
|
|
11
12
|
return optionalFields;
|
|
12
13
|
}
|
|
13
|
-
exports.default = makeFieldsOptional;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = mapFieldErrorsToParameterErrors;
|
|
6
7
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
7
8
|
function mapFieldErrorsToParameterErrors(fieldErrors) {
|
|
8
9
|
const { missingParameters, invalidParameters, unexpectedParamaters } = pullParamaterIssues(fieldErrors);
|
|
@@ -30,7 +31,6 @@ function mapFieldErrorsToParameterErrors(fieldErrors) {
|
|
|
30
31
|
}
|
|
31
32
|
return errors;
|
|
32
33
|
}
|
|
33
|
-
exports.default = mapFieldErrorsToParameterErrors;
|
|
34
34
|
function pullParamaterIssues(errors, prefix = '') {
|
|
35
35
|
const missingParameters = [];
|
|
36
36
|
const invalidParameters = [];
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = normalizeFieldValue;
|
|
7
|
+
exports.normalizeValueToArray = normalizeValueToArray;
|
|
7
8
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
8
9
|
function normalizeFieldValue(schemaId, schemaName, schemasById, field, value, options) {
|
|
9
10
|
var _a;
|
|
@@ -62,7 +63,6 @@ function normalizeFieldValue(schemaId, schemaName, schemasById, field, value, op
|
|
|
62
63
|
}
|
|
63
64
|
return (field.isArray ? localValue : localValue[0]);
|
|
64
65
|
}
|
|
65
|
-
exports.default = normalizeFieldValue;
|
|
66
66
|
function normalizeValueToArray(value) {
|
|
67
67
|
return value === null || typeof value === 'undefined'
|
|
68
68
|
? []
|
|
@@ -70,4 +70,3 @@ function normalizeValueToArray(value) {
|
|
|
70
70
|
? value
|
|
71
71
|
: [value];
|
|
72
72
|
}
|
|
73
|
-
exports.normalizeValueToArray = normalizeValueToArray;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { Schema, SchemaPartialValues, SchemaGetValuesOptions, SchemaFieldNames, SchemaPublicFieldNames, SchemaValues } from '../schemas.static.types';
|
|
2
|
-
export default function normalizePartialSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, Values extends SchemaPartialValues<S, CreateEntityInstances> = SchemaPartialValues<S, CreateEntityInstances>, Fields extends keyof Values = keyof Values>(schema: S, values: Values, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields>): Required<Pick<SchemaValues<S, CreateEntityInstances>,
|
|
2
|
+
export default function normalizePartialSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, Values extends SchemaPartialValues<S, CreateEntityInstances> = SchemaPartialValues<S, CreateEntityInstances>, Fields extends keyof Values = keyof Values>(schema: S, values: Values, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields>): Required<Pick<SchemaValues<S, CreateEntityInstances>,
|
|
3
|
+
/** @ts-ignore */
|
|
4
|
+
Fields>>;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = normalizePartialSchemaValues;
|
|
6
7
|
const normalizeSchemaValues_1 = __importDefault(require("./normalizeSchemaValues"));
|
|
7
8
|
function normalizePartialSchemaValues(schema, values, options) {
|
|
8
9
|
const normalized = (0, normalizeSchemaValues_1.default)(schema, values, {
|
|
@@ -11,4 +12,3 @@ function normalizePartialSchemaValues(schema, values, options) {
|
|
|
11
12
|
});
|
|
12
13
|
return normalized;
|
|
13
14
|
}
|
|
14
|
-
exports.default = normalizePartialSchemaValues;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = normalizeSchemaToIdWithVersion;
|
|
6
7
|
const isIdWithVersion_1 = __importDefault(require("./isIdWithVersion"));
|
|
7
8
|
function normalizeSchemaToIdWithVersion(schemaOrIdWithVersion) {
|
|
8
9
|
if ((0, isIdWithVersion_1.default)(schemaOrIdWithVersion)) {
|
|
@@ -17,4 +18,3 @@ function normalizeSchemaToIdWithVersion(schemaOrIdWithVersion) {
|
|
|
17
18
|
}
|
|
18
19
|
return idWithVersion;
|
|
19
20
|
}
|
|
20
|
-
exports.default = normalizeSchemaToIdWithVersion;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = normalizeSchemaValues;
|
|
6
7
|
const SchemaEntityFactory_1 = __importDefault(require("../factories/SchemaEntityFactory"));
|
|
7
8
|
function normalizeSchemaValues(schema, values, options) {
|
|
8
9
|
const instance = SchemaEntityFactory_1.default.Entity(schema, values);
|
|
@@ -13,4 +14,3 @@ function normalizeSchemaValues(schema, values, options) {
|
|
|
13
14
|
};
|
|
14
15
|
return instance.getValues(normalizedOptions);
|
|
15
16
|
}
|
|
16
|
-
exports.default = normalizeSchemaValues;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = pickFields;
|
|
3
4
|
function pickFields(fields, names) {
|
|
4
5
|
const final = {};
|
|
5
6
|
for (const name of names) {
|
|
@@ -7,4 +8,3 @@ function pickFields(fields, names) {
|
|
|
7
8
|
}
|
|
8
9
|
return final;
|
|
9
10
|
}
|
|
10
|
-
exports.default = pickFields;
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateFieldRegistration =
|
|
6
|
+
exports.validateFieldRegistration = validateFieldRegistration;
|
|
7
|
+
exports.default = registerFieldType;
|
|
7
8
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
8
9
|
function validateFieldRegistration(registration) {
|
|
9
10
|
const errors = [];
|
|
@@ -36,7 +37,6 @@ function validateFieldRegistration(registration) {
|
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
exports.validateFieldRegistration = validateFieldRegistration;
|
|
40
40
|
/** Register a new type of field */
|
|
41
41
|
function registerFieldType(options) {
|
|
42
42
|
const registration = {
|
|
@@ -54,4 +54,3 @@ function registerFieldType(options) {
|
|
|
54
54
|
validateFieldRegistration(registration);
|
|
55
55
|
return registration;
|
|
56
56
|
}
|
|
57
|
-
exports.default = registerFieldType;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.selectChoicesToHash = selectChoicesToHash;
|
|
4
|
+
exports.schemaChoicesToHash = schemaChoicesToHash;
|
|
4
5
|
/** Pass the select options directly to create a value/label hash */
|
|
5
6
|
function selectChoicesToHash(options) {
|
|
6
7
|
const partial = {};
|
|
@@ -10,7 +11,6 @@ function selectChoicesToHash(options) {
|
|
|
10
11
|
});
|
|
11
12
|
return partial;
|
|
12
13
|
}
|
|
13
|
-
exports.selectChoicesToHash = selectChoicesToHash;
|
|
14
14
|
/** Take a definition and a field name and returns a value/label hash */
|
|
15
15
|
function schemaChoicesToHash(definition, fieldName) {
|
|
16
16
|
var _a, _b, _c, _d;
|
|
@@ -19,4 +19,3 @@ function schemaChoicesToHash(definition, fieldName) {
|
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
(_d = (_c = (_b = (_a = definition.fields) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.choices) !== null && _d !== void 0 ? _d : []);
|
|
21
21
|
}
|
|
22
|
-
exports.schemaChoicesToHash = schemaChoicesToHash;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = validateSchema;
|
|
6
7
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
7
8
|
function validateSchema(schema) {
|
|
8
9
|
var _a;
|
|
@@ -32,4 +33,3 @@ function validateSchema(schema) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
exports.default = validateSchema;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = validateSchemaValues;
|
|
6
7
|
const just_safe_set_1 = __importDefault(require("just-safe-set"));
|
|
7
8
|
const __1 = require("..");
|
|
8
9
|
const SchemaEntityFactory_1 = __importDefault(require("../factories/SchemaEntityFactory"));
|
|
@@ -17,4 +18,3 @@ function validateSchemaValues(schema, values, options) {
|
|
|
17
18
|
const instance = SchemaEntityFactory_1.default.Entity(schema, mapped);
|
|
18
19
|
instance.validate(opts);
|
|
19
20
|
}
|
|
20
|
-
exports.default = validateSchemaValues;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"!build/__tests__",
|
|
9
9
|
"esm"
|
|
10
10
|
],
|
|
11
|
-
"version": "30.0.
|
|
11
|
+
"version": "30.0.110",
|
|
12
12
|
"main": "./build/index.js",
|
|
13
13
|
"types": "./build/index.d.ts",
|
|
14
14
|
"module": "./build/esm/index.js",
|
|
@@ -50,9 +50,6 @@
|
|
|
50
50
|
"release": "semantic-release",
|
|
51
51
|
"test": "jest",
|
|
52
52
|
"update.dependencies": "yarn run clean.dependencies && yarn",
|
|
53
|
-
"upgrade.packages": "yarn-upgrade-all && rm -f yarn.lock ; yarn ; yarn fix.lint ; true",
|
|
54
|
-
"upgrade.packages.all": "yarn install && yarn upgrade.packages",
|
|
55
|
-
"upgrade.packages.test": "yarn upgrade.packages.all && yarn lint && yarn build.dev && yarn test",
|
|
56
53
|
"watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
|
|
57
54
|
"watch.tsc": "tsc -w",
|
|
58
55
|
"post.watch.build": "yarn build.resolve-paths",
|
|
@@ -61,28 +58,28 @@
|
|
|
61
58
|
"build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/"
|
|
62
59
|
},
|
|
63
60
|
"dependencies": {
|
|
64
|
-
"@sprucelabs/error": "^6.0.
|
|
65
|
-
"@sprucelabs/test-utils": "^5.1.
|
|
61
|
+
"@sprucelabs/error": "^6.0.69",
|
|
62
|
+
"@sprucelabs/test-utils": "^5.1.2",
|
|
66
63
|
"email-validator": "^2.0.4",
|
|
67
64
|
"just-safe-get": "^4.2.0",
|
|
68
65
|
"just-safe-set": "^4.2.1"
|
|
69
66
|
},
|
|
70
67
|
"devDependencies": {
|
|
71
|
-
"@sprucelabs/esm-postbuild": "^6.0.
|
|
72
|
-
"@sprucelabs/jest-json-reporter": "^8.0.
|
|
73
|
-
"@sprucelabs/resolve-path-aliases": "^2.0.
|
|
74
|
-
"@sprucelabs/semantic-release": "^5.0.
|
|
75
|
-
"@sprucelabs/test": "^9.0.
|
|
68
|
+
"@sprucelabs/esm-postbuild": "^6.0.52",
|
|
69
|
+
"@sprucelabs/jest-json-reporter": "^8.0.72",
|
|
70
|
+
"@sprucelabs/resolve-path-aliases": "^2.0.47",
|
|
71
|
+
"@sprucelabs/semantic-release": "^5.0.2",
|
|
72
|
+
"@sprucelabs/test": "^9.0.34",
|
|
76
73
|
"chokidar-cli": "^3.0.0",
|
|
77
74
|
"eslint": "^9.5.0",
|
|
78
|
-
"eslint-config-spruce": "^11.2.
|
|
75
|
+
"eslint-config-spruce": "^11.2.26",
|
|
79
76
|
"jest": "^29.7.0",
|
|
80
77
|
"jest-circus": "^29.7.0",
|
|
81
78
|
"prettier": "^3.3.2",
|
|
82
79
|
"ts-node": "^10.9.2",
|
|
83
80
|
"tsc-watch": "^6.2.0",
|
|
84
81
|
"tsconfig-paths": "^4.2.0",
|
|
85
|
-
"typescript": "^5.
|
|
82
|
+
"typescript": "^5.5.2"
|
|
86
83
|
},
|
|
87
84
|
"jest": {
|
|
88
85
|
"testEnvironment": "node",
|