@sprucelabs/schema 30.0.8 → 30.0.10

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.
@@ -10,7 +10,7 @@ export default abstract class AbstractField<F extends FieldDefinitions> implemen
10
10
  /** The name of this field (camel case) */
11
11
  name: string;
12
12
  constructor(name: string, definition: F);
13
- static get description(): string;
13
+ static description: string;
14
14
  /** For mapping schemas to types dynamically in schema values */
15
15
  static generateTypeDetails(): {
16
16
  valueTypeMapper: string | undefined;
@@ -1,24 +1,13 @@
1
+ var _a;
1
2
  import SpruceError from '../errors/SpruceError.js';
2
3
  import isUndefinedOrNull from '../utilities/isUndefinedOrNull.js';
3
- export default class AbstractField {
4
+ class AbstractField {
4
5
  constructor(name, definition) {
5
6
  this.definition = definition;
6
7
  this.name = name;
7
8
  this.type = definition.type;
8
9
  return this;
9
10
  }
10
- static get description() {
11
- throw new SpruceError({
12
- code: 'NOT_IMPLEMENTED',
13
- instructions: `Copy and paste this into ${this.name}:
14
-
15
- public static get description() {
16
- return '*** describe your field here ***'
17
- }
18
-
19
- `,
20
- });
21
- }
22
11
  /** For mapping schemas to types dynamically in schema values */
23
12
  static generateTypeDetails() {
24
13
  return {
@@ -60,8 +49,8 @@ public static generateTemplateDetails(
60
49
  return this.definition.hint;
61
50
  }
62
51
  get minArrayLength() {
63
- var _a;
64
- return (_a = this.definition.minArrayLength) !== null && _a !== void 0 ? _a : 1;
52
+ var _b;
53
+ return (_b = this.definition.minArrayLength) !== null && _b !== void 0 ? _b : 1;
65
54
  }
66
55
  validate(value, _) {
67
56
  const errors = [];
@@ -79,3 +68,10 @@ public static generateTemplateDetails(
79
68
  return value;
80
69
  }
81
70
  }
71
+ _a = AbstractField;
72
+ AbstractField.description = `Please set the description for your field ${_a.name}:
73
+
74
+ public static description = '*** describe your field here ***'
75
+
76
+ `;
77
+ export default AbstractField;
@@ -1,8 +1,6 @@
1
1
  import AbstractEntity from '../AbstractEntity.js';
2
- import DynamicSchemaEntityImplementation from '../DynamicSchemaEntityImplementation.js';
3
2
  import SpruceError from '../errors/SpruceError.js';
4
3
  import SchemaRegistry from '../singletons/SchemaRegistry.js';
5
- import StaticSchemaEntity from '../StaticSchemaEntityImpl.js';
6
4
  import { TemplateRenderAs, } from '../types/template.types.js';
7
5
  import isIdWithVersion from '../utilities/isIdWithVersion.js';
8
6
  import normalizeSchemaToIdWithVersion from '../utilities/normalizeSchemaToIdWithVersion.js';
@@ -255,9 +253,10 @@ class SchemaField extends AbstractField {
255
253
  return errors;
256
254
  }
257
255
  Schema(schema, value) {
258
- return schema.dynamicFieldSignature
259
- ? new DynamicSchemaEntityImplementation(schema, value)
260
- : new StaticSchemaEntity(schema, value);
256
+ const Class = schema.dynamicFieldSignature
257
+ ? require('../DynamicSchemaEntityImplementation.js').default
258
+ : require('../StaticSchemaEntityImpl.js').default;
259
+ return new Class(schema, value);
261
260
  }
262
261
  toValueType(value, options) {
263
262
  const errors = this.validate(value, options);
@@ -10,7 +10,7 @@ export default abstract class AbstractField<F extends FieldDefinitions> implemen
10
10
  /** The name of this field (camel case) */
11
11
  name: string;
12
12
  constructor(name: string, definition: F);
13
- static get description(): string;
13
+ static description: string;
14
14
  /** For mapping schemas to types dynamically in schema values */
15
15
  static generateTypeDetails(): {
16
16
  valueTypeMapper: string | undefined;
@@ -18,18 +18,11 @@ class AbstractField {
18
18
  this.type = definition.type;
19
19
  return this;
20
20
  }
21
- static get description() {
22
- throw new SpruceError_1.default({
23
- code: 'NOT_IMPLEMENTED',
24
- instructions: `Copy and paste this into ${this.name}:
21
+ static description = `Please set the description for your field ${this.name}:
25
22
 
26
- public static get description() {
27
- return '*** describe your field here ***'
28
- }
29
-
30
- `,
31
- });
32
- }
23
+ public static description = '*** describe your field here ***'
24
+
25
+ `;
33
26
  /** For mapping schemas to types dynamically in schema values */
34
27
  static generateTypeDetails() {
35
28
  return {
@@ -4,10 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const AbstractEntity_1 = __importDefault(require("../AbstractEntity"));
7
- const DynamicSchemaEntityImplementation_1 = __importDefault(require("../DynamicSchemaEntityImplementation"));
8
7
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
9
8
  const SchemaRegistry_1 = __importDefault(require("../singletons/SchemaRegistry"));
10
- const StaticSchemaEntityImpl_1 = __importDefault(require("../StaticSchemaEntityImpl"));
11
9
  const template_types_1 = require("../types/template.types");
12
10
  const isIdWithVersion_1 = __importDefault(require("../utilities/isIdWithVersion"));
13
11
  const normalizeSchemaToIdWithVersion_1 = __importDefault(require("../utilities/normalizeSchemaToIdWithVersion"));
@@ -260,9 +258,10 @@ class SchemaField extends AbstractField_1.default {
260
258
  return errors;
261
259
  }
262
260
  Schema(schema, value) {
263
- return schema.dynamicFieldSignature
264
- ? new DynamicSchemaEntityImplementation_1.default(schema, value)
265
- : new StaticSchemaEntityImpl_1.default(schema, value);
261
+ const Class = schema.dynamicFieldSignature
262
+ ? require('../DynamicSchemaEntityImplementation').default
263
+ : require('../StaticSchemaEntityImpl').default;
264
+ return new Class(schema, value);
266
265
  }
267
266
  toValueType(value, options) {
268
267
  const errors = this.validate(value, options);
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "30.0.8",
11
+ "version": "30.0.10",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",