@aemforms/af-core 0.22.31 → 0.22.33
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/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +6 -6
- package/lib/{esm/BaseNode-f84b22c6.js → BaseNode.js} +58 -94
- package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
- package/lib/Checkbox.js +29 -0
- package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
- package/lib/CheckboxGroup.js +24 -0
- package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
- package/lib/{esm/Container.js → Container.js} +51 -77
- package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
- package/lib/DateField.js +26 -0
- package/lib/{esm/Field.d.ts → Field.d.ts} +7 -7
- package/lib/{esm/Field.js → Field.js} +84 -104
- package/lib/{esm/Fieldset.d.ts → Fieldset.d.ts} +7 -7
- package/lib/{esm/Fieldset.js → Fieldset.js} +14 -43
- package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
- package/lib/FileObject.js +29 -0
- package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
- package/lib/FileUpload.js +124 -0
- package/lib/{esm/Form.d.ts → Form.d.ts} +12 -12
- package/lib/{esm/Form.js → Form.js} +34 -65
- package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
- package/lib/FormInstance.js +94 -0
- package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
- package/lib/FormMetaData.js +15 -0
- package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
- package/lib/InstanceManager.js +35 -0
- package/lib/Node.js +15 -0
- package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
- package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
- package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
- package/lib/{esm/controller → controller}/EventQueue.js +8 -32
- package/lib/{esm/controller → controller}/Events.d.ts +2 -2
- package/lib/{esm/controller → controller}/Events.js +22 -26
- package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
- package/lib/controller/Logger.js +33 -0
- package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
- package/lib/{esm/data → data}/DataGroup.js +20 -38
- package/lib/{esm/data → data}/DataValue.d.ts +1 -1
- package/lib/{esm/data → data}/DataValue.js +4 -26
- package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
- package/lib/data/EmptyDataValue.js +34 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +57 -0
- package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
- package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
- package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
- package/lib/rules/RuleEngine.js +51 -0
- package/lib/{esm/types → types}/Json.d.ts +16 -16
- package/lib/types/Json.js +10 -0
- package/lib/{esm/types → types}/Model.d.ts +9 -9
- package/lib/types/Model.js +10 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/{esm/utils → utils}/DataRefParser.d.ts +4 -4
- package/lib/{esm/utils → utils}/DataRefParser.js +30 -45
- package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
- package/lib/utils/Fetch.js +74 -0
- package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
- package/lib/utils/FormCreationUtils.js +67 -0
- package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
- package/lib/{esm/utils → utils}/FormUtils.js +62 -46
- package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
- package/lib/utils/JsonUtils.js +89 -0
- package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
- package/lib/utils/LogUtils.js +10 -0
- package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
- package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
- package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
- package/lib/utils/TranslationUtils.js +125 -0
- package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
- package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
- package/package.json +8 -13
- package/lib/cjs/index.cjs +0 -7426
- package/lib/esm/BaseNode.js +0 -26
- package/lib/esm/Checkbox.js +0 -63
- package/lib/esm/CheckboxGroup.js +0 -60
- package/lib/esm/DateField.js +0 -57
- package/lib/esm/FileObject.js +0 -48
- package/lib/esm/FileUpload.js +0 -141
- package/lib/esm/FormInstance.js +0 -129
- package/lib/esm/FormMetaData.js +0 -35
- package/lib/esm/InstanceManager.js +0 -58
- package/lib/esm/Node.js +0 -40
- package/lib/esm/controller/Logger.js +0 -52
- package/lib/esm/data/EmptyDataValue.js +0 -51
- package/lib/esm/index.d.ts +0 -21
- package/lib/esm/index.js +0 -55
- package/lib/esm/rules/RuleEngine.js +0 -76
- package/lib/esm/types/Json.js +0 -29
- package/lib/esm/types/Model.js +0 -30
- package/lib/esm/types/index.d.ts +0 -2
- package/lib/esm/types/index.js +0 -22
- package/lib/esm/utils/Fetch.js +0 -83
- package/lib/esm/utils/FormCreationUtils.js +0 -112
- package/lib/esm/utils/JsonUtils.js +0 -99
- package/lib/esm/utils/LogUtils.js +0 -28
- package/lib/esm/utils/TranslationUtils.js +0 -138
- /package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2022 Adobe
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
|
|
17
|
-
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
-
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
-
*************************************************************************/
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportDataSchema = exports.defaultFieldTypes = void 0;
|
|
21
4
|
const objToMap = (o) => new Map(Object.entries(o));
|
|
22
5
|
const stringViewTypes = objToMap({ 'date': 'date-input', 'data-url': 'file-input', 'binary': 'file-input' });
|
|
23
6
|
const typeToViewTypes = objToMap({
|
|
@@ -45,7 +28,9 @@ const defaultFieldTypes = (schema) => {
|
|
|
45
28
|
}
|
|
46
29
|
return typeToViewTypes.get(type) || 'text-input';
|
|
47
30
|
};
|
|
31
|
+
exports.defaultFieldTypes = defaultFieldTypes;
|
|
48
32
|
const fieldSchema = (input) => {
|
|
33
|
+
var _a;
|
|
49
34
|
if ('items' in input) {
|
|
50
35
|
const fieldset = input;
|
|
51
36
|
const items = fieldset.items;
|
|
@@ -53,8 +38,8 @@ const fieldSchema = (input) => {
|
|
|
53
38
|
return {
|
|
54
39
|
type: 'array',
|
|
55
40
|
items: fieldSchema(items[0]),
|
|
56
|
-
minItems: fieldset
|
|
57
|
-
maxItems: fieldset
|
|
41
|
+
minItems: fieldset === null || fieldset === void 0 ? void 0 : fieldset.minItems,
|
|
42
|
+
maxItems: fieldset === null || fieldset === void 0 ? void 0 : fieldset.maxItems
|
|
58
43
|
};
|
|
59
44
|
}
|
|
60
45
|
else {
|
|
@@ -79,15 +64,10 @@ const fieldSchema = (input) => {
|
|
|
79
64
|
if (field.dataRef === 'none' || Object.keys(schema).length == 0) {
|
|
80
65
|
return undefined;
|
|
81
66
|
}
|
|
82
|
-
return {
|
|
83
|
-
title: field.label?.value,
|
|
84
|
-
description: field.description,
|
|
85
|
-
...schema
|
|
86
|
-
};
|
|
67
|
+
return Object.assign({ title: (_a = field.label) === null || _a === void 0 ? void 0 : _a.value, description: field.description }, schema);
|
|
87
68
|
}
|
|
88
69
|
};
|
|
89
70
|
const exportDataSchema = (form) => {
|
|
90
71
|
return fieldSchema(form);
|
|
91
72
|
};
|
|
92
|
-
|
|
93
|
-
export { defaultFieldTypes, exportDataSchema };
|
|
73
|
+
exports.exportDataSchema = exportDataSchema;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FieldJson, FieldsetJson, FormJson } from '../types/index
|
|
1
|
+
import { FieldJson, FieldsetJson, FormJson } from '../types/index';
|
|
2
2
|
export declare const TRANSLATION_TOKEN = "##";
|
|
3
3
|
export declare const TRANSLATION_ID = "afs:translationIds";
|
|
4
4
|
export declare const CUSTOM_PROPS_KEY = "properties";
|
|
5
|
-
type formElementJson = FieldJson | FieldsetJson | FormJson | any;
|
|
5
|
+
declare type formElementJson = FieldJson | FieldsetJson | FormJson | any;
|
|
6
6
|
export declare const invalidateTranslation: (input: formElementJson, updates: any) => void;
|
|
7
7
|
export declare const addTranslationId: (input: formElementJson, additionalTranslationProps?: string[]) => formElementJson;
|
|
8
8
|
export declare const getOrElse: (input: any, key: string | string[], defaultValue?: any) => any;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTranslationObject = exports.createTranslationObj = exports.getOrElse = exports.addTranslationId = exports.invalidateTranslation = exports.CUSTOM_PROPS_KEY = exports.TRANSLATION_ID = exports.TRANSLATION_TOKEN = void 0;
|
|
4
|
+
const index_1 = require("../types/index");
|
|
5
|
+
exports.TRANSLATION_TOKEN = '##';
|
|
6
|
+
exports.TRANSLATION_ID = 'afs:translationIds';
|
|
7
|
+
exports.CUSTOM_PROPS_KEY = 'properties';
|
|
8
|
+
const defaultBcp47LangTags = [
|
|
9
|
+
'de-DE',
|
|
10
|
+
'en-US',
|
|
11
|
+
'es-ES',
|
|
12
|
+
'fr-FR',
|
|
13
|
+
'it-IT',
|
|
14
|
+
'ja-JP',
|
|
15
|
+
'ko-KR',
|
|
16
|
+
'pt-BR',
|
|
17
|
+
'zh-CN',
|
|
18
|
+
'zh-TW'
|
|
19
|
+
];
|
|
20
|
+
const invalidateTranslation = (input, updates) => {
|
|
21
|
+
index_1.translationProps.forEach((prop) => {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
if (prop in updates && ((_b = (_a = input === null || input === void 0 ? void 0 : input[exports.CUSTOM_PROPS_KEY]) === null || _a === void 0 ? void 0 : _a[exports.TRANSLATION_ID]) === null || _b === void 0 ? void 0 : _b[prop])) {
|
|
24
|
+
(_d = (_c = input === null || input === void 0 ? void 0 : input[exports.CUSTOM_PROPS_KEY]) === null || _c === void 0 ? void 0 : _c[exports.TRANSLATION_ID]) === null || _d === void 0 ? true : delete _d[prop];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.invalidateTranslation = invalidateTranslation;
|
|
29
|
+
const addTranslationId = (input, additionalTranslationProps = []) => {
|
|
30
|
+
const model = input;
|
|
31
|
+
const transProps = [...index_1.translationProps, ...additionalTranslationProps];
|
|
32
|
+
_createTranslationId(model, '', transProps);
|
|
33
|
+
return model;
|
|
34
|
+
};
|
|
35
|
+
exports.addTranslationId = addTranslationId;
|
|
36
|
+
const _createTranslationId = (input, path, transProps) => {
|
|
37
|
+
Object.entries(input).forEach(([key, value]) => {
|
|
38
|
+
if (typeof value == 'object') {
|
|
39
|
+
if (input instanceof Array) {
|
|
40
|
+
if (value && 'name' in value) {
|
|
41
|
+
_createTranslationId(value, `${path === '' ? path : path + exports.TRANSLATION_TOKEN}${value.name}`, transProps);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
_createTranslationId(value, ((key === 'items') ? path : `${path === '' ? path : path + exports.TRANSLATION_TOKEN}${key}`), transProps);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (':type' in input ||
|
|
50
|
+
'type' in input ||
|
|
51
|
+
'fieldType' in input) {
|
|
52
|
+
for (const transProp of transProps) {
|
|
53
|
+
if ((0, exports.getOrElse)(input, transProp) != null) {
|
|
54
|
+
if (!(exports.CUSTOM_PROPS_KEY in input)) {
|
|
55
|
+
input[exports.CUSTOM_PROPS_KEY] = {};
|
|
56
|
+
}
|
|
57
|
+
if (!(exports.TRANSLATION_ID in input[exports.CUSTOM_PROPS_KEY])) {
|
|
58
|
+
input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID] = {};
|
|
59
|
+
}
|
|
60
|
+
if (!(transProp in input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID])) {
|
|
61
|
+
input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID][transProp] = `${path}${exports.TRANSLATION_TOKEN}${transProp}${exports.TRANSLATION_TOKEN}${Math.floor(Math.random() * 10000) + 1}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const _createTranslationObj = (input, translationObj, translationProps) => {
|
|
70
|
+
Object.values(input).forEach((value) => {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
if (typeof value == 'object') {
|
|
73
|
+
_createTranslationObj(value, translationObj, translationProps);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
for (const translationProp of translationProps) {
|
|
77
|
+
const objValue = (0, exports.getOrElse)(input, translationProp);
|
|
78
|
+
if (objValue && ((_b = (_a = input === null || input === void 0 ? void 0 : input[exports.CUSTOM_PROPS_KEY]) === null || _a === void 0 ? void 0 : _a[exports.TRANSLATION_ID]) === null || _b === void 0 ? void 0 : _b[translationProp])) {
|
|
79
|
+
if (objValue instanceof Array) {
|
|
80
|
+
objValue.forEach((item, index) => {
|
|
81
|
+
if (typeof item === 'string') {
|
|
82
|
+
translationObj[`${input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID][translationProp]}${exports.TRANSLATION_TOKEN}${index}`] = item;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
translationObj[`${input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID][translationProp]}`] = objValue;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const getOrElse = (input, key, defaultValue = null) => {
|
|
95
|
+
if (!key) {
|
|
96
|
+
return defaultValue;
|
|
97
|
+
}
|
|
98
|
+
const arr = Array.isArray(key) ? key : key.split('.');
|
|
99
|
+
let objValue = input, index = 0;
|
|
100
|
+
while (index < arr.length && objValue.hasOwnProperty(arr[index])) {
|
|
101
|
+
objValue = objValue[arr[index]];
|
|
102
|
+
index++;
|
|
103
|
+
}
|
|
104
|
+
return index == arr.length ? objValue : defaultValue;
|
|
105
|
+
};
|
|
106
|
+
exports.getOrElse = getOrElse;
|
|
107
|
+
const createTranslationObj = (input, additionalTranslationProps = []) => {
|
|
108
|
+
const obj = {};
|
|
109
|
+
const transProps = [...index_1.translationProps, ...additionalTranslationProps];
|
|
110
|
+
_createTranslationObj(input, obj, transProps);
|
|
111
|
+
return obj;
|
|
112
|
+
};
|
|
113
|
+
exports.createTranslationObj = createTranslationObj;
|
|
114
|
+
const createTranslationObject = (input, additionalTranslationProps = [], bcp47LangTags = []) => {
|
|
115
|
+
const transProps = [...index_1.translationProps, ...additionalTranslationProps];
|
|
116
|
+
const inputCopy = JSON.parse(JSON.stringify(input));
|
|
117
|
+
const obj = (0, exports.createTranslationObj)((0, exports.addTranslationId)(inputCopy, additionalTranslationProps), transProps);
|
|
118
|
+
const langTags = [...defaultBcp47LangTags, ...bcp47LangTags];
|
|
119
|
+
const allLangs = {};
|
|
120
|
+
for (const langTag of langTags) {
|
|
121
|
+
allLangs[langTag] = JSON.parse(JSON.stringify(obj));
|
|
122
|
+
}
|
|
123
|
+
return [inputCopy, allLangs];
|
|
124
|
+
};
|
|
125
|
+
exports.createTranslationObject = createTranslationObject;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type ValidationResult = {
|
|
1
|
+
declare type ValidationResult = {
|
|
2
2
|
valid: boolean;
|
|
3
3
|
value: any;
|
|
4
4
|
};
|
|
5
5
|
export declare const coerceType: (param: any, type: 'string' | 'number' | 'boolean') => string | number | boolean;
|
|
6
|
-
type ValidConstraintsType = {
|
|
6
|
+
declare type ValidConstraintsType = {
|
|
7
7
|
date: ValidationConstraints[];
|
|
8
8
|
string: ValidationConstraints[];
|
|
9
9
|
number: ValidationConstraints[];
|
|
@@ -11,8 +11,8 @@ type ValidConstraintsType = {
|
|
|
11
11
|
file: ValidationConstraints[];
|
|
12
12
|
};
|
|
13
13
|
export declare const ValidConstraints: ValidConstraintsType;
|
|
14
|
-
export type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
|
|
15
|
-
type ConstraintsObject = {
|
|
14
|
+
export declare type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
|
|
15
|
+
declare type ConstraintsObject = {
|
|
16
16
|
[key in ValidationConstraints]: (constraint: any, inputVal: any) => ValidationResult;
|
|
17
17
|
};
|
|
18
18
|
export declare const Constraints: ConstraintsObject;
|
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
|
|
17
|
-
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
-
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
-
*************************************************************************/
|
|
20
|
-
|
|
21
|
-
import { getFileSizeInBytes, extractFileInfo } from './FormUtils.js';
|
|
22
|
-
import { FileObject } from '../FileObject.js';
|
|
23
|
-
import './JsonUtils.js';
|
|
24
|
-
import '../types/Json.js';
|
|
25
|
-
import './SchemaUtils.js';
|
|
26
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Constraints = exports.ValidConstraints = exports.coerceType = void 0;
|
|
4
|
+
const FormUtils_1 = require("./FormUtils");
|
|
5
|
+
const FileObject_1 = require("../FileObject");
|
|
27
6
|
const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
28
7
|
const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
29
8
|
const daysInMonth = (leapYear, month) => {
|
|
@@ -56,6 +35,7 @@ const coerceType = (param, type) => {
|
|
|
56
35
|
}
|
|
57
36
|
throw `${param} has invalid type. Expected : ${type}, Actual ${typeof param}`;
|
|
58
37
|
};
|
|
38
|
+
exports.coerceType = coerceType;
|
|
59
39
|
const checkNumber = (inputVal) => {
|
|
60
40
|
if (inputVal === '' || inputVal == null) {
|
|
61
41
|
return {
|
|
@@ -98,7 +78,7 @@ const checkBool = (inputVal) => {
|
|
|
98
78
|
return { valid, value };
|
|
99
79
|
};
|
|
100
80
|
const checkFile = (inputVal) => {
|
|
101
|
-
const value = extractFileInfo(inputVal);
|
|
81
|
+
const value = (0, FormUtils_1.extractFileInfo)(inputVal);
|
|
102
82
|
const valid = value !== null;
|
|
103
83
|
return {
|
|
104
84
|
value: valid ? value : inputVal,
|
|
@@ -129,14 +109,14 @@ const partitionArray = (inputVal, validatorFn) => {
|
|
|
129
109
|
return acc;
|
|
130
110
|
}, [[], []]);
|
|
131
111
|
};
|
|
132
|
-
|
|
112
|
+
exports.ValidConstraints = {
|
|
133
113
|
date: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'format'],
|
|
134
114
|
string: ['minLength', 'maxLength', 'pattern'],
|
|
135
115
|
number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
|
|
136
116
|
array: ['minItems', 'maxItems', 'uniqueItems'],
|
|
137
117
|
file: ['accept', 'maxFileSize']
|
|
138
118
|
};
|
|
139
|
-
|
|
119
|
+
exports.Constraints = {
|
|
140
120
|
type: (constraint, inputVal) => {
|
|
141
121
|
let value = inputVal;
|
|
142
122
|
if (inputVal == undefined) {
|
|
@@ -249,10 +229,10 @@ const Constraints = {
|
|
|
249
229
|
return { valid: !constraint || ((value instanceof Array) && value.length === new Set(value).size), value };
|
|
250
230
|
},
|
|
251
231
|
minLength: (constraint, value) => {
|
|
252
|
-
return {
|
|
232
|
+
return Object.assign(Object.assign({}, exports.Constraints.minimum(constraint, typeof value === 'string' ? value.length : 0)), { value });
|
|
253
233
|
},
|
|
254
234
|
maxLength: (constraint, value) => {
|
|
255
|
-
return {
|
|
235
|
+
return Object.assign(Object.assign({}, exports.Constraints.maximum(constraint, typeof value === 'string' ? value.length : 0)), { value });
|
|
256
236
|
},
|
|
257
237
|
pattern: (constraint, value) => {
|
|
258
238
|
let regex;
|
|
@@ -289,12 +269,10 @@ const Constraints = {
|
|
|
289
269
|
};
|
|
290
270
|
},
|
|
291
271
|
maxFileSize: (constraint, value) => {
|
|
292
|
-
const sizeLimit = typeof constraint === 'string' ? getFileSizeInBytes(constraint) : constraint;
|
|
272
|
+
const sizeLimit = typeof constraint === 'string' ? (0, FormUtils_1.getFileSizeInBytes)(constraint) : constraint;
|
|
293
273
|
return {
|
|
294
|
-
valid: !(value instanceof FileObject) || value.size <= sizeLimit,
|
|
274
|
+
valid: !(value instanceof FileObject_1.FileObject) || value.size <= sizeLimit,
|
|
295
275
|
value
|
|
296
276
|
};
|
|
297
277
|
}
|
|
298
278
|
};
|
|
299
|
-
|
|
300
|
-
export { Constraints, ValidConstraints, coerceType };
|
package/package.json
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.33",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
7
|
-
"
|
|
8
|
-
"module": "lib/esm/index.js",
|
|
9
|
-
"types": "lib/esm/index.d.ts",
|
|
10
|
-
"main": "lib/cjs/index.cjs",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": "./lib/esm/index.js"
|
|
13
|
-
},
|
|
7
|
+
"main": "lib/index.js",
|
|
14
8
|
"directories": {
|
|
15
9
|
"lib": "lib",
|
|
16
10
|
"source": "src",
|
|
@@ -30,25 +24,26 @@
|
|
|
30
24
|
"access": "public"
|
|
31
25
|
},
|
|
32
26
|
"scripts": {
|
|
33
|
-
"test": "
|
|
27
|
+
"test": "jest --silent",
|
|
34
28
|
"eslint": "npx eslint src/**",
|
|
35
29
|
"eslint:fix": "npx eslint --fix src/**",
|
|
36
|
-
"test:ci": "
|
|
37
|
-
"
|
|
38
|
-
"build": "rollup -c rollup.config.js",
|
|
30
|
+
"test:ci": "jest --silent --coverage",
|
|
31
|
+
"build": "npm run eslint && npx tsc",
|
|
39
32
|
"clean": "rm -rf lib target",
|
|
40
33
|
"prepublishOnly": "npm run build && npm run test",
|
|
41
34
|
"docs": "npx typedoc --options .typedoc.cjs"
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
37
|
"@adobe/json-formula": "0.1.50",
|
|
45
|
-
"@aemforms/af-formatters": "^0.22.
|
|
38
|
+
"@aemforms/af-formatters": "^0.22.33"
|
|
46
39
|
},
|
|
47
40
|
"devDependencies": {
|
|
41
|
+
"@babel/preset-env": "^7.20.2",
|
|
48
42
|
"@types/jest": "29.2.4",
|
|
49
43
|
"@types/lodash": "^4.14.171",
|
|
50
44
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
51
45
|
"@typescript-eslint/parser": "^4.28.2",
|
|
46
|
+
"babel-jest": "^29.4.1",
|
|
52
47
|
"blob-polyfill": "^7.0.20220408",
|
|
53
48
|
"eslint": "^7.30.0",
|
|
54
49
|
"eslint-config-standard": "^16.0.3",
|