@aemforms/af-core 0.22.19 → 0.22.22
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/lib/cjs/index.cjs +7277 -0
- package/lib/{BaseNode.js → esm/BaseNode-dc59ab07.js} +108 -184
- package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +10 -69
- package/lib/esm/BaseNode.js +26 -0
- package/lib/esm/Checkbox.d.ts +79 -0
- package/lib/esm/Checkbox.js +63 -0
- package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
- package/lib/esm/CheckboxGroup.js +60 -0
- package/lib/{Container.d.ts → esm/Container.d.ts} +12 -59
- package/lib/{Container.js → esm/Container.js} +81 -122
- package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
- package/lib/esm/DateField.js +57 -0
- package/lib/{Field.d.ts → esm/Field.d.ts} +41 -106
- package/lib/{Field.js → esm/Field.js} +186 -216
- package/lib/esm/Fieldset.d.ts +16 -0
- package/lib/esm/Fieldset.js +78 -0
- package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
- package/lib/esm/FileObject.js +48 -0
- package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
- package/lib/esm/FileUpload.js +141 -0
- package/lib/{Form.d.ts → esm/Form.d.ts} +20 -86
- package/lib/esm/Form.js +208 -0
- package/lib/esm/FormInstance.d.ts +13 -0
- package/lib/esm/FormInstance.js +129 -0
- package/lib/esm/FormMetaData.d.ts +7 -0
- package/lib/esm/FormMetaData.js +35 -0
- package/lib/esm/InstanceManager.d.ts +9 -0
- package/lib/esm/InstanceManager.js +58 -0
- package/lib/esm/Node.d.ts +7 -0
- package/lib/esm/Node.js +40 -0
- package/lib/esm/Scriptable.d.ts +17 -0
- package/lib/{Scriptable.js → esm/Scriptable.js} +38 -54
- package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
- package/lib/{controller → esm/controller}/EventQueue.js +32 -26
- package/lib/esm/controller/Events.d.ts +85 -0
- package/lib/esm/controller/Events.js +171 -0
- package/lib/{controller → esm/controller}/Logger.d.ts +2 -8
- package/lib/esm/controller/Logger.js +52 -0
- package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
- package/lib/{data → esm/data}/DataGroup.js +38 -34
- package/lib/{data → esm/data}/DataValue.d.ts +1 -7
- package/lib/esm/data/DataValue.js +68 -0
- package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
- package/lib/esm/data/EmptyDataValue.js +51 -0
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.js +55 -0
- package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +3 -25
- package/lib/{rules → esm/rules}/FunctionRuntime.js +66 -117
- package/lib/esm/rules/RuleEngine.d.ts +12 -0
- package/lib/esm/rules/RuleEngine.js +76 -0
- package/lib/esm/types/Json.d.ts +119 -0
- package/lib/esm/types/Json.js +29 -0
- package/lib/esm/types/Model.d.ts +131 -0
- package/lib/esm/types/Model.js +30 -0
- package/lib/esm/types/index.d.ts +2 -0
- package/lib/esm/types/index.js +22 -0
- package/lib/{utils → esm/utils}/DataRefParser.d.ts +4 -7
- package/lib/{utils → esm/utils}/DataRefParser.js +42 -44
- package/lib/{utils → esm/utils}/Fetch.d.ts +1 -7
- package/lib/esm/utils/Fetch.js +83 -0
- package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
- package/lib/esm/utils/FormCreationUtils.js +112 -0
- package/lib/esm/utils/FormUtils.d.ts +12 -0
- package/lib/esm/utils/FormUtils.js +212 -0
- package/lib/esm/utils/JsonUtils.d.ts +11 -0
- package/lib/esm/utils/JsonUtils.js +99 -0
- package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
- package/lib/esm/utils/LogUtils.js +28 -0
- package/lib/esm/utils/SchemaUtils.d.ts +3 -0
- package/lib/esm/utils/SchemaUtils.js +93 -0
- package/lib/esm/utils/TranslationUtils.d.ts +11 -0
- package/lib/esm/utils/TranslationUtils.js +138 -0
- package/lib/esm/utils/ValidationUtils.d.ts +19 -0
- package/lib/{utils → esm/utils}/ValidationUtils.js +55 -187
- package/package.json +18 -10
- package/lib/Checkbox.d.ts +0 -88
- package/lib/Checkbox.js +0 -49
- package/lib/CheckboxGroup.js +0 -43
- package/lib/DateField.js +0 -35
- package/lib/Fieldset.d.ts +0 -24
- package/lib/Fieldset.js +0 -74
- package/lib/FileObject.js +0 -39
- package/lib/FileUpload.js +0 -155
- package/lib/Form.js +0 -252
- package/lib/FormInstance.d.ts +0 -38
- package/lib/FormInstance.js +0 -127
- package/lib/FormMetaData.d.ts +0 -11
- package/lib/FormMetaData.js +0 -28
- package/lib/InstanceManager.d.ts +0 -16
- package/lib/InstanceManager.js +0 -53
- package/lib/Node.d.ts +0 -12
- package/lib/Node.js +0 -27
- package/lib/Scriptable.d.ts +0 -31
- package/lib/controller/Controller.d.ts +0 -255
- package/lib/controller/Controller.js +0 -328
- package/lib/controller/Logger.js +0 -36
- package/lib/controller/index.d.ts +0 -1
- package/lib/controller/index.js +0 -24
- package/lib/data/DataValue.js +0 -56
- package/lib/data/EmptyDataValue.js +0 -46
- package/lib/index.d.ts +0 -28
- package/lib/index.js +0 -63
- package/lib/rules/RuleEngine.d.ts +0 -23
- package/lib/rules/RuleEngine.js +0 -62
- package/lib/types/Json.d.ts +0 -138
- package/lib/types/Json.js +0 -19
- package/lib/types/Model.d.ts +0 -393
- package/lib/types/Model.js +0 -20
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -25
- package/lib/utils/Fetch.js +0 -87
- package/lib/utils/FormCreationUtils.d.ts +0 -11
- package/lib/utils/FormCreationUtils.js +0 -83
- package/lib/utils/FormUtils.d.ts +0 -47
- package/lib/utils/FormUtils.js +0 -257
- package/lib/utils/JsonUtils.d.ts +0 -63
- package/lib/utils/JsonUtils.js +0 -157
- package/lib/utils/LogUtils.js +0 -17
- package/lib/utils/SchemaUtils.d.ts +0 -16
- package/lib/utils/SchemaUtils.js +0 -92
- package/lib/utils/TranslationUtils.d.ts +0 -41
- package/lib/utils/TranslationUtils.js +0 -185
- package/lib/utils/ValidationUtils.d.ts +0 -170
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ConstraintsJson, ContainerJson, FieldJson, FieldsetJson, FormJson, Label, MetaDataJson } from './Json.js';
|
|
2
|
+
import RuleEngine from '../rules/RuleEngine.js';
|
|
3
|
+
import EventQueue from '../controller/EventQueue.js';
|
|
4
|
+
import DataGroup from '../data/DataGroup.js';
|
|
5
|
+
import { Logger } from '../controller/Logger.js';
|
|
6
|
+
export interface ScriptableField {
|
|
7
|
+
rules?: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
events?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
ruleEngine: RuleEngine;
|
|
14
|
+
}
|
|
15
|
+
interface WithState<T> {
|
|
16
|
+
getState: () => any;
|
|
17
|
+
}
|
|
18
|
+
type stateProps = {
|
|
19
|
+
id: string;
|
|
20
|
+
index: number;
|
|
21
|
+
':type': string;
|
|
22
|
+
};
|
|
23
|
+
export type State<T> = stateProps & (T extends ContainerJson ? T & {
|
|
24
|
+
items: Array<State<FieldJson | ContainerJson>>;
|
|
25
|
+
} : T);
|
|
26
|
+
export type Subscription = {
|
|
27
|
+
unsubscribe(): void;
|
|
28
|
+
};
|
|
29
|
+
export interface Action {
|
|
30
|
+
type: string;
|
|
31
|
+
payload: any;
|
|
32
|
+
metadata: any;
|
|
33
|
+
readonly isCustomEvent: boolean;
|
|
34
|
+
readonly target: FormModel | FieldModel | FieldsetModel;
|
|
35
|
+
readonly originalAction?: Action;
|
|
36
|
+
}
|
|
37
|
+
export type callbackFn = (action: Action) => void;
|
|
38
|
+
export interface WithController {
|
|
39
|
+
subscribe(callback: callbackFn, eventName?: string): Subscription;
|
|
40
|
+
dispatch(action: Action): void;
|
|
41
|
+
}
|
|
42
|
+
export interface BaseModel extends ConstraintsJson, WithController {
|
|
43
|
+
readonly name?: string;
|
|
44
|
+
readonly dataRef?: string | null;
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly index: number;
|
|
47
|
+
readonly qualifiedName: string;
|
|
48
|
+
label?: Label;
|
|
49
|
+
description?: string;
|
|
50
|
+
readOnly?: boolean;
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
visible?: boolean;
|
|
53
|
+
placeholder?: string;
|
|
54
|
+
valid?: boolean;
|
|
55
|
+
readonly ':type': string;
|
|
56
|
+
readonly 'fieldType': string;
|
|
57
|
+
properties: {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
readonly isContainer: boolean;
|
|
61
|
+
readonly parent: ContainerModel | null;
|
|
62
|
+
readonly items?: Array<FieldsetModel | FieldModel>;
|
|
63
|
+
value: any;
|
|
64
|
+
readonly default?: any;
|
|
65
|
+
readonly repeatable?: boolean;
|
|
66
|
+
readonly language?: string;
|
|
67
|
+
validate(): Array<ValidationError>;
|
|
68
|
+
reset(): any;
|
|
69
|
+
importData(a?: DataGroup): any;
|
|
70
|
+
getRuleNode(): any;
|
|
71
|
+
ruleNodeReference(): any;
|
|
72
|
+
_initialize(): any;
|
|
73
|
+
_addDependent(dependent: BaseModel): any;
|
|
74
|
+
}
|
|
75
|
+
export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJson> {
|
|
76
|
+
parent: ContainerModel;
|
|
77
|
+
readonly editFormat?: string;
|
|
78
|
+
readonly displayFormat?: string;
|
|
79
|
+
readonly displayValue?: string;
|
|
80
|
+
readonly editValue?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface FormMetaDataModel {
|
|
83
|
+
readonly version: string;
|
|
84
|
+
readonly grammar: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ContainerModel extends BaseModel, ScriptableField {
|
|
87
|
+
items: Array<FieldsetModel | FieldModel>;
|
|
88
|
+
parent: ContainerModel;
|
|
89
|
+
indexOf(f: FieldModel | FieldsetModel): number;
|
|
90
|
+
isTransparent(): boolean;
|
|
91
|
+
activeChild: BaseModel | null;
|
|
92
|
+
}
|
|
93
|
+
export interface FieldsetModel extends ContainerModel, WithState<FieldsetJson> {
|
|
94
|
+
type?: 'array' | 'object';
|
|
95
|
+
}
|
|
96
|
+
export interface FormModel extends ContainerModel, WithState<FormJson> {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly data?: any;
|
|
99
|
+
readonly metadata?: MetaDataJson;
|
|
100
|
+
readonly title: string;
|
|
101
|
+
readonly logger: Logger;
|
|
102
|
+
importData(data: any): any;
|
|
103
|
+
exportData(): any;
|
|
104
|
+
getElement(id: string): FieldModel | FormModel | FieldsetModel;
|
|
105
|
+
getUniqueId(): string;
|
|
106
|
+
getEventQueue(): EventQueue;
|
|
107
|
+
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
108
|
+
fieldAdded(field: FieldModel | FieldsetModel): void;
|
|
109
|
+
}
|
|
110
|
+
export interface IFormFieldFactory {
|
|
111
|
+
createField(child: FieldsetJson | FieldJson, options: {
|
|
112
|
+
form: FormModel;
|
|
113
|
+
parent: ContainerModel;
|
|
114
|
+
}): FieldModel | FieldsetModel;
|
|
115
|
+
}
|
|
116
|
+
export interface IFileObject {
|
|
117
|
+
name: string;
|
|
118
|
+
mediaType: string;
|
|
119
|
+
data?: any;
|
|
120
|
+
size?: number;
|
|
121
|
+
}
|
|
122
|
+
export interface IValidationError {
|
|
123
|
+
fieldName: string;
|
|
124
|
+
errorMessages: Array<string>;
|
|
125
|
+
}
|
|
126
|
+
export declare class ValidationError implements IValidationError {
|
|
127
|
+
fieldName: string;
|
|
128
|
+
errorMessages: Array<string>;
|
|
129
|
+
constructor(fieldName?: string, errorMessages?: Array<any>);
|
|
130
|
+
}
|
|
131
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 };
|
|
@@ -0,0 +1,22 @@
|
|
|
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';
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import DataGroup from '../data/DataGroup';
|
|
5
|
-
import DataValue from '../data/DataValue';
|
|
6
|
-
declare type TokenType = string;
|
|
1
|
+
import DataGroup from '../data/DataGroup.js';
|
|
2
|
+
import DataValue from '../data/DataValue.js';
|
|
3
|
+
type TokenType = string;
|
|
7
4
|
export declare const TOK_GLOBAL: TokenType;
|
|
8
|
-
export
|
|
5
|
+
export type Token = {
|
|
9
6
|
type: TokenType;
|
|
10
7
|
value: string | number;
|
|
11
8
|
start: number;
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 DataGroup from '../data/DataGroup.js';
|
|
22
|
+
import '../data/DataValue.js';
|
|
23
|
+
import '../data/EmptyDataValue.js';
|
|
24
|
+
|
|
18
25
|
const TOK_DOT = 'DOT';
|
|
19
26
|
const TOK_IDENTIFIER = 'Identifier';
|
|
20
|
-
|
|
27
|
+
const TOK_GLOBAL = 'Global';
|
|
21
28
|
const TOK_BRACKET = 'bracket';
|
|
22
29
|
const TOK_NUMBER = 'Number';
|
|
23
30
|
const globalStartToken = '$';
|
|
@@ -28,7 +35,6 @@ const identifier = (value, start) => {
|
|
|
28
35
|
start
|
|
29
36
|
};
|
|
30
37
|
};
|
|
31
|
-
exports.identifier = identifier;
|
|
32
38
|
const bracket = (value, start) => {
|
|
33
39
|
return {
|
|
34
40
|
type: TOK_BRACKET,
|
|
@@ -36,15 +42,13 @@ const bracket = (value, start) => {
|
|
|
36
42
|
start
|
|
37
43
|
};
|
|
38
44
|
};
|
|
39
|
-
exports.bracket = bracket;
|
|
40
45
|
const global$ = () => {
|
|
41
46
|
return {
|
|
42
|
-
type:
|
|
47
|
+
type: TOK_GLOBAL,
|
|
43
48
|
start: 0,
|
|
44
49
|
value: globalStartToken
|
|
45
50
|
};
|
|
46
51
|
};
|
|
47
|
-
exports.global$ = global$;
|
|
48
52
|
const isAlphaNum = function (ch) {
|
|
49
53
|
return (ch >= 'a' && ch <= 'z')
|
|
50
54
|
|| (ch >= 'A' && ch <= 'Z')
|
|
@@ -52,16 +56,13 @@ const isAlphaNum = function (ch) {
|
|
|
52
56
|
|| ch === '_';
|
|
53
57
|
};
|
|
54
58
|
const isGlobal = (prev, stream, pos) => {
|
|
55
|
-
// global tokens occur only at the start of an expression
|
|
56
59
|
return prev === null && stream[pos] === globalStartToken;
|
|
57
60
|
};
|
|
58
61
|
const isIdentifier = (stream, pos) => {
|
|
59
62
|
const ch = stream[pos];
|
|
60
|
-
// $ is special -- it's allowed to be part of an identifier if it's the first character
|
|
61
63
|
if (ch === '$') {
|
|
62
64
|
return stream.length > pos && isAlphaNum(stream[pos + 1]);
|
|
63
65
|
}
|
|
64
|
-
// return whether character 'isAlpha'
|
|
65
66
|
return (ch >= 'a' && ch <= 'z')
|
|
66
67
|
|| (ch >= 'A' && ch <= 'Z')
|
|
67
68
|
|| ch === '_';
|
|
@@ -70,15 +71,17 @@ const isNum = (ch) => {
|
|
|
70
71
|
return (ch >= '0' && ch <= '9');
|
|
71
72
|
};
|
|
72
73
|
class Tokenizer {
|
|
74
|
+
stream;
|
|
75
|
+
_current;
|
|
76
|
+
_tokens = [];
|
|
77
|
+
_result_tokens = [];
|
|
73
78
|
constructor(stream) {
|
|
74
79
|
this.stream = stream;
|
|
75
|
-
this._tokens = [];
|
|
76
|
-
this._result_tokens = [];
|
|
77
80
|
this._current = 0;
|
|
78
81
|
}
|
|
79
82
|
_consumeGlobal() {
|
|
80
83
|
this._current += 1;
|
|
81
|
-
return
|
|
84
|
+
return global$();
|
|
82
85
|
}
|
|
83
86
|
_consumeUnquotedIdentifier(stream) {
|
|
84
87
|
const start = this._current;
|
|
@@ -86,14 +89,13 @@ class Tokenizer {
|
|
|
86
89
|
while (this._current < stream.length && isAlphaNum(stream[this._current])) {
|
|
87
90
|
this._current += 1;
|
|
88
91
|
}
|
|
89
|
-
return
|
|
92
|
+
return identifier(stream.slice(start, this._current), start);
|
|
90
93
|
}
|
|
91
94
|
_consumeQuotedIdentifier(stream) {
|
|
92
95
|
const start = this._current;
|
|
93
96
|
this._current += 1;
|
|
94
97
|
const maxLength = stream.length;
|
|
95
98
|
while (stream[this._current] !== '"' && this._current < maxLength) {
|
|
96
|
-
// You can escape a double quote and you can escape an escape.
|
|
97
99
|
let current = this._current;
|
|
98
100
|
if (stream[current] === '\\' && (stream[current + 1] === '\\'
|
|
99
101
|
|| stream[current + 1] === '"')) {
|
|
@@ -105,7 +107,7 @@ class Tokenizer {
|
|
|
105
107
|
this._current = current;
|
|
106
108
|
}
|
|
107
109
|
this._current += 1;
|
|
108
|
-
return
|
|
110
|
+
return identifier(JSON.parse(stream.slice(start, this._current)), start);
|
|
109
111
|
}
|
|
110
112
|
_consumeNumber(stream) {
|
|
111
113
|
const start = this._current;
|
|
@@ -132,7 +134,7 @@ class Tokenizer {
|
|
|
132
134
|
throw new Error(`unexpected exception at position ${this._current}. Must be a character`);
|
|
133
135
|
}
|
|
134
136
|
this._current++;
|
|
135
|
-
return
|
|
137
|
+
return bracket(value, start);
|
|
136
138
|
}
|
|
137
139
|
tokenize() {
|
|
138
140
|
const stream = this.stream;
|
|
@@ -157,8 +159,6 @@ class Tokenizer {
|
|
|
157
159
|
this._current += 1;
|
|
158
160
|
}
|
|
159
161
|
else if (stream[this._current] === '[') {
|
|
160
|
-
// No need to increment this._current. This happens
|
|
161
|
-
// in _consumeLBracket
|
|
162
162
|
const token = this._consumeBracket(stream);
|
|
163
163
|
this._tokens.push(token);
|
|
164
164
|
this._result_tokens.push(token);
|
|
@@ -180,11 +180,10 @@ class Tokenizer {
|
|
|
180
180
|
const tokenize = (stream) => {
|
|
181
181
|
return new Tokenizer(stream).tokenize();
|
|
182
182
|
};
|
|
183
|
-
exports.tokenize = tokenize;
|
|
184
183
|
const resolveData = (data, input, create) => {
|
|
185
184
|
let tokens;
|
|
186
185
|
if (typeof input === 'string') {
|
|
187
|
-
tokens =
|
|
186
|
+
tokens = tokenize(input);
|
|
188
187
|
}
|
|
189
188
|
else {
|
|
190
189
|
tokens = input;
|
|
@@ -193,17 +192,16 @@ const resolveData = (data, input, create) => {
|
|
|
193
192
|
let i = 0;
|
|
194
193
|
const createIntermediateNode = (token, nextToken, create) => {
|
|
195
194
|
return nextToken === null ? create :
|
|
196
|
-
(nextToken.type === TOK_BRACKET) ? new
|
|
197
|
-
new
|
|
195
|
+
(nextToken.type === TOK_BRACKET) ? new DataGroup(token.value, [], 'array') :
|
|
196
|
+
new DataGroup(token.value, {});
|
|
198
197
|
};
|
|
199
198
|
while (i < tokens.length && result != null) {
|
|
200
199
|
const token = tokens[i];
|
|
201
|
-
if (token.type ===
|
|
200
|
+
if (token.type === TOK_GLOBAL) {
|
|
202
201
|
result = data;
|
|
203
202
|
}
|
|
204
203
|
else if (token.type === TOK_IDENTIFIER) {
|
|
205
|
-
if (result instanceof
|
|
206
|
-
//@ts-ignore
|
|
204
|
+
if (result instanceof DataGroup && result.$type === 'object') {
|
|
207
205
|
if (result.$containsDataNode(token.value) && result.$getDataNode(token.value).$value !== null) {
|
|
208
206
|
result = result.$getDataNode(token.value);
|
|
209
207
|
}
|
|
@@ -222,10 +220,9 @@ const resolveData = (data, input, create) => {
|
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
222
|
else if (token.type === TOK_BRACKET) {
|
|
225
|
-
if (result instanceof
|
|
223
|
+
if (result instanceof DataGroup && result.$type === 'array') {
|
|
226
224
|
const index = token.value;
|
|
227
225
|
if (index < result.$length) {
|
|
228
|
-
//@ts-ignore
|
|
229
226
|
result = result.$getDataNode(index);
|
|
230
227
|
}
|
|
231
228
|
else if (create) {
|
|
@@ -246,4 +243,5 @@ const resolveData = (data, input, create) => {
|
|
|
246
243
|
}
|
|
247
244
|
return result;
|
|
248
245
|
};
|
|
249
|
-
|
|
246
|
+
|
|
247
|
+
export { TOK_GLOBAL, bracket, global$, identifier, resolveData, tokenize };
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param url
|
|
4
|
-
* @param data
|
|
5
|
-
* @param options
|
|
6
|
-
*/
|
|
7
1
|
export declare const request: (url: string, data?: any, options?: RequestOptions) => any;
|
|
8
|
-
export
|
|
2
|
+
export type RequestOptions = {
|
|
9
3
|
contentType?: string;
|
|
10
4
|
method?: 'POST' | 'GET';
|
|
11
5
|
headers?: any;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContainerModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, FormModel, IFormFieldFactory } from '../types/index.js';
|
|
2
|
+
declare class FormFieldFactoryImpl implements IFormFieldFactory {
|
|
3
|
+
createField(child: FieldsetJson | FieldJson, _options: {
|
|
4
|
+
form: FormModel;
|
|
5
|
+
parent: ContainerModel;
|
|
6
|
+
}): FieldModel | FieldsetModel;
|
|
7
|
+
}
|
|
8
|
+
export declare const FormFieldFactory: FormFieldFactoryImpl;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
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-dc59ab07.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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ContainerModel } from '../types/index.js';
|
|
2
|
+
export declare const randomWord: (l: number) => string;
|
|
3
|
+
export declare const isEmpty: (value: any) => boolean;
|
|
4
|
+
export declare const getAttachments: (input: ContainerModel) => any;
|
|
5
|
+
export declare const getFileSizeInBytes: (str: any) => number;
|
|
6
|
+
export declare const IdGenerator: (initial?: number) => Generator<string, void, string>;
|
|
7
|
+
export declare const isDataUrl: (str: string) => boolean;
|
|
8
|
+
export declare const extractFileInfo: (file: any) => any;
|
|
9
|
+
export declare const dataURItoBlob: (dataURI: string) => {
|
|
10
|
+
name: string;
|
|
11
|
+
blob: Blob;
|
|
12
|
+
} | null;
|