@sprucelabs/schema 32.0.48 → 32.1.1
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/fields/FileField.types.d.ts +1 -0
- package/build/esm/fields/ImageField.types.d.ts +1 -0
- package/build/esm/singletons/SchemaRegistry.d.ts +4 -1
- package/build/esm/singletons/SchemaRegistry.js +9 -2
- package/build/fields/FileField.types.d.ts +1 -0
- package/build/fields/ImageField.types.d.ts +1 -0
- package/build/singletons/SchemaRegistry.d.ts +4 -1
- package/build/singletons/SchemaRegistry.js +9 -2
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ export declare const supportedFileTypes: readonly ["image/png", "image/svg+xml",
|
|
|
3
3
|
export type SupportedFileType = (typeof supportedFileTypes)[number];
|
|
4
4
|
export interface FileFieldValue {
|
|
5
5
|
name: string;
|
|
6
|
+
id?: string;
|
|
6
7
|
type?: SupportedFileType;
|
|
7
8
|
uri?: string;
|
|
8
9
|
base64?: string;
|
|
@@ -11,6 +11,7 @@ export declare const requiredImageSizes: readonly ["s", "m", "l", "xl", "*"];
|
|
|
11
11
|
export type RequiredImageSize = (typeof requiredImageSizes)[number];
|
|
12
12
|
export interface ImageFieldValue {
|
|
13
13
|
name: string;
|
|
14
|
+
id?: string;
|
|
14
15
|
base64?: string;
|
|
15
16
|
type?: SupportedFileType;
|
|
16
17
|
sUri?: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Schema } from '../schemas.static.types';
|
|
2
2
|
export default class SchemaRegistry {
|
|
3
3
|
private schemasById;
|
|
4
|
-
private static instance
|
|
4
|
+
private static instance?;
|
|
5
|
+
private shouldTrack;
|
|
6
|
+
constructor(shouldTrack?: boolean);
|
|
5
7
|
static getInstance(): SchemaRegistry;
|
|
6
8
|
trackSchema(schema: Schema): void;
|
|
7
9
|
isTrackingSchema(id: string, version?: string, namespace?: string): boolean;
|
|
@@ -12,4 +14,5 @@ export default class SchemaRegistry {
|
|
|
12
14
|
private getSchemaNotThrowing;
|
|
13
15
|
private isTrackedById;
|
|
14
16
|
forgetSchema(id: string, version?: string): void;
|
|
17
|
+
static reset(): void;
|
|
15
18
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import SpruceError from '../errors/SpruceError.js';
|
|
2
2
|
import validateSchema from '../utilities/validateSchema.js';
|
|
3
3
|
export default class SchemaRegistry {
|
|
4
|
-
constructor() {
|
|
4
|
+
constructor(shouldTrack = true) {
|
|
5
5
|
this.schemasById = {};
|
|
6
|
+
this.shouldTrack = shouldTrack;
|
|
6
7
|
}
|
|
7
8
|
static getInstance() {
|
|
8
9
|
if (!this.instance) {
|
|
9
|
-
this.instance = new SchemaRegistry();
|
|
10
|
+
this.instance = new SchemaRegistry(process.env.SHOULD_USE_SCHEMA_REGISTRY !== 'false');
|
|
10
11
|
}
|
|
11
12
|
return this.instance;
|
|
12
13
|
}
|
|
13
14
|
trackSchema(schema) {
|
|
15
|
+
if (!this.shouldTrack) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
14
18
|
validateSchema(schema);
|
|
15
19
|
const id = schema.id;
|
|
16
20
|
if (!this.schemasById[id]) {
|
|
@@ -85,4 +89,7 @@ export default class SchemaRegistry {
|
|
|
85
89
|
delete this.schemasById[id];
|
|
86
90
|
}
|
|
87
91
|
}
|
|
92
|
+
static reset() {
|
|
93
|
+
delete this.instance;
|
|
94
|
+
}
|
|
88
95
|
}
|
|
@@ -3,6 +3,7 @@ export declare const supportedFileTypes: readonly ["image/png", "image/svg+xml",
|
|
|
3
3
|
export type SupportedFileType = (typeof supportedFileTypes)[number];
|
|
4
4
|
export interface FileFieldValue {
|
|
5
5
|
name: string;
|
|
6
|
+
id?: string;
|
|
6
7
|
type?: SupportedFileType;
|
|
7
8
|
uri?: string;
|
|
8
9
|
base64?: string;
|
|
@@ -11,6 +11,7 @@ export declare const requiredImageSizes: readonly ["s", "m", "l", "xl", "*"];
|
|
|
11
11
|
export type RequiredImageSize = (typeof requiredImageSizes)[number];
|
|
12
12
|
export interface ImageFieldValue {
|
|
13
13
|
name: string;
|
|
14
|
+
id?: string;
|
|
14
15
|
base64?: string;
|
|
15
16
|
type?: SupportedFileType;
|
|
16
17
|
sUri?: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Schema } from '../schemas.static.types';
|
|
2
2
|
export default class SchemaRegistry {
|
|
3
3
|
private schemasById;
|
|
4
|
-
private static instance
|
|
4
|
+
private static instance?;
|
|
5
|
+
private shouldTrack;
|
|
6
|
+
constructor(shouldTrack?: boolean);
|
|
5
7
|
static getInstance(): SchemaRegistry;
|
|
6
8
|
trackSchema(schema: Schema): void;
|
|
7
9
|
isTrackingSchema(id: string, version?: string, namespace?: string): boolean;
|
|
@@ -12,4 +14,5 @@ export default class SchemaRegistry {
|
|
|
12
14
|
private getSchemaNotThrowing;
|
|
13
15
|
private isTrackedById;
|
|
14
16
|
forgetSchema(id: string, version?: string): void;
|
|
17
|
+
static reset(): void;
|
|
15
18
|
}
|
|
@@ -6,16 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
7
7
|
const validateSchema_1 = __importDefault(require("../utilities/validateSchema"));
|
|
8
8
|
class SchemaRegistry {
|
|
9
|
-
constructor() {
|
|
9
|
+
constructor(shouldTrack = true) {
|
|
10
10
|
this.schemasById = {};
|
|
11
|
+
this.shouldTrack = shouldTrack;
|
|
11
12
|
}
|
|
12
13
|
static getInstance() {
|
|
13
14
|
if (!this.instance) {
|
|
14
|
-
this.instance = new SchemaRegistry();
|
|
15
|
+
this.instance = new SchemaRegistry(process.env.SHOULD_USE_SCHEMA_REGISTRY !== 'false');
|
|
15
16
|
}
|
|
16
17
|
return this.instance;
|
|
17
18
|
}
|
|
18
19
|
trackSchema(schema) {
|
|
20
|
+
if (!this.shouldTrack) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
(0, validateSchema_1.default)(schema);
|
|
20
24
|
const id = schema.id;
|
|
21
25
|
if (!this.schemasById[id]) {
|
|
@@ -89,5 +93,8 @@ class SchemaRegistry {
|
|
|
89
93
|
delete this.schemasById[id];
|
|
90
94
|
}
|
|
91
95
|
}
|
|
96
|
+
static reset() {
|
|
97
|
+
delete this.instance;
|
|
98
|
+
}
|
|
92
99
|
}
|
|
93
100
|
exports.default = SchemaRegistry;
|