@aemforms/af-core 0.22.20 → 0.22.23
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/LICENSE +18 -4
- package/README.md +14 -5
- package/lib/cjs/index.cjs +267 -1876
- package/lib/esm/BaseNode-dc59ab07.js +478 -0
- package/lib/esm/BaseNode.js +26 -454
- package/lib/esm/Checkbox.js +37 -1
- package/lib/esm/CheckboxGroup.js +38 -1
- package/lib/esm/Container.js +30 -9
- package/lib/esm/DateField.js +38 -2
- package/lib/esm/Field.d.ts +2 -2
- package/lib/esm/Field.js +62 -26
- package/lib/esm/Fieldset.js +36 -3
- package/lib/esm/FileObject.js +23 -1
- package/lib/esm/FileUpload.js +34 -1
- package/lib/esm/Form.d.ts +1 -1
- package/lib/esm/Form.js +40 -8
- package/lib/esm/FormInstance.js +53 -5
- package/lib/esm/FormMetaData.js +26 -1
- package/lib/esm/InstanceManager.js +35 -8
- package/lib/esm/Node.js +25 -1
- package/lib/esm/Scriptable.js +29 -2
- package/lib/esm/controller/EventQueue.js +23 -1
- package/lib/esm/controller/Events.d.ts +1 -1
- package/lib/esm/controller/Events.js +41 -19
- package/lib/esm/controller/Logger.d.ts +2 -2
- package/lib/esm/controller/Logger.js +23 -1
- package/lib/esm/data/DataGroup.js +24 -1
- package/lib/esm/data/DataValue.js +23 -1
- package/lib/esm/data/EmptyDataValue.js +23 -1
- package/lib/esm/index.js +55 -21
- package/lib/esm/rules/FunctionRuntime.d.ts +3 -3
- package/lib/esm/rules/FunctionRuntime.js +31 -6
- package/lib/esm/rules/RuleEngine.js +30 -1
- package/lib/esm/types/Json.d.ts +16 -16
- package/lib/esm/types/Json.js +24 -2
- package/lib/esm/types/Model.d.ts +4 -4
- package/lib/esm/types/Model.js +23 -1
- package/lib/esm/types/index.js +22 -2
- package/lib/esm/utils/DataRefParser.d.ts +2 -2
- package/lib/esm/utils/DataRefParser.js +31 -6
- package/lib/esm/utils/Fetch.d.ts +1 -1
- package/lib/esm/utils/Fetch.js +24 -2
- package/lib/esm/utils/FormCreationUtils.js +40 -2
- package/lib/esm/utils/FormUtils.js +33 -8
- package/lib/esm/utils/JsonUtils.js +34 -11
- package/lib/esm/utils/LogUtils.js +23 -1
- package/lib/esm/utils/SchemaUtils.js +24 -2
- package/lib/esm/utils/TranslationUtils.d.ts +1 -1
- package/lib/esm/utils/TranslationUtils.js +32 -9
- package/lib/esm/utils/ValidationUtils.d.ts +4 -4
- package/lib/esm/utils/ValidationUtils.js +30 -4
- package/package.json +4 -3
- package/lib/browser/afb-events.js +0 -151
- package/lib/browser/afb-runtime.js +0 -3620
|
@@ -1,3 +1,23 @@
|
|
|
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
|
+
|
|
1
21
|
class ActionImpl {
|
|
2
22
|
_metadata;
|
|
3
23
|
_type;
|
|
@@ -37,7 +57,7 @@ class ActionImpl {
|
|
|
37
57
|
return JSON.stringify(this.toJson());
|
|
38
58
|
}
|
|
39
59
|
}
|
|
40
|
-
|
|
60
|
+
class Change extends ActionImpl {
|
|
41
61
|
constructor(payload, dispatch = false) {
|
|
42
62
|
super(payload, 'change', { dispatch });
|
|
43
63
|
}
|
|
@@ -45,22 +65,22 @@ export class Change extends ActionImpl {
|
|
|
45
65
|
return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
|
|
46
66
|
}
|
|
47
67
|
}
|
|
48
|
-
|
|
68
|
+
class Invalid extends ActionImpl {
|
|
49
69
|
constructor(payload = {}) {
|
|
50
70
|
super(payload, 'invalid', {});
|
|
51
71
|
}
|
|
52
72
|
}
|
|
53
|
-
|
|
73
|
+
class Valid extends ActionImpl {
|
|
54
74
|
constructor(payload = {}) {
|
|
55
75
|
super(payload, 'valid', {});
|
|
56
76
|
}
|
|
57
77
|
}
|
|
58
|
-
|
|
78
|
+
class ExecuteRule extends ActionImpl {
|
|
59
79
|
constructor(payload = {}, dispatch = false) {
|
|
60
80
|
super(payload, 'executeRule', { dispatch });
|
|
61
81
|
}
|
|
62
82
|
}
|
|
63
|
-
|
|
83
|
+
const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
64
84
|
return new Change({
|
|
65
85
|
changes: [
|
|
66
86
|
{
|
|
@@ -71,47 +91,47 @@ export const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
|
71
91
|
]
|
|
72
92
|
});
|
|
73
93
|
};
|
|
74
|
-
|
|
94
|
+
class Initialize extends ActionImpl {
|
|
75
95
|
constructor(payload, dispatch = false) {
|
|
76
96
|
super(payload, 'initialize', { dispatch });
|
|
77
97
|
}
|
|
78
98
|
}
|
|
79
|
-
|
|
99
|
+
class FormLoad extends ActionImpl {
|
|
80
100
|
constructor() {
|
|
81
101
|
super({}, 'load', { dispatch: false });
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
|
-
|
|
104
|
+
class Click extends ActionImpl {
|
|
85
105
|
constructor(payload, dispatch = false) {
|
|
86
106
|
super(payload, 'click', { dispatch });
|
|
87
107
|
}
|
|
88
108
|
}
|
|
89
|
-
|
|
109
|
+
class Blur extends ActionImpl {
|
|
90
110
|
constructor(payload, dispatch = false) {
|
|
91
111
|
super(payload, 'blur', { dispatch });
|
|
92
112
|
}
|
|
93
113
|
}
|
|
94
|
-
|
|
114
|
+
class ValidationComplete extends ActionImpl {
|
|
95
115
|
constructor(payload, dispatch = false) {
|
|
96
116
|
super(payload, 'validationComplete', { dispatch });
|
|
97
117
|
}
|
|
98
118
|
}
|
|
99
|
-
|
|
119
|
+
class Focus extends ActionImpl {
|
|
100
120
|
constructor() {
|
|
101
121
|
super({}, 'focus', { dispatch: false });
|
|
102
122
|
}
|
|
103
123
|
}
|
|
104
|
-
|
|
124
|
+
class Submit extends ActionImpl {
|
|
105
125
|
constructor(payload, dispatch = false) {
|
|
106
126
|
super(payload, 'submit', { dispatch });
|
|
107
127
|
}
|
|
108
128
|
}
|
|
109
|
-
|
|
129
|
+
class Reset extends ActionImpl {
|
|
110
130
|
constructor(payload, dispatch = false) {
|
|
111
131
|
super(payload, 'reset', { dispatch });
|
|
112
132
|
}
|
|
113
133
|
}
|
|
114
|
-
|
|
134
|
+
class FieldChanged extends ActionImpl {
|
|
115
135
|
constructor(changes, field) {
|
|
116
136
|
super({
|
|
117
137
|
field,
|
|
@@ -119,7 +139,7 @@ export class FieldChanged extends ActionImpl {
|
|
|
119
139
|
}, 'fieldChanged');
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
|
-
|
|
142
|
+
class CustomEvent extends ActionImpl {
|
|
123
143
|
constructor(eventName, payload = {}, dispatch = false) {
|
|
124
144
|
super(payload, eventName, { dispatch });
|
|
125
145
|
}
|
|
@@ -127,23 +147,25 @@ export class CustomEvent extends ActionImpl {
|
|
|
127
147
|
return true;
|
|
128
148
|
}
|
|
129
149
|
}
|
|
130
|
-
|
|
150
|
+
class AddItem extends ActionImpl {
|
|
131
151
|
constructor(payload) {
|
|
132
152
|
super(payload, 'addItem');
|
|
133
153
|
}
|
|
134
154
|
}
|
|
135
|
-
|
|
155
|
+
class RemoveItem extends ActionImpl {
|
|
136
156
|
constructor(payload) {
|
|
137
157
|
super(payload, 'removeItem');
|
|
138
158
|
}
|
|
139
159
|
}
|
|
140
|
-
|
|
160
|
+
class AddInstance extends ActionImpl {
|
|
141
161
|
constructor(payload) {
|
|
142
162
|
super(payload, 'addInstance');
|
|
143
163
|
}
|
|
144
164
|
}
|
|
145
|
-
|
|
165
|
+
class RemoveInstance extends ActionImpl {
|
|
146
166
|
constructor(payload) {
|
|
147
167
|
super(payload, 'removeInstance');
|
|
148
168
|
}
|
|
149
169
|
}
|
|
170
|
+
|
|
171
|
+
export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, Reset, Submit, Valid, ValidationComplete, propertyChange };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type LogFunction = 'info' | 'warn' | 'error' | 'debug';
|
|
2
|
+
export type LogLevel = 'off' | LogFunction;
|
|
3
3
|
export declare class Logger {
|
|
4
4
|
debug(msg: string): void;
|
|
5
5
|
info(msg: string): void;
|
|
@@ -1,3 +1,23 @@
|
|
|
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
|
+
|
|
1
21
|
const levels = {
|
|
2
22
|
off: 0,
|
|
3
23
|
debug: 1,
|
|
@@ -5,7 +25,7 @@ const levels = {
|
|
|
5
25
|
warn: 3,
|
|
6
26
|
error: 4
|
|
7
27
|
};
|
|
8
|
-
|
|
28
|
+
class Logger {
|
|
9
29
|
debug(msg) {
|
|
10
30
|
this.log(msg, 'debug');
|
|
11
31
|
}
|
|
@@ -28,3 +48,5 @@ export class Logger {
|
|
|
28
48
|
this.logLevel = levels[logLevel];
|
|
29
49
|
}
|
|
30
50
|
}
|
|
51
|
+
|
|
52
|
+
export { Logger };
|
|
@@ -1,6 +1,27 @@
|
|
|
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
|
+
|
|
1
21
|
import DataValue from './DataValue.js';
|
|
2
22
|
import NullDataValue from './EmptyDataValue.js';
|
|
3
|
-
|
|
23
|
+
|
|
24
|
+
class DataGroup extends DataValue {
|
|
4
25
|
$_items;
|
|
5
26
|
createEntry(key, value) {
|
|
6
27
|
const t = value instanceof Array ? 'array' : typeof value;
|
|
@@ -75,3 +96,5 @@ export default class DataGroup extends DataValue {
|
|
|
75
96
|
return true;
|
|
76
97
|
}
|
|
77
98
|
}
|
|
99
|
+
|
|
100
|
+
export { DataGroup as default };
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
|
|
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 DataValue {
|
|
2
22
|
$_name;
|
|
3
23
|
$_value;
|
|
4
24
|
$_type;
|
|
@@ -44,3 +64,5 @@ export default class DataValue {
|
|
|
44
64
|
return false;
|
|
45
65
|
}
|
|
46
66
|
}
|
|
67
|
+
|
|
68
|
+
export { DataValue as default };
|
|
@@ -1,4 +1,25 @@
|
|
|
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
|
+
|
|
1
21
|
import DataValue from './DataValue.js';
|
|
22
|
+
|
|
2
23
|
const value = Symbol('NullValue');
|
|
3
24
|
class NullDataValueClass extends DataValue {
|
|
4
25
|
constructor() {
|
|
@@ -26,4 +47,5 @@ class NullDataValueClass extends DataValue {
|
|
|
26
47
|
}
|
|
27
48
|
}
|
|
28
49
|
const NullDataValue = new NullDataValueClass();
|
|
29
|
-
|
|
50
|
+
|
|
51
|
+
export { NullDataValue as default };
|
package/lib/esm/index.js
CHANGED
|
@@ -1,21 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export {
|
|
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-dc59ab07.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,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type HTTP_VERB = 'GET' | 'POST';
|
|
2
2
|
export declare const request: (context: any, uri: string, httpVerb: HTTP_VERB, payload: any, success: string, error: string, headers: any) => Promise<void>;
|
|
3
3
|
export declare const submit: (context: any, success: string, error: string, submitAs?: 'application/json' | 'multipart/form-data', input_data?: any) => Promise<void>;
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type CustomFunction = Function;
|
|
5
|
+
export type FunctionDefinition = {
|
|
6
6
|
_func: CustomFunction;
|
|
7
7
|
_signature: Array<any>;
|
|
8
8
|
};
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { CustomEvent, Submit, RemoveInstance, AddInstance, Reset, RemoveItem, AddItem, Click, Change } from '../controller/Events.js';
|
|
22
|
+
import { request as request$1 } from '../utils/Fetch.js';
|
|
3
23
|
import { FileObject } from '../FileObject.js';
|
|
4
24
|
import { getAttachments } from '../utils/FormUtils.js';
|
|
5
25
|
import { jsonString } from '../utils/JsonUtils.js';
|
|
26
|
+
import '../types/Json.js';
|
|
27
|
+
import '../utils/SchemaUtils.js';
|
|
28
|
+
|
|
6
29
|
const getCustomEventName = (name) => {
|
|
7
30
|
const eName = name;
|
|
8
31
|
if (eName.length > 0 && eName.startsWith('custom:')) {
|
|
@@ -10,7 +33,7 @@ const getCustomEventName = (name) => {
|
|
|
10
33
|
}
|
|
11
34
|
return eName;
|
|
12
35
|
};
|
|
13
|
-
|
|
36
|
+
const request = async (context, uri, httpVerb, payload, success, error, headers) => {
|
|
14
37
|
const endpoint = uri;
|
|
15
38
|
const requestOptions = {
|
|
16
39
|
method: httpVerb
|
|
@@ -48,7 +71,7 @@ export const request = async (context, uri, httpVerb, payload, success, error, h
|
|
|
48
71
|
inputPayload = urlEncoded(payload);
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
|
-
result = await
|
|
74
|
+
result = await request$1(endpoint, inputPayload, requestOptions);
|
|
52
75
|
}
|
|
53
76
|
catch (e) {
|
|
54
77
|
context.form.logger.error('Error invoking a rest API');
|
|
@@ -103,7 +126,7 @@ const multipartFormData = (data, attachments) => {
|
|
|
103
126
|
}
|
|
104
127
|
return formData;
|
|
105
128
|
};
|
|
106
|
-
|
|
129
|
+
const submit = async (context, success, error, submitAs = 'multipart/form-data', input_data = null) => {
|
|
107
130
|
const endpoint = context.form.action;
|
|
108
131
|
let data = input_data;
|
|
109
132
|
if (typeof data != 'object' || data == null) {
|
|
@@ -317,4 +340,6 @@ class FunctionRuntimeImpl {
|
|
|
317
340
|
return { ...defaultFunctions, ...this.customFunctions };
|
|
318
341
|
}
|
|
319
342
|
}
|
|
320
|
-
|
|
343
|
+
const FunctionRuntime = new FunctionRuntimeImpl();
|
|
344
|
+
|
|
345
|
+
export { FunctionRuntime, request, submit };
|
|
@@ -1,5 +1,33 @@
|
|
|
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
|
+
|
|
1
21
|
import Formula from '@adobe/json-formula';
|
|
2
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
|
+
|
|
3
31
|
class RuleEngine {
|
|
4
32
|
_context;
|
|
5
33
|
_globalNames = [
|
|
@@ -44,4 +72,5 @@ class RuleEngine {
|
|
|
44
72
|
}
|
|
45
73
|
}
|
|
46
74
|
}
|
|
47
|
-
|
|
75
|
+
|
|
76
|
+
export { RuleEngine as default };
|
package/lib/esm/types/Json.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Items<T> = {
|
|
2
2
|
[key: string]: T;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type Primitives = string | number | boolean | null | undefined;
|
|
5
|
+
export type Label = {
|
|
6
6
|
value: string;
|
|
7
7
|
richText?: boolean;
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type TranslationConstraintsJson = {
|
|
11
11
|
enumNames?: string[];
|
|
12
12
|
enum?: any[];
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type ConstraintsJson = TranslationConstraintsJson & {
|
|
15
15
|
accept?: string[];
|
|
16
16
|
enforceEnum?: boolean;
|
|
17
17
|
exclusiveMinimum?: number;
|
|
@@ -33,7 +33,7 @@ export declare type ConstraintsJson = TranslationConstraintsJson & {
|
|
|
33
33
|
validationExpression?: string;
|
|
34
34
|
uniqueItems?: boolean;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type ConstraintsMessages = {
|
|
37
37
|
accept?: string;
|
|
38
38
|
enum?: string;
|
|
39
39
|
exclusiveMinimum?: string;
|
|
@@ -53,14 +53,14 @@ export declare type ConstraintsMessages = {
|
|
|
53
53
|
type?: string;
|
|
54
54
|
validationExpression?: string;
|
|
55
55
|
};
|
|
56
|
-
export
|
|
56
|
+
export type RulesJson = {
|
|
57
57
|
rules?: Items<string>;
|
|
58
58
|
events?: Items<string[] | string | undefined>;
|
|
59
59
|
};
|
|
60
|
-
|
|
60
|
+
type TranslationBaseJson = {
|
|
61
61
|
description?: string;
|
|
62
62
|
};
|
|
63
|
-
export
|
|
63
|
+
export type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
|
|
64
64
|
dataRef?: string | null;
|
|
65
65
|
':type'?: string;
|
|
66
66
|
label?: Label;
|
|
@@ -79,10 +79,10 @@ export declare type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson
|
|
|
79
79
|
altText?: string;
|
|
80
80
|
viewType?: string;
|
|
81
81
|
};
|
|
82
|
-
|
|
82
|
+
type TranslationFieldJson = {
|
|
83
83
|
placeholder?: string;
|
|
84
84
|
};
|
|
85
|
-
export
|
|
85
|
+
export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
86
86
|
readOnly?: boolean;
|
|
87
87
|
valid?: boolean;
|
|
88
88
|
default?: any;
|
|
@@ -93,19 +93,19 @@ export declare type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
93
93
|
displayValue?: string;
|
|
94
94
|
emptyValue?: 'null' | 'undefined' | '';
|
|
95
95
|
};
|
|
96
|
-
export
|
|
96
|
+
export type ContainerJson = BaseJson & {
|
|
97
97
|
items: Array<FieldJson | ContainerJson>;
|
|
98
98
|
initialItems?: number;
|
|
99
99
|
activeChild?: string;
|
|
100
100
|
};
|
|
101
|
-
export
|
|
101
|
+
export type MetaDataJson = {
|
|
102
102
|
version?: string;
|
|
103
103
|
grammar?: string;
|
|
104
104
|
};
|
|
105
|
-
export
|
|
105
|
+
export type FieldsetJson = ContainerJson & {
|
|
106
106
|
'type'?: 'array' | 'object';
|
|
107
107
|
};
|
|
108
|
-
export
|
|
108
|
+
export type FormJson = ContainerJson & {
|
|
109
109
|
metadata?: MetaDataJson;
|
|
110
110
|
data?: any;
|
|
111
111
|
title?: string;
|
|
@@ -113,7 +113,7 @@ export declare type FormJson = ContainerJson & {
|
|
|
113
113
|
adaptiveForm?: string;
|
|
114
114
|
lang?: string;
|
|
115
115
|
};
|
|
116
|
-
export
|
|
116
|
+
export type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
|
|
117
117
|
export declare const translationProps: string[];
|
|
118
118
|
export declare const constraintProps: string[];
|
|
119
119
|
export {};
|
package/lib/esm/types/Json.js
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
|
|
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',
|
|
2
22
|
'constraintMessages.enum', 'constraintMessages.exclusiveMinimum', 'constraintMessages.exclusiveMaximum', 'constraintMessages.format', 'constraintMessages.maxFileSize', 'constraintMessages.maxLength',
|
|
3
23
|
'constraintMessages.maximum', 'constraintMessages.maxItems', 'constraintMessages.minLength', 'constraintMessages.minimum', 'constraintMessages.minItems', 'constraintMessages.pattern', 'constraintMessages.required',
|
|
4
24
|
'constraintMessages.step', 'constraintMessages.type', 'constraintMessages.validationExpression'];
|
|
5
|
-
|
|
25
|
+
const constraintProps = ['accept', 'enum', 'exclusiveMinimum', 'exclusiveMaximum',
|
|
6
26
|
'format', 'maxFileSize', 'maxLength', 'maximum', 'maxItems',
|
|
7
27
|
'minLength', 'minimum', 'minItems', 'pattern', 'required', 'step', 'validationExpression', 'enumNames'];
|
|
28
|
+
|
|
29
|
+
export { constraintProps, translationProps };
|
package/lib/esm/types/Model.d.ts
CHANGED
|
@@ -15,15 +15,15 @@ export interface ScriptableField {
|
|
|
15
15
|
interface WithState<T> {
|
|
16
16
|
getState: () => any;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
type stateProps = {
|
|
19
19
|
id: string;
|
|
20
20
|
index: number;
|
|
21
21
|
':type': string;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type State<T> = stateProps & (T extends ContainerJson ? T & {
|
|
24
24
|
items: Array<State<FieldJson | ContainerJson>>;
|
|
25
25
|
} : T);
|
|
26
|
-
export
|
|
26
|
+
export type Subscription = {
|
|
27
27
|
unsubscribe(): void;
|
|
28
28
|
};
|
|
29
29
|
export interface Action {
|
|
@@ -34,7 +34,7 @@ export interface Action {
|
|
|
34
34
|
readonly target: FormModel | FieldModel | FieldsetModel;
|
|
35
35
|
readonly originalAction?: Action;
|
|
36
36
|
}
|
|
37
|
-
export
|
|
37
|
+
export type callbackFn = (action: Action) => void;
|
|
38
38
|
export interface WithController {
|
|
39
39
|
subscribe(callback: callbackFn, eventName?: string): Subscription;
|
|
40
40
|
dispatch(action: Action): void;
|