@sprucelabs/schema 28.0.2 → 28.0.5
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/AbstractField.d.ts +1 -1
- package/build/esm/fields/ImageField.d.ts +3 -2
- package/build/esm/fields/ImageField.js +5 -2
- package/build/esm/fields/ImageField.types.d.ts +8 -4
- package/build/esm/fields/ImageField.types.js +8 -10
- package/build/esm/index.js +2 -0
- package/build/fields/AbstractField.d.ts +1 -1
- package/build/fields/ImageField.d.ts +3 -2
- package/build/fields/ImageField.js +4 -1
- package/build/fields/ImageField.types.d.ts +8 -4
- package/build/fields/ImageField.types.js +8 -10
- package/build/index.js +2 -0
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ export default abstract class AbstractField<F extends FieldDefinitions> implemen
|
|
|
36
36
|
} | {
|
|
37
37
|
relativeTo?: string | undefined;
|
|
38
38
|
} | {
|
|
39
|
-
requiredSizes: ("s" | "*" | "
|
|
39
|
+
requiredSizes: ("s" | "*" | "m" | "l" | "xl")[];
|
|
40
40
|
} | undefined;
|
|
41
41
|
get isRequired(): boolean;
|
|
42
42
|
get isPrivate(): boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FieldTemplateDetailOptions, FieldTemplateDetails } from '../types/template.types';
|
|
2
2
|
import AbstractField from './AbstractField';
|
|
3
|
-
import { ImageFieldDefinition
|
|
3
|
+
import { ImageFieldDefinition } from './ImageField.types';
|
|
4
4
|
export default class ImageField extends AbstractField<ImageFieldDefinition> {
|
|
5
5
|
static generateTemplateDetails(options: FieldTemplateDetailOptions<ImageFieldDefinition>): FieldTemplateDetails;
|
|
6
|
-
|
|
6
|
+
static get description(): string;
|
|
7
|
+
validate(value: any): import("..").FieldError[];
|
|
7
8
|
private getRequiredSizes;
|
|
8
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AbstractField from './AbstractField.js';
|
|
2
|
-
import { requiredImageSizes
|
|
2
|
+
import { requiredImageSizes } from './ImageField.types.js';
|
|
3
3
|
export default class ImageField extends AbstractField {
|
|
4
4
|
static generateTemplateDetails(options) {
|
|
5
5
|
const { definition, importAs } = options;
|
|
@@ -7,10 +7,13 @@ export default class ImageField extends AbstractField {
|
|
|
7
7
|
valueType: `${importAs}.ImageFieldValue${definition.isArray ? '[]' : ''}`,
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
static get description() {
|
|
11
|
+
return 'Images of various sizes!';
|
|
12
|
+
}
|
|
10
13
|
validate(value) {
|
|
11
14
|
var _a;
|
|
12
15
|
const errors = super.validate(value);
|
|
13
|
-
if (errors.length === 0 && !value.base64) {
|
|
16
|
+
if (value && errors.length === 0 && !value.base64) {
|
|
14
17
|
let sizes = this.getRequiredSizes();
|
|
15
18
|
const missing = [];
|
|
16
19
|
for (const size of sizes) {
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { FieldDefinition } from './field.static.types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Min dimension for each size
|
|
4
|
+
xl: 1024
|
|
5
|
+
l: 500
|
|
6
|
+
m: 60
|
|
7
|
+
s: 30
|
|
8
|
+
*/
|
|
9
|
+
export declare const requiredImageSizes: readonly ["s", "m", "l", "xl", "*"];
|
|
3
10
|
export declare type RequiredImageSize = typeof requiredImageSizes[number];
|
|
4
11
|
export interface ImageFieldValue {
|
|
5
12
|
name: string;
|
|
6
13
|
base64?: string;
|
|
7
|
-
xxsUri?: string;
|
|
8
|
-
xsUri?: string;
|
|
9
14
|
sUri?: string;
|
|
10
15
|
mUri?: string;
|
|
11
16
|
lUri?: string;
|
|
12
17
|
xlUri?: string;
|
|
13
|
-
xxlUri?: string;
|
|
14
18
|
}
|
|
15
19
|
export declare type ImageFieldDefinition = FieldDefinition<ImageFieldValue> & {
|
|
16
20
|
/** * .image - a great way to deal with file management */
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'*',
|
|
10
|
-
];
|
|
1
|
+
/**
|
|
2
|
+
* Min dimension for each size
|
|
3
|
+
xl: 1024
|
|
4
|
+
l: 500
|
|
5
|
+
m: 60
|
|
6
|
+
s: 30
|
|
7
|
+
*/
|
|
8
|
+
export const requiredImageSizes = ['s', 'm', 'l', 'xl', '*'];
|
package/build/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import durationRegistration from './addons/durationField.addon.js';
|
|
|
8
8
|
import emailRegistration from './addons/emailField.addon.js';
|
|
9
9
|
import fileRegistration from './addons/fileField.addon.js';
|
|
10
10
|
import idRegistration from './addons/idField.addon.js';
|
|
11
|
+
import imageRegistration from './addons/imageField.addon.js';
|
|
11
12
|
import numberRegistration from './addons/numberField.addon.js';
|
|
12
13
|
import phoneRegistration from './addons/phoneField.addon.js';
|
|
13
14
|
import rawRegistration from './addons/rawField.addon.js';
|
|
@@ -64,6 +65,7 @@ export const fieldRegistrations = [
|
|
|
64
65
|
selectRegistration,
|
|
65
66
|
textRegistration,
|
|
66
67
|
emailRegistration,
|
|
68
|
+
imageRegistration,
|
|
67
69
|
];
|
|
68
70
|
export { default as assertOptions } from './utilities/assertOptions.js';
|
|
69
71
|
export { default as mapFieldErrorsToParameterErrors } from './utilities/mapFieldErrorsToParameterErrors.js';
|
|
@@ -36,7 +36,7 @@ export default abstract class AbstractField<F extends FieldDefinitions> implemen
|
|
|
36
36
|
} | {
|
|
37
37
|
relativeTo?: string | undefined;
|
|
38
38
|
} | {
|
|
39
|
-
requiredSizes: ("s" | "*" | "
|
|
39
|
+
requiredSizes: ("s" | "*" | "m" | "l" | "xl")[];
|
|
40
40
|
} | undefined;
|
|
41
41
|
get isRequired(): boolean;
|
|
42
42
|
get isPrivate(): boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FieldTemplateDetailOptions, FieldTemplateDetails } from '../types/template.types';
|
|
2
2
|
import AbstractField from './AbstractField';
|
|
3
|
-
import { ImageFieldDefinition
|
|
3
|
+
import { ImageFieldDefinition } from './ImageField.types';
|
|
4
4
|
export default class ImageField extends AbstractField<ImageFieldDefinition> {
|
|
5
5
|
static generateTemplateDetails(options: FieldTemplateDetailOptions<ImageFieldDefinition>): FieldTemplateDetails;
|
|
6
|
-
|
|
6
|
+
static get description(): string;
|
|
7
|
+
validate(value: any): import("..").FieldError[];
|
|
7
8
|
private getRequiredSizes;
|
|
8
9
|
}
|
|
@@ -12,10 +12,13 @@ class ImageField extends AbstractField_1.default {
|
|
|
12
12
|
valueType: `${importAs}.ImageFieldValue${definition.isArray ? '[]' : ''}`,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
static get description() {
|
|
16
|
+
return 'Images of various sizes!';
|
|
17
|
+
}
|
|
15
18
|
validate(value) {
|
|
16
19
|
var _a;
|
|
17
20
|
const errors = super.validate(value);
|
|
18
|
-
if (errors.length === 0 && !value.base64) {
|
|
21
|
+
if (value && errors.length === 0 && !value.base64) {
|
|
19
22
|
let sizes = this.getRequiredSizes();
|
|
20
23
|
const missing = [];
|
|
21
24
|
for (const size of sizes) {
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { FieldDefinition } from './field.static.types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Min dimension for each size
|
|
4
|
+
xl: 1024
|
|
5
|
+
l: 500
|
|
6
|
+
m: 60
|
|
7
|
+
s: 30
|
|
8
|
+
*/
|
|
9
|
+
export declare const requiredImageSizes: readonly ["s", "m", "l", "xl", "*"];
|
|
3
10
|
export declare type RequiredImageSize = typeof requiredImageSizes[number];
|
|
4
11
|
export interface ImageFieldValue {
|
|
5
12
|
name: string;
|
|
6
13
|
base64?: string;
|
|
7
|
-
xxsUri?: string;
|
|
8
|
-
xsUri?: string;
|
|
9
14
|
sUri?: string;
|
|
10
15
|
mUri?: string;
|
|
11
16
|
lUri?: string;
|
|
12
17
|
xlUri?: string;
|
|
13
|
-
xxlUri?: string;
|
|
14
18
|
}
|
|
15
19
|
export declare type ImageFieldDefinition = FieldDefinition<ImageFieldValue> & {
|
|
16
20
|
/** * .image - a great way to deal with file management */
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requiredImageSizes = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'*',
|
|
13
|
-
];
|
|
4
|
+
/**
|
|
5
|
+
* Min dimension for each size
|
|
6
|
+
xl: 1024
|
|
7
|
+
l: 500
|
|
8
|
+
m: 60
|
|
9
|
+
s: 30
|
|
10
|
+
*/
|
|
11
|
+
exports.requiredImageSizes = ['s', 'm', 'l', 'xl', '*'];
|
package/build/index.js
CHANGED
|
@@ -28,6 +28,7 @@ const durationField_addon_1 = __importDefault(require("./addons/durationField.ad
|
|
|
28
28
|
const emailField_addon_1 = __importDefault(require("./addons/emailField.addon"));
|
|
29
29
|
const fileField_addon_1 = __importDefault(require("./addons/fileField.addon"));
|
|
30
30
|
const idField_addon_1 = __importDefault(require("./addons/idField.addon"));
|
|
31
|
+
const imageField_addon_1 = __importDefault(require("./addons/imageField.addon"));
|
|
31
32
|
const numberField_addon_1 = __importDefault(require("./addons/numberField.addon"));
|
|
32
33
|
const phoneField_addon_1 = __importDefault(require("./addons/phoneField.addon"));
|
|
33
34
|
const rawField_addon_1 = __importDefault(require("./addons/rawField.addon"));
|
|
@@ -107,6 +108,7 @@ exports.fieldRegistrations = [
|
|
|
107
108
|
selectField_addon_1.default,
|
|
108
109
|
textField_addon_1.default,
|
|
109
110
|
emailField_addon_1.default,
|
|
111
|
+
imageField_addon_1.default,
|
|
110
112
|
];
|
|
111
113
|
var assertOptions_1 = require("./utilities/assertOptions");
|
|
112
114
|
Object.defineProperty(exports, "assertOptions", { enumerable: true, get: function () { return __importDefault(assertOptions_1).default; } });
|