@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,52 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
const levels = {
|
|
22
|
-
off: 0,
|
|
23
|
-
debug: 1,
|
|
24
|
-
info: 2,
|
|
25
|
-
warn: 3,
|
|
26
|
-
error: 4
|
|
27
|
-
};
|
|
28
|
-
class Logger {
|
|
29
|
-
debug(msg) {
|
|
30
|
-
this.log(msg, 'debug');
|
|
31
|
-
}
|
|
32
|
-
info(msg) {
|
|
33
|
-
this.log(msg, 'info');
|
|
34
|
-
}
|
|
35
|
-
warn(msg) {
|
|
36
|
-
this.log(msg, 'warn');
|
|
37
|
-
}
|
|
38
|
-
error(msg) {
|
|
39
|
-
this.log(msg, 'error');
|
|
40
|
-
}
|
|
41
|
-
log(msg, level) {
|
|
42
|
-
if (this.logLevel !== 0 && this.logLevel <= levels[level]) {
|
|
43
|
-
console[level](msg);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
logLevel;
|
|
47
|
-
constructor(logLevel = 'off') {
|
|
48
|
-
this.logLevel = levels[logLevel];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { Logger };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
import DataValue from './DataValue.js';
|
|
22
|
-
|
|
23
|
-
const value = Symbol('NullValue');
|
|
24
|
-
class NullDataValueClass extends DataValue {
|
|
25
|
-
constructor() {
|
|
26
|
-
super('', value, 'null');
|
|
27
|
-
}
|
|
28
|
-
setValue() {
|
|
29
|
-
}
|
|
30
|
-
$bindToField() {
|
|
31
|
-
}
|
|
32
|
-
$length() {
|
|
33
|
-
return 0;
|
|
34
|
-
}
|
|
35
|
-
$convertToDataValue() {
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
$addDataNode() {
|
|
39
|
-
}
|
|
40
|
-
$removeDataNode() {
|
|
41
|
-
}
|
|
42
|
-
$getDataNode() {
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
$containsDataNode() {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const NullDataValue = new NullDataValueClass();
|
|
50
|
-
|
|
51
|
-
export { NullDataValue as default };
|
package/lib/esm/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export * from './FormInstance.js';
|
|
2
|
-
export * from './types/index.js';
|
|
3
|
-
export * from './controller/Events.js';
|
|
4
|
-
export * from './utils/TranslationUtils.js';
|
|
5
|
-
export * from './utils/JsonUtils.js';
|
|
6
|
-
export * from './utils/SchemaUtils.js';
|
|
7
|
-
import { getFileSizeInBytes, extractFileInfo, isEmpty } from './utils/FormUtils.js';
|
|
8
|
-
import { BaseNode } from './BaseNode.js';
|
|
9
|
-
import Checkbox from './Checkbox.js';
|
|
10
|
-
import CheckboxGroup from './CheckboxGroup.js';
|
|
11
|
-
import Container from './Container.js';
|
|
12
|
-
import Field from './Field.js';
|
|
13
|
-
import { Fieldset } from './Fieldset.js';
|
|
14
|
-
import { FileObject } from './FileObject.js';
|
|
15
|
-
import FileUpload from './FileUpload.js';
|
|
16
|
-
import FormMetaData from './FormMetaData.js';
|
|
17
|
-
import Node from './Node.js';
|
|
18
|
-
import Scriptable from './Scriptable.js';
|
|
19
|
-
import Form from './Form.js';
|
|
20
|
-
import { FunctionRuntime, request } from './rules/FunctionRuntime.js';
|
|
21
|
-
export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes, extractFileInfo, FunctionRuntime, request, isEmpty };
|
package/lib/esm/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
export { createFormInstance, fetchForm, registerFunctions, validateFormData, validateFormInstance } from './FormInstance.js';
|
|
22
|
-
export { constraintProps, translationProps } from './types/Json.js';
|
|
23
|
-
export { ValidationError } from './types/Model.js';
|
|
24
|
-
export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, Reset, Submit, Valid, ValidationComplete, propertyChange } from './controller/Events.js';
|
|
25
|
-
export { CUSTOM_PROPS_KEY, TRANSLATION_ID, TRANSLATION_TOKEN, addTranslationId, createTranslationObj, createTranslationObject, getOrElse, invalidateTranslation } from './utils/TranslationUtils.js';
|
|
26
|
-
export { checkIfConstraintsArePresent, checkIfKeyAdded, deepClone, getProperty, isCheckbox, isCheckboxGroup, isDateField, isFile, isRepeatable, jsonString } from './utils/JsonUtils.js';
|
|
27
|
-
export { defaultFieldTypes, exportDataSchema } from './utils/SchemaUtils.js';
|
|
28
|
-
export { extractFileInfo, getFileSizeInBytes, isEmpty } from './utils/FormUtils.js';
|
|
29
|
-
export { B as BaseNode } from './BaseNode-f84b22c6.js';
|
|
30
|
-
export { default as Checkbox } from './Checkbox.js';
|
|
31
|
-
export { default as CheckboxGroup } from './CheckboxGroup.js';
|
|
32
|
-
export { default as Container } from './Container.js';
|
|
33
|
-
export { default as Field } from './Field.js';
|
|
34
|
-
export { Fieldset } from './Fieldset.js';
|
|
35
|
-
export { FileObject } from './FileObject.js';
|
|
36
|
-
export { default as FileUpload } from './FileUpload.js';
|
|
37
|
-
export { default as FormMetaData } from './FormMetaData.js';
|
|
38
|
-
export { default as Node } from './Node.js';
|
|
39
|
-
export { default as Scriptable } from './Scriptable.js';
|
|
40
|
-
export { default as Form } from './Form.js';
|
|
41
|
-
export { FunctionRuntime, request } from './rules/FunctionRuntime.js';
|
|
42
|
-
import './utils/Fetch.js';
|
|
43
|
-
import './rules/RuleEngine.js';
|
|
44
|
-
import '@adobe/json-formula';
|
|
45
|
-
import './controller/EventQueue.js';
|
|
46
|
-
import './controller/Logger.js';
|
|
47
|
-
import './utils/FormCreationUtils.js';
|
|
48
|
-
import './InstanceManager.js';
|
|
49
|
-
import './utils/DataRefParser.js';
|
|
50
|
-
import './data/DataGroup.js';
|
|
51
|
-
import './data/DataValue.js';
|
|
52
|
-
import './data/EmptyDataValue.js';
|
|
53
|
-
import './DateField.js';
|
|
54
|
-
import '@aemforms/af-formatters';
|
|
55
|
-
import './utils/ValidationUtils.js';
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
import Formula from '@adobe/json-formula';
|
|
22
|
-
import { FunctionRuntime } from './FunctionRuntime.js';
|
|
23
|
-
import '../controller/Events.js';
|
|
24
|
-
import '../utils/Fetch.js';
|
|
25
|
-
import '../FileObject.js';
|
|
26
|
-
import '../utils/FormUtils.js';
|
|
27
|
-
import '../utils/JsonUtils.js';
|
|
28
|
-
import '../types/Json.js';
|
|
29
|
-
import '../utils/SchemaUtils.js';
|
|
30
|
-
|
|
31
|
-
class RuleEngine {
|
|
32
|
-
_context;
|
|
33
|
-
_globalNames = [
|
|
34
|
-
'$form',
|
|
35
|
-
'$field',
|
|
36
|
-
'$event'
|
|
37
|
-
];
|
|
38
|
-
formulaEngine;
|
|
39
|
-
debugInfo = [];
|
|
40
|
-
constructor() {
|
|
41
|
-
const customFunctions = FunctionRuntime.getFunctions();
|
|
42
|
-
this.formulaEngine = new Formula(customFunctions, undefined, this.debugInfo);
|
|
43
|
-
}
|
|
44
|
-
compileRule(rule) {
|
|
45
|
-
return this.formulaEngine.compile(rule, this._globalNames);
|
|
46
|
-
}
|
|
47
|
-
execute(node, data, globals, useValueOf = false) {
|
|
48
|
-
const oldContext = this._context;
|
|
49
|
-
this._context = globals;
|
|
50
|
-
let res = undefined;
|
|
51
|
-
try {
|
|
52
|
-
res = this.formulaEngine.run(node, data, 'en-US', globals);
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
this._context?.form?.logger?.error(err);
|
|
56
|
-
}
|
|
57
|
-
while (this.debugInfo.length > 0) {
|
|
58
|
-
this._context?.form?.logger?.debug(this.debugInfo.pop());
|
|
59
|
-
}
|
|
60
|
-
let finalRes = res;
|
|
61
|
-
if (useValueOf) {
|
|
62
|
-
if (typeof res === 'object' && res !== null) {
|
|
63
|
-
finalRes = Object.getPrototypeOf(res).valueOf.call(res);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
this._context = oldContext;
|
|
67
|
-
return finalRes;
|
|
68
|
-
}
|
|
69
|
-
trackDependency(subscriber) {
|
|
70
|
-
if (this._context && this._context.field !== undefined && this._context.field !== subscriber) {
|
|
71
|
-
subscriber._addDependent(this._context.field);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export { RuleEngine as default };
|
package/lib/esm/types/Json.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
const translationProps = ['description', 'placeholder', 'enum', 'enumNames', 'label.value', 'constraintMessages.accept',
|
|
22
|
-
'constraintMessages.enum', 'constraintMessages.exclusiveMinimum', 'constraintMessages.exclusiveMaximum', 'constraintMessages.format', 'constraintMessages.maxFileSize', 'constraintMessages.maxLength',
|
|
23
|
-
'constraintMessages.maximum', 'constraintMessages.maxItems', 'constraintMessages.minLength', 'constraintMessages.minimum', 'constraintMessages.minItems', 'constraintMessages.pattern', 'constraintMessages.required',
|
|
24
|
-
'constraintMessages.step', 'constraintMessages.type', 'constraintMessages.validationExpression'];
|
|
25
|
-
const constraintProps = ['accept', 'enum', 'exclusiveMinimum', 'exclusiveMaximum',
|
|
26
|
-
'format', 'maxFileSize', 'maxLength', 'maximum', 'maxItems',
|
|
27
|
-
'minLength', 'minimum', 'minItems', 'pattern', 'required', 'step', 'validationExpression', 'enumNames'];
|
|
28
|
-
|
|
29
|
-
export { constraintProps, translationProps };
|
package/lib/esm/types/Model.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
class ValidationError {
|
|
22
|
-
fieldName;
|
|
23
|
-
errorMessages;
|
|
24
|
-
constructor(fieldName = '', errorMessages = []) {
|
|
25
|
-
this.errorMessages = errorMessages;
|
|
26
|
-
this.fieldName = fieldName;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { ValidationError };
|
package/lib/esm/types/index.d.ts
DELETED
package/lib/esm/types/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
export { constraintProps, translationProps } from './Json.js';
|
|
22
|
-
export { ValidationError } from './Model.js';
|
package/lib/esm/utils/Fetch.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
const request = (url, data = null, options = {}) => {
|
|
22
|
-
const opts = { ...defaultRequestOptions, ...options };
|
|
23
|
-
const updatedUrl = opts.method === 'GET' && data ? convertQueryString(url, data) : url;
|
|
24
|
-
if (opts.method !== 'GET') {
|
|
25
|
-
opts.body = data;
|
|
26
|
-
}
|
|
27
|
-
return fetch(updatedUrl, {
|
|
28
|
-
...opts
|
|
29
|
-
}).then(async (response) => {
|
|
30
|
-
let body;
|
|
31
|
-
if (!response.ok) {
|
|
32
|
-
console.error(`Error fetching response from ${url} : ${response.statusText}`);
|
|
33
|
-
body = response.statusText;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (response?.headers?.get('Content-Type')?.includes('application/json')) {
|
|
37
|
-
body = await response.json();
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
body = await response.text();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const headers = {};
|
|
44
|
-
response?.headers?.forEach((value, key) => {
|
|
45
|
-
headers[key] = value;
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
status: response.status,
|
|
49
|
-
body,
|
|
50
|
-
headers
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const defaultRequestOptions = {
|
|
55
|
-
method: 'GET'
|
|
56
|
-
};
|
|
57
|
-
const convertQueryString = (endpoint, payload) => {
|
|
58
|
-
if (!payload) {
|
|
59
|
-
return endpoint;
|
|
60
|
-
}
|
|
61
|
-
let updatedPayload = {};
|
|
62
|
-
try {
|
|
63
|
-
updatedPayload = JSON.parse(payload);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
console.log('Query params invalid');
|
|
67
|
-
}
|
|
68
|
-
const params = [];
|
|
69
|
-
Object.keys(updatedPayload).forEach((key) => {
|
|
70
|
-
if (Array.isArray(updatedPayload[key])) {
|
|
71
|
-
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(JSON.stringify(updatedPayload[key]))}`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(updatedPayload[key])}`);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
if (!params.length) {
|
|
78
|
-
return endpoint;
|
|
79
|
-
}
|
|
80
|
-
return endpoint.includes('?') ? `${endpoint}&${params.join('&')}` : `${endpoint}?${params.join('&')}`;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { convertQueryString, request };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
import { InstanceManager } from '../InstanceManager.js';
|
|
22
|
-
import { Fieldset } from '../Fieldset.js';
|
|
23
|
-
import { isRepeatable, isFile, isCheckbox, isCheckboxGroup, isDateField } from './JsonUtils.js';
|
|
24
|
-
import FileUpload from '../FileUpload.js';
|
|
25
|
-
import Checkbox from '../Checkbox.js';
|
|
26
|
-
import CheckboxGroup from '../CheckboxGroup.js';
|
|
27
|
-
import DateField from '../DateField.js';
|
|
28
|
-
import Field from '../Field.js';
|
|
29
|
-
import '../BaseNode-f84b22c6.js';
|
|
30
|
-
import '../controller/Events.js';
|
|
31
|
-
import './DataRefParser.js';
|
|
32
|
-
import '../data/DataGroup.js';
|
|
33
|
-
import '../data/DataValue.js';
|
|
34
|
-
import '../data/EmptyDataValue.js';
|
|
35
|
-
import '../Container.js';
|
|
36
|
-
import '../Scriptable.js';
|
|
37
|
-
import '../types/Json.js';
|
|
38
|
-
import './SchemaUtils.js';
|
|
39
|
-
import './FormUtils.js';
|
|
40
|
-
import '../FileObject.js';
|
|
41
|
-
import './ValidationUtils.js';
|
|
42
|
-
import '../types/Model.js';
|
|
43
|
-
import '@aemforms/af-formatters';
|
|
44
|
-
|
|
45
|
-
const alternateFieldTypeMapping = {
|
|
46
|
-
'text': 'text-input',
|
|
47
|
-
'number': 'number-input',
|
|
48
|
-
'email': 'text-input',
|
|
49
|
-
'file': 'file-input',
|
|
50
|
-
'range': 'range',
|
|
51
|
-
'textarea': 'multiline-input'
|
|
52
|
-
};
|
|
53
|
-
class FormFieldFactoryImpl {
|
|
54
|
-
createField(child, _options) {
|
|
55
|
-
let retVal;
|
|
56
|
-
const options = {
|
|
57
|
-
..._options,
|
|
58
|
-
fieldFactory: this
|
|
59
|
-
};
|
|
60
|
-
child.fieldType = child.fieldType ? (child.fieldType in alternateFieldTypeMapping ?
|
|
61
|
-
alternateFieldTypeMapping[child.fieldType] : child.fieldType)
|
|
62
|
-
: 'text-input';
|
|
63
|
-
if (isRepeatable(child)) {
|
|
64
|
-
const newChild = {
|
|
65
|
-
...child,
|
|
66
|
-
...('items' in child && { 'type': 'object' }),
|
|
67
|
-
minOccur: undefined,
|
|
68
|
-
maxOccur: undefined,
|
|
69
|
-
repeatable: undefined,
|
|
70
|
-
name: undefined
|
|
71
|
-
};
|
|
72
|
-
const newJson = {
|
|
73
|
-
...{
|
|
74
|
-
minItems: child.minOccur || 0,
|
|
75
|
-
maxItems: child.maxOccur || -1,
|
|
76
|
-
fieldType: child.fieldType,
|
|
77
|
-
type: 'array',
|
|
78
|
-
name: child.name,
|
|
79
|
-
dataRef: child.dataRef
|
|
80
|
-
},
|
|
81
|
-
...{
|
|
82
|
-
'items': [newChild]
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
retVal = new InstanceManager(newJson, options);
|
|
86
|
-
}
|
|
87
|
-
else if ('items' in child) {
|
|
88
|
-
retVal = new Fieldset(child, options);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
if (isFile(child) || child.fieldType === 'file-input') {
|
|
92
|
-
retVal = new FileUpload(child, options);
|
|
93
|
-
}
|
|
94
|
-
else if (isCheckbox(child)) {
|
|
95
|
-
retVal = new Checkbox(child, options);
|
|
96
|
-
}
|
|
97
|
-
else if (isCheckboxGroup(child)) {
|
|
98
|
-
retVal = new CheckboxGroup(child, options);
|
|
99
|
-
}
|
|
100
|
-
else if (isDateField(child)) {
|
|
101
|
-
retVal = new DateField(child, options);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
retVal = new Field(child, options);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return retVal;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const FormFieldFactory = new FormFieldFactoryImpl();
|
|
111
|
-
|
|
112
|
-
export { FormFieldFactory };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
import { constraintProps } from '../types/Json.js';
|
|
22
|
-
import { defaultFieldTypes } from './SchemaUtils.js';
|
|
23
|
-
|
|
24
|
-
const getProperty = (data, key, def) => {
|
|
25
|
-
if (key in data) {
|
|
26
|
-
return data[key];
|
|
27
|
-
}
|
|
28
|
-
else if (!key.startsWith(':')) {
|
|
29
|
-
const prefixedKey = `:${key}`;
|
|
30
|
-
if (prefixedKey in data) {
|
|
31
|
-
return data[prefixedKey];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return def;
|
|
35
|
-
};
|
|
36
|
-
const isFile = function (item) {
|
|
37
|
-
return (item?.type === 'file' || item?.type === 'file[]') ||
|
|
38
|
-
((item?.type === 'string' || item?.type === 'string[]') &&
|
|
39
|
-
(item?.format === 'binary' || item?.format === 'data-url'));
|
|
40
|
-
};
|
|
41
|
-
const checkIfConstraintsArePresent = function (item) {
|
|
42
|
-
return constraintProps.some(cp => item[cp] !== undefined);
|
|
43
|
-
};
|
|
44
|
-
const isCheckbox = function (item) {
|
|
45
|
-
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
46
|
-
return fieldType === 'checkbox';
|
|
47
|
-
};
|
|
48
|
-
const isCheckboxGroup = function (item) {
|
|
49
|
-
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
50
|
-
return fieldType === 'checkbox-group';
|
|
51
|
-
};
|
|
52
|
-
const isDateField = function (item) {
|
|
53
|
-
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
54
|
-
return (fieldType === 'text-input' && item?.format === 'date') || fieldType === 'date-input';
|
|
55
|
-
};
|
|
56
|
-
function deepClone(obj, idGenerator) {
|
|
57
|
-
let result;
|
|
58
|
-
if (obj instanceof Array) {
|
|
59
|
-
result = [];
|
|
60
|
-
result = obj.map(x => deepClone(x, idGenerator));
|
|
61
|
-
}
|
|
62
|
-
else if (typeof obj === 'object' && obj !== null) {
|
|
63
|
-
result = {};
|
|
64
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
65
|
-
result[key] = deepClone(value, idGenerator);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
result = obj;
|
|
70
|
-
}
|
|
71
|
-
if (idGenerator && result && result.id) {
|
|
72
|
-
result.id = idGenerator();
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
function checkIfKeyAdded(currentObj, prevObj, objKey) {
|
|
77
|
-
if (currentObj != null && prevObj != null) {
|
|
78
|
-
const newPrvObj = { ...prevObj };
|
|
79
|
-
newPrvObj[objKey] = currentObj[objKey];
|
|
80
|
-
const newJsonStr = jsonString(currentObj).replace(jsonString(newPrvObj), '');
|
|
81
|
-
return newJsonStr === '';
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const jsonString = (obj) => {
|
|
88
|
-
return JSON.stringify(obj, null, 2);
|
|
89
|
-
};
|
|
90
|
-
const isRepeatable = (obj) => {
|
|
91
|
-
return ((obj.repeatable &&
|
|
92
|
-
((obj.minOccur === undefined && obj.maxOccur === undefined) ||
|
|
93
|
-
(obj.minOccur !== undefined && obj.maxOccur !== undefined && obj.maxOccur !== 0) ||
|
|
94
|
-
(obj.minOccur !== undefined && obj.maxOccur !== undefined && obj.minOccur !== 0 && obj.maxOccur !== 0) ||
|
|
95
|
-
(obj.minOccur !== undefined && obj.minOccur >= 0) ||
|
|
96
|
-
(obj.maxOccur !== undefined && obj.maxOccur !== 0))) || false);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export { checkIfConstraintsArePresent, checkIfKeyAdded, deepClone, getProperty, isCheckbox, isCheckboxGroup, isDateField, isFile, isRepeatable, jsonString };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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
|
-
|
|
21
|
-
const logFormCallbacks = (callbacks) => {
|
|
22
|
-
const s = Object.entries(callbacks).map(([id, fn]) => {
|
|
23
|
-
return `${id} : ${fn.length}`;
|
|
24
|
-
}).join(' ');
|
|
25
|
-
console.log(s);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { logFormCallbacks };
|