@sprucelabs/schema 25.5.63 → 25.5.67

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.
Files changed (94) hide show
  1. package/build/esm/DynamicSchemaEntityImplementation.d.ts +1 -1
  2. package/build/esm/fields/AbstractField.d.ts +1 -1
  3. package/build/esm/fields/field.static.types.d.ts +1 -1
  4. package/build/esm/schemas.static.types.d.ts +1 -1
  5. package/build/esm/utilities/normalizeFieldValue.d.ts +1 -1
  6. package/package.json +15 -14
  7. package/build/esm/__tests__/behavioral/AssertingSelectOptions.test.d.ts +0 -7
  8. package/build/esm/__tests__/behavioral/AssertingSelectOptions.test.js +0 -93
  9. package/build/esm/__tests__/behavioral/AssertingValidationErrors.test.d.ts +0 -18
  10. package/build/esm/__tests__/behavioral/AssertingValidationErrors.test.js +0 -217
  11. package/build/esm/__tests__/behavioral/BuildSchema.test.d.ts +0 -5
  12. package/build/esm/__tests__/behavioral/BuildSchema.test.js +0 -66
  13. package/build/esm/__tests__/behavioral/CreatingEntityInstances.test.d.ts +0 -7
  14. package/build/esm/__tests__/behavioral/CreatingEntityInstances.test.js +0 -93
  15. package/build/esm/__tests__/behavioral/DroppingFields.test.d.ts +0 -5
  16. package/build/esm/__tests__/behavioral/DroppingFields.test.js +0 -86
  17. package/build/esm/__tests__/behavioral/GeneratesRelationshipTemplates.test.d.ts +0 -9
  18. package/build/esm/__tests__/behavioral/GeneratesRelationshipTemplates.test.js +0 -137
  19. package/build/esm/__tests__/behavioral/GeneratesRelationshipTemplatesWithSuffix.test.d.ts +0 -5
  20. package/build/esm/__tests__/behavioral/GeneratesRelationshipTemplatesWithSuffix.test.js +0 -146
  21. package/build/esm/__tests__/behavioral/GeneratesTemplates.test.d.ts +0 -5
  22. package/build/esm/__tests__/behavioral/GeneratesTemplates.test.js +0 -67
  23. package/build/esm/__tests__/behavioral/GeneratesTypeMappers.test.d.ts +0 -5
  24. package/build/esm/__tests__/behavioral/GeneratesTypeMappers.test.js +0 -29
  25. package/build/esm/__tests__/behavioral/GeneratesVersionedRelationshipTemplates.test.d.ts +0 -11
  26. package/build/esm/__tests__/behavioral/GeneratesVersionedRelationshipTemplates.test.js +0 -191
  27. package/build/esm/__tests__/behavioral/GettingFieldsOffASchema.test.d.ts +0 -7
  28. package/build/esm/__tests__/behavioral/GettingFieldsOffASchema.test.js +0 -88
  29. package/build/esm/__tests__/behavioral/HandlesDynamicFields.test.d.ts +0 -17
  30. package/build/esm/__tests__/behavioral/HandlesDynamicFields.test.js +0 -284
  31. package/build/esm/__tests__/behavioral/HandlesHidingPrivateFields.test.d.ts +0 -11
  32. package/build/esm/__tests__/behavioral/HandlesHidingPrivateFields.test.js +0 -111
  33. package/build/esm/__tests__/behavioral/HandlesRelationships.test.d.ts +0 -9
  34. package/build/esm/__tests__/behavioral/HandlesRelationships.test.js +0 -175
  35. package/build/esm/__tests__/behavioral/HandlesRequiredFields.test.d.ts +0 -4
  36. package/build/esm/__tests__/behavioral/HandlesRequiredFields.test.js +0 -37
  37. package/build/esm/__tests__/behavioral/HandlesVersionedRelationships.test.d.ts +0 -6
  38. package/build/esm/__tests__/behavioral/HandlesVersionedRelationships.test.js +0 -102
  39. package/build/esm/__tests__/behavioral/HandlesVersioning.test.d.ts +0 -8
  40. package/build/esm/__tests__/behavioral/HandlesVersioning.test.js +0 -93
  41. package/build/esm/__tests__/behavioral/IsIdWithVersion.test.d.ts +0 -4
  42. package/build/esm/__tests__/behavioral/IsIdWithVersion.test.js +0 -30
  43. package/build/esm/__tests__/behavioral/MakingFieldsOptional.test.d.ts +0 -4
  44. package/build/esm/__tests__/behavioral/MakingFieldsOptional.test.js +0 -57
  45. package/build/esm/__tests__/behavioral/NormalizeToSchemaIdWithVersion.test.d.ts +0 -6
  46. package/build/esm/__tests__/behavioral/NormalizeToSchemaIdWithVersion.test.js +0 -77
  47. package/build/esm/__tests__/behavioral/NormalizingSchemaValues.test.d.ts +0 -8
  48. package/build/esm/__tests__/behavioral/NormalizingSchemaValues.test.js +0 -148
  49. package/build/esm/__tests__/behavioral/ResetsSchemasEveryTest.test.d.ts +0 -6
  50. package/build/esm/__tests__/behavioral/ResetsSchemasEveryTest.test.js +0 -45
  51. package/build/esm/__tests__/behavioral/SchemaDefaultValues.test.d.ts +0 -9
  52. package/build/esm/__tests__/behavioral/SchemaDefaultValues.test.js +0 -138
  53. package/build/esm/__tests__/behavioral/SelectChoicesToHash.test.d.ts +0 -4
  54. package/build/esm/__tests__/behavioral/SelectChoicesToHash.test.js +0 -43
  55. package/build/esm/__tests__/behavioral/SettingMinAndMaxValuesOnArrayFields.test.d.ts +0 -9
  56. package/build/esm/__tests__/behavioral/SettingMinAndMaxValuesOnArrayFields.test.js +0 -104
  57. package/build/esm/__tests__/behavioral/UsingSchemas.test.d.ts +0 -13
  58. package/build/esm/__tests__/behavioral/UsingSchemas.test.js +0 -281
  59. package/build/esm/__tests__/behavioral/UsingTheSchemaRegisteryForNamespacedSchemas.test.d.ts +0 -14
  60. package/build/esm/__tests__/behavioral/UsingTheSchemaRegisteryForNamespacedSchemas.test.js +0 -140
  61. package/build/esm/__tests__/behavioral/UsingTheSchemaRegistry.test.d.ts +0 -15
  62. package/build/esm/__tests__/behavioral/UsingTheSchemaRegistry.test.js +0 -117
  63. package/build/esm/__tests__/behavioral/ValidatingSchemaValues.test.d.ts +0 -28
  64. package/build/esm/__tests__/behavioral/ValidatingSchemaValues.test.js +0 -674
  65. package/build/esm/__tests__/data/personWithCars.d.ts +0 -188
  66. package/build/esm/__tests__/data/personWithCars.js +0 -163
  67. package/build/esm/__tests__/data/versionedPersonWithCars.d.ts +0 -323
  68. package/build/esm/__tests__/data/versionedPersonWithCars.js +0 -281
  69. package/build/esm/__tests__/implementation/BooleanField.test.d.ts +0 -6
  70. package/build/esm/__tests__/implementation/BooleanField.test.js +0 -59
  71. package/build/esm/__tests__/implementation/DurationField.test.d.ts +0 -7
  72. package/build/esm/__tests__/implementation/DurationField.test.js +0 -45
  73. package/build/esm/__tests__/implementation/EmailField.test.d.ts +0 -4
  74. package/build/esm/__tests__/implementation/EmailField.test.js +0 -39
  75. package/build/esm/__tests__/implementation/ErrorMapUtil.test.d.ts +0 -11
  76. package/build/esm/__tests__/implementation/ErrorMapUtil.test.js +0 -176
  77. package/build/esm/__tests__/implementation/FieldFactory.test.d.ts +0 -4
  78. package/build/esm/__tests__/implementation/FieldFactory.test.js +0 -35
  79. package/build/esm/__tests__/implementation/FileField.test.d.ts +0 -19
  80. package/build/esm/__tests__/implementation/FileField.test.js +0 -125
  81. package/build/esm/__tests__/implementation/NumberField.test.d.ts +0 -5
  82. package/build/esm/__tests__/implementation/NumberField.test.js +0 -54
  83. package/build/esm/__tests__/implementation/PhoneField.test.d.ts +0 -7
  84. package/build/esm/__tests__/implementation/PhoneField.test.js +0 -82
  85. package/build/esm/__tests__/implementation/SchemaFieldTransformingOptions.test.d.ts +0 -5
  86. package/build/esm/__tests__/implementation/SchemaFieldTransformingOptions.test.js +0 -209
  87. package/build/esm/__tests__/implementation/SchemaFieldValidation.test.d.ts +0 -8
  88. package/build/esm/__tests__/implementation/SchemaFieldValidation.test.js +0 -87
  89. package/build/esm/__tests__/implementation/SelectField.test.d.ts +0 -8
  90. package/build/esm/__tests__/implementation/SelectField.test.js +0 -127
  91. package/build/esm/__tests__/implementation/TextField.test.d.ts +0 -4
  92. package/build/esm/__tests__/implementation/TextField.test.js +0 -34
  93. package/build/esm/__tests__/implementation/ValidateErrorMessageFormatter.test.d.ts +0 -16
  94. package/build/esm/__tests__/implementation/ValidateErrorMessageFormatter.test.js +0 -216
@@ -1,4 +1,4 @@
1
- import { FieldMap } from "./../.spruce/schemas/fields/fields.types";
1
+ import { FieldMap } from "./.spruce/schemas/fields/fields.types";
2
2
  import AbstractEntity from './AbstractEntity';
3
3
  import { FieldDefinitionValueType, Field, FieldDefinition } from './fields/field.static.types';
4
4
  import { DynamicSchemaAllValues, DynamicSchemaPartialValues, DynamicSchemaEntityByName, DynamicSchemaGetValuesOptions, DynamicSchemaNamedFieldsOptions, Schema, DynamicSchemaNamedField, SchemaNormalizeOptions, DynamicSchemaValidateOptions, DynamicSchemaNormalizeOptions } from './schemas.static.types';
@@ -1,4 +1,4 @@
1
- import { FieldDefinitions } from "./../../.spruce/schemas/fields/fields.types";
1
+ import { FieldDefinitions } from "./../.spruce/schemas/fields/fields.types";
2
2
  import { FieldError } from '../errors/options.types';
3
3
  import { FieldTemplateDetails, FieldTemplateDetailOptions } from '../types/template.types';
4
4
  import { ValidateOptions, Field } from './field.static.types';
@@ -1,4 +1,4 @@
1
- import { FieldDefinitions, FieldMap, FieldValueTypeGeneratorMap } from "./../../.spruce/schemas/fields/fields.types";
1
+ import { FieldDefinitions, FieldMap, FieldValueTypeGeneratorMap } from "./../.spruce/schemas/fields/fields.types";
2
2
  import { FieldError } from '../errors/options.types';
3
3
  import { Schema, SchemaValues, StaticSchemaEntity } from '../schemas.static.types';
4
4
  import { Unpack, IsArray, IsRequired } from '../types/utilities.types';
@@ -1,4 +1,4 @@
1
- import { FieldDefinitions, Fields, FieldDefinitionMap, FieldMap } from "./../.spruce/schemas/fields/fields.types";
1
+ import { FieldDefinitions, Fields, FieldDefinitionMap, FieldMap } from "./.spruce/schemas/fields/fields.types";
2
2
  import { FieldDefinition, FieldDefinitionValueType, Field, FieldType } from './fields/field.static.types';
3
3
  export interface SchemaEntity {
4
4
  schemaId: string;
@@ -1,4 +1,4 @@
1
- import { Fields, FieldDefinitionMap } from "./../../.spruce/schemas/fields/fields.types";
1
+ import { Fields, FieldDefinitionMap } from "./../.spruce/schemas/fields/fields.types";
2
2
  import { FieldDefinitionValueType } from '../fields';
3
3
  import { SchemasById } from '../fields/field.static.types';
4
4
  import { SchemaNormalizeFieldValueOptions } from '../schemas.static.types';
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "25.5.63",
11
+ "version": "25.5.67",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",
@@ -33,14 +33,15 @@
33
33
  "scripts": {
34
34
  "build.ci": "yarn build.tsc && yarn build.resolve-paths && yarn lint",
35
35
  "build.dev": "yarn build.tsc --sourceMap ; yarn resolve-paths.lint",
36
- "build.dist": "yarn build.tsc && tsc --project tsconfig.dist.json && yarn build.resolve-paths && yarn build.esm-postbuild",
37
- "build.tsc": "tsc",
36
+ "build.dist": "tsc --project tsconfig.dist.json && yarn build.resolve-paths && mv build esm && yarn build.esm-postbuild && yarn build.tsc && yarn build.resolve-paths && mv esm build/ && yarn clean.dist",
37
+ "build.esm-postbuild": "esm-postbuild --target esm --patterns '**/*.js'",
38
38
  "build.resolve-paths": "resolve-path-aliases --target build --patterns '**/*.js,**/*.d.ts'",
39
- "build.esm-postbuild": "esm-postbuild --target build/esm --patterns '**/*.js'",
39
+ "build.tsc": "tsc",
40
40
  "clean": "yarn clean.build",
41
41
  "clean.all": "yarn clean.dependencies && yarn clean.build",
42
42
  "clean.build": "rm -rf build/",
43
43
  "clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
44
+ "clean.dist": "rm -rf build/__tests__ build/esm/__tests__",
44
45
  "fix.lint": "eslint --fix --cache '**/*.ts'",
45
46
  "lint": "eslint --cache '**/*.ts'",
46
47
  "lint.tsc": "tsc -p . --noEmit",
@@ -60,29 +61,29 @@
60
61
  "build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/"
61
62
  },
62
63
  "dependencies": {
63
- "@sprucelabs/error": "^5.0.364",
64
- "@sprucelabs/test": "^7.7.268",
64
+ "@sprucelabs/error": "^5.0.367",
65
+ "@sprucelabs/test": "^7.7.270",
65
66
  "email-validator": "^2.0.4",
66
67
  "lodash": "^4.17.21",
67
68
  "mime-db": "^1.51.0",
68
69
  "mime-type": "^4.0.0"
69
70
  },
70
71
  "devDependencies": {
71
- "@sprucelabs/esm-postbuild": "^1.0.319",
72
- "@sprucelabs/jest-json-reporter": "^6.0.301",
73
- "@sprucelabs/jest-sheets-reporter": "^1.2.298",
74
- "@sprucelabs/resolve-path-aliases": "^1.0.249",
72
+ "@sprucelabs/esm-postbuild": "^1.0.321",
73
+ "@sprucelabs/jest-json-reporter": "^6.0.303",
74
+ "@sprucelabs/jest-sheets-reporter": "^1.2.299",
75
+ "@sprucelabs/resolve-path-aliases": "^1.0.250",
75
76
  "@sprucelabs/semantic-release": "^4.0.8",
76
- "@sprucelabs/spruce-test-fixtures": "^20.1.14",
77
- "@sprucelabs/test-utils": "^3.0.366",
77
+ "@sprucelabs/spruce-test-fixtures": "^20.1.15",
78
+ "@sprucelabs/test-utils": "^3.0.369",
78
79
  "@types/lodash": "^4.14.178",
79
80
  "@types/mime-db": "^1.43.1",
80
81
  "chokidar-cli": "^3.0.0",
81
82
  "concurrently": "^7.0.0",
82
83
  "eslint": "^8.6.0",
83
84
  "eslint-config-spruce": "^10.11.0",
84
- "jest": "^27.4.5",
85
- "jest-circus": "^27.4.5",
85
+ "jest": "^27.4.6",
86
+ "jest-circus": "^27.4.6",
86
87
  "prettier": "^2.5.1",
87
88
  "ts-node": "^10.4.0",
88
89
  "tsc-watch": "^4.6.0",
@@ -1,7 +0,0 @@
1
- import AbstractSpruceTest from '@sprucelabs/test';
2
- export default class AssertingSelectOptionsTest extends AbstractSpruceTest {
3
- protected static canCreateAssertSelectOptions(): void;
4
- protected static knowsIfChoicesDontMatch(choices: any, expected: any): void;
5
- protected static knowsIfSingeOptionMatches(options: any, expected: any): void;
6
- protected static canType(): void;
7
- }
@@ -1,93 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import AbstractSpruceTest, { test, assert } from '@sprucelabs/test';
8
- import selectAssertUtil from '../../tests/selectAssert.utility.js';
9
- export default class AssertingSelectOptionsTest extends AbstractSpruceTest {
10
- static canCreateAssertSelectOptions() {
11
- assert.isFunction(selectAssertUtil.assertSelectChoicesMatch);
12
- }
13
- static knowsIfChoicesDontMatch(choices, expected) {
14
- assert.doesThrow(() => selectAssertUtil.assertSelectChoicesMatch(choices, expected));
15
- }
16
- static knowsIfSingeOptionMatches(options, expected) {
17
- selectAssertUtil.assertSelectChoicesMatch(options, expected);
18
- }
19
- static canType() {
20
- selectAssertUtil.assertSelectChoicesMatch([
21
- {
22
- value: 'hello',
23
- label: 'World!',
24
- },
25
- {
26
- value: 'no',
27
- label: 'Way',
28
- },
29
- ], ['hello', 'no']);
30
- }
31
- }
32
- __decorate([
33
- test()
34
- ], AssertingSelectOptionsTest, "canCreateAssertSelectOptions", null);
35
- __decorate([
36
- test('throws if single option does not match', [
37
- {
38
- value: 'hello',
39
- label: 'World!',
40
- },
41
- ], ['no']),
42
- test('throws if choices outnumber expected does not match', [
43
- {
44
- value: 'hello',
45
- label: 'World!',
46
- },
47
- {
48
- value: 'no',
49
- label: 'way!',
50
- },
51
- ], ['no']),
52
- test('throws if not all choices match', [
53
- {
54
- value: 'hello',
55
- label: 'World!',
56
- },
57
- {
58
- value: 'no',
59
- label: 'way!',
60
- },
61
- ], ['no', 'word'])
62
- ], AssertingSelectOptionsTest, "knowsIfChoicesDontMatch", null);
63
- __decorate([
64
- test('matches single choices', [
65
- {
66
- value: 'hello',
67
- label: 'World!',
68
- },
69
- ], ['hello']),
70
- test('matches in order', [
71
- {
72
- value: 'hello',
73
- label: 'World!',
74
- },
75
- {
76
- value: 'no',
77
- label: 'Way',
78
- },
79
- ], ['hello', 'no']),
80
- test('matches out of order', [
81
- {
82
- value: 'hello',
83
- label: 'World!',
84
- },
85
- {
86
- value: 'no',
87
- label: 'Way',
88
- },
89
- ], ['no', 'hello'])
90
- ], AssertingSelectOptionsTest, "knowsIfSingeOptionMatches", null);
91
- __decorate([
92
- test('is typed correctly (will always pass)')
93
- ], AssertingSelectOptionsTest, "canType", null);
@@ -1,18 +0,0 @@
1
- import AbstractSpruceTest from '@sprucelabs/test';
2
- import { FieldErrorCode } from '../../errors/options.types';
3
- import { ValidationErrorAssertOptionsKey } from '../../tests/validationErrorAssert.utility';
4
- export default class AssertingValidationErrorsTest extends AbstractSpruceTest {
5
- protected static canCreateAssertingValidationErrors(): void;
6
- protected static throwsWhenMissingErrorAndOptions(): void;
7
- protected static throwsWhenMissingOptions(): void;
8
- protected static throwsWhenNotGettingSpruceError(): void;
9
- protected static passesWhenJustReturnedError(): void;
10
- protected static failsWhenMissingNotFound(): void;
11
- protected static failsWhenMissingNotFoundWithOtherErrors(): void;
12
- protected static failsWhenMissingIsNamedDifferently(): void;
13
- protected static failsWhenOneOfTwoMatches(code: FieldErrorCode, key: ValidationErrorAssertOptionsKey, search: RegExp): void;
14
- protected static matches(code: FieldErrorCode, key: ValidationErrorAssertOptionsKey): void;
15
- protected static throwsWhenCodeMissmatches(): void;
16
- protected static matchesNestedParameters(): void;
17
- protected static throwWhenMissingOnNested(): void;
18
- }
@@ -1,217 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import AbstractSpruceTest, { test, assert } from '@sprucelabs/test';
8
- import { errorAssertUtil } from '@sprucelabs/test-utils';
9
- import SpruceError from '../../errors/SpruceError.js';
10
- import validationErrorAssertUtil from '../../tests/validationErrorAssert.utility.js';
11
- export default class AssertingValidationErrorsTest extends AbstractSpruceTest {
12
- static canCreateAssertingValidationErrors() {
13
- assert.isFunction(validationErrorAssertUtil.assertError);
14
- }
15
- static throwsWhenMissingErrorAndOptions() {
16
- const err = assert.doesThrow(
17
- //@ts-ignore
18
- () => validationErrorAssertUtil.assertError());
19
- errorAssertUtil.assertError(err, 'MISSING_PARAMETERS', {
20
- parameters: ['error', 'options'],
21
- });
22
- }
23
- static throwsWhenMissingOptions() {
24
- const err = assert.doesThrow(
25
- //@ts-ignore
26
- () => validationErrorAssertUtil.assertError(new Error('test')));
27
- errorAssertUtil.assertError(err, 'MISSING_PARAMETERS', {
28
- parameters: ['options'],
29
- });
30
- }
31
- static throwsWhenNotGettingSpruceError() {
32
- const err = assert.doesThrow(() =>
33
- //@ts-ignore
34
- validationErrorAssertUtil.assertError(new Error('test'), {
35
- missing: [],
36
- }));
37
- errorAssertUtil.assertError(err, 'INVALID_PARAMETERS', {
38
- parameters: ['error'],
39
- });
40
- }
41
- static passesWhenJustReturnedError() {
42
- validationErrorAssertUtil.assertError(new SpruceError({
43
- code: 'VALIDATION_FAILED',
44
- schemaId: 'person',
45
- errors: [
46
- {
47
- code: 'MISSING_PARAMETER',
48
- name: 'test',
49
- },
50
- ],
51
- }), {
52
- missing: ['test'],
53
- });
54
- }
55
- static failsWhenMissingNotFound() {
56
- assert.doesThrow(() => validationErrorAssertUtil.assertError(new SpruceError({
57
- code: 'VALIDATION_FAILED',
58
- schemaId: 'person',
59
- errors: [],
60
- }), {
61
- missing: ['test'],
62
- }), /missing.*?test/gis);
63
- }
64
- static failsWhenMissingNotFoundWithOtherErrors() {
65
- assert.doesThrow(() => validationErrorAssertUtil.assertError(new SpruceError({
66
- code: 'VALIDATION_FAILED',
67
- schemaId: 'person',
68
- errors: [
69
- {
70
- code: 'INVALID_PARAMETER',
71
- name: 'taco',
72
- },
73
- ],
74
- }), {
75
- missing: ['test'],
76
- }), /missing.*?test/gis);
77
- }
78
- static failsWhenMissingIsNamedDifferently() {
79
- assert.doesThrow(() => validationErrorAssertUtil.assertError(new SpruceError({
80
- code: 'VALIDATION_FAILED',
81
- schemaId: 'person',
82
- errors: [
83
- {
84
- code: 'MISSING_PARAMETER',
85
- name: 'taco',
86
- },
87
- ],
88
- }), {
89
- missing: ['cheesy'],
90
- }), /missing|cheesy/gis);
91
- }
92
- static failsWhenOneOfTwoMatches(code, key, search) {
93
- assert.doesThrow(() => validationErrorAssertUtil.assertError(new SpruceError({
94
- code: 'VALIDATION_FAILED',
95
- schemaId: 'person',
96
- errors: [
97
- {
98
- code,
99
- name: 'taco',
100
- },
101
- ],
102
- }), {
103
- [key]: ['taco', 'cheesy'],
104
- }), search);
105
- }
106
- static matches(code, key) {
107
- validationErrorAssertUtil.assertError(new SpruceError({
108
- code: 'VALIDATION_FAILED',
109
- schemaId: 'person',
110
- errors: [
111
- {
112
- code,
113
- name: 'test',
114
- },
115
- ],
116
- }), {
117
- [key]: ['test'],
118
- });
119
- }
120
- static throwsWhenCodeMissmatches() {
121
- assert.doesThrow(() => validationErrorAssertUtil.assertError(new SpruceError({
122
- code: 'VALIDATION_FAILED',
123
- schemaId: 'person',
124
- errors: [
125
- {
126
- code: 'MISSING_PARAMETER',
127
- name: 'taco',
128
- },
129
- ],
130
- }), {
131
- invalid: ['taco'],
132
- }));
133
- }
134
- static matchesNestedParameters() {
135
- validationErrorAssertUtil.assertError(new SpruceError({
136
- code: 'VALIDATION_FAILED',
137
- schemaId: 'person',
138
- errors: [
139
- {
140
- code: 'INVALID_PARAMETER',
141
- name: 'test',
142
- errors: [
143
- {
144
- code: 'MISSING_PARAMETER',
145
- name: 'turkey',
146
- },
147
- ],
148
- },
149
- ],
150
- }), {
151
- missing: ['test.turkey'],
152
- });
153
- }
154
- static throwWhenMissingOnNested() {
155
- assert.doesThrow(() => validationErrorAssertUtil.assertError(new SpruceError({
156
- code: 'VALIDATION_FAILED',
157
- schemaId: 'person',
158
- errors: [
159
- {
160
- code: 'INVALID_PARAMETER',
161
- name: 'taco',
162
- errors: [
163
- {
164
- code: 'UNEXPECTED_PARAMETER',
165
- name: 'bravo',
166
- },
167
- ],
168
- },
169
- ],
170
- }), {
171
- invalid: ['taco.bravo'],
172
- }));
173
- }
174
- }
175
- __decorate([
176
- test()
177
- ], AssertingValidationErrorsTest, "canCreateAssertingValidationErrors", null);
178
- __decorate([
179
- test()
180
- ], AssertingValidationErrorsTest, "throwsWhenMissingErrorAndOptions", null);
181
- __decorate([
182
- test()
183
- ], AssertingValidationErrorsTest, "throwsWhenMissingOptions", null);
184
- __decorate([
185
- test()
186
- ], AssertingValidationErrorsTest, "throwsWhenNotGettingSpruceError", null);
187
- __decorate([
188
- test()
189
- ], AssertingValidationErrorsTest, "passesWhenJustReturnedError", null);
190
- __decorate([
191
- test()
192
- ], AssertingValidationErrorsTest, "failsWhenMissingNotFound", null);
193
- __decorate([
194
- test()
195
- ], AssertingValidationErrorsTest, "failsWhenMissingNotFoundWithOtherErrors", null);
196
- __decorate([
197
- test()
198
- ], AssertingValidationErrorsTest, "failsWhenMissingIsNamedDifferently", null);
199
- __decorate([
200
- test('fails when matches only 1 missing', 'MISSING_PARAMETER', 'missing', /missing|cheesy/),
201
- test('fails when matches only 1 invalid', 'INVALID_PARAMETER', 'invalid', /invalid|cheesy/),
202
- test('fails when matches only 1 unexpected', 'UNEXPECTED_PARAMETER', 'unexpected', /unexpected.*?cheesy/)
203
- ], AssertingValidationErrorsTest, "failsWhenOneOfTwoMatches", null);
204
- __decorate([
205
- test('matching missing', 'MISSING_PARAMETER', 'missing'),
206
- test('matching invalid', 'INVALID_PARAMETER', 'invalid'),
207
- test('matching unexpected', 'UNEXPECTED_PARAMETER', 'unexpected')
208
- ], AssertingValidationErrorsTest, "matches", null);
209
- __decorate([
210
- test()
211
- ], AssertingValidationErrorsTest, "throwsWhenCodeMissmatches", null);
212
- __decorate([
213
- test()
214
- ], AssertingValidationErrorsTest, "matchesNestedParameters", null);
215
- __decorate([
216
- test()
217
- ], AssertingValidationErrorsTest, "throwWhenMissingOnNested", null);
@@ -1,5 +0,0 @@
1
- import AbstractSpruceTest from '@sprucelabs/test';
2
- export default class BuildSchemaTest extends AbstractSpruceTest {
3
- protected static testBasicSchemaBuilding(): Promise<void>;
4
- protected static testBuiltSchemaType(): Promise<void>;
5
- }
@@ -1,66 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- // TODO figure out how to get schema field mixins working from buildSchema (SchemaDefinitionValues fails)
17
- import AbstractSpruceTest, { test, assert } from '@sprucelabs/test';
18
- import buildSchema from '../../utilities/buildSchema.js';
19
- export default class BuildSchemaTest extends AbstractSpruceTest {
20
- static testBasicSchemaBuilding() {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const schema = buildSchema({
23
- id: 'test-1',
24
- name: 'test 1',
25
- fields: {
26
- firstName: {
27
- type: 'text',
28
- },
29
- },
30
- });
31
- assert.isTruthy(schema);
32
- assert.isTruthy(schema.fields.firstName);
33
- });
34
- }
35
- static testBuiltSchemaType() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const schema = buildSchema({
38
- id: 'test-2',
39
- name: 'test two',
40
- fields: {
41
- skillName: {
42
- type: 'text',
43
- label: 'Name',
44
- isRequired: true,
45
- hint: "What's the name of your skill?",
46
- },
47
- description: {
48
- type: 'text',
49
- label: 'Description',
50
- isRequired: true,
51
- hint: 'How would you describe your skill?',
52
- },
53
- },
54
- });
55
- const test = (def) => def;
56
- test(schema);
57
- test(schema);
58
- });
59
- }
60
- }
61
- __decorate([
62
- test()
63
- ], BuildSchemaTest, "testBasicSchemaBuilding", null);
64
- __decorate([
65
- test()
66
- ], BuildSchemaTest, "testBuiltSchemaType", null);
@@ -1,7 +0,0 @@
1
- import AbstractSchemaTest from '../../AbstractSchemaTest';
2
- export default class CreatingEntityInstancesTest extends AbstractSchemaTest {
3
- protected static canCreateStaticEntity(): Promise<void>;
4
- protected static typesStaticEntity(): Promise<void>;
5
- protected static canCreateDynamicEntity(): Promise<void>;
6
- protected static typesDynamicEntity(): Promise<void>;
7
- }
@@ -1,93 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- import { test, assert } from '@sprucelabs/test';
17
- import AbstractSchemaTest from '../../AbstractSchemaTest.js';
18
- import DynamicSchemaEntityImplementation from '../../DynamicSchemaEntityImplementation.js';
19
- import EntityFactory from '../../factories/SchemaEntityFactory.js';
20
- import StaticSchemaEntityImplementation from '../../StaticSchemaEntityImplementation.js';
21
- export default class CreatingEntityInstancesTest extends AbstractSchemaTest {
22
- static canCreateStaticEntity() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const instance = EntityFactory.Entity({
25
- id: 'staticPerson',
26
- fields: {
27
- firstName: {
28
- type: 'text',
29
- isRequired: true,
30
- },
31
- },
32
- });
33
- assert.isTrue(instance instanceof StaticSchemaEntityImplementation);
34
- });
35
- }
36
- static typesStaticEntity() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const instance = EntityFactory.Entity({
39
- id: 'staticPerson',
40
- fields: {
41
- firstName: {
42
- type: 'text',
43
- isRequired: true,
44
- },
45
- },
46
- }, {
47
- firstName: 'Tay tay',
48
- });
49
- const values = instance.getValues();
50
- assert.isExactType(true);
51
- });
52
- }
53
- static canCreateDynamicEntity() {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- const instance = EntityFactory.Entity({
56
- id: 'staticPerson',
57
- dynamicFieldSignature: {
58
- type: 'boolean',
59
- keyName: 'key',
60
- },
61
- });
62
- assert.isTrue(instance instanceof DynamicSchemaEntityImplementation);
63
- });
64
- }
65
- static typesDynamicEntity() {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const instance = EntityFactory.Entity({
68
- id: 'staticPerson',
69
- dynamicFieldSignature: {
70
- type: 'boolean',
71
- keyName: 'key',
72
- },
73
- }, {
74
- pass: true,
75
- youSure: false,
76
- });
77
- const values = instance.getValues();
78
- assert.isExactType(true);
79
- });
80
- }
81
- }
82
- __decorate([
83
- test()
84
- ], CreatingEntityInstancesTest, "canCreateStaticEntity", null);
85
- __decorate([
86
- test()
87
- ], CreatingEntityInstancesTest, "typesStaticEntity", null);
88
- __decorate([
89
- test()
90
- ], CreatingEntityInstancesTest, "canCreateDynamicEntity", null);
91
- __decorate([
92
- test()
93
- ], CreatingEntityInstancesTest, "typesDynamicEntity", null);
@@ -1,5 +0,0 @@
1
- import AbstractSchemaTest from '../../AbstractSchemaTest';
2
- export default class DroppingFieldsTest extends AbstractSchemaTest {
3
- protected static droppingFields(): Promise<void>;
4
- protected static droppingPrivateFields(): Promise<void>;
5
- }