@aemforms/af-core 0.22.18 → 0.22.20
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/browser/afb-events.js +151 -0
- package/lib/browser/afb-runtime.js +3620 -0
- package/lib/cjs/index.cjs +8886 -0
- package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +11 -68
- package/lib/{BaseNode.js → esm/BaseNode.js} +86 -182
- package/lib/esm/Checkbox.d.ts +79 -0
- package/lib/esm/Checkbox.js +27 -0
- package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
- package/lib/esm/CheckboxGroup.js +23 -0
- package/lib/esm/Container.d.ts +53 -0
- package/lib/{Container.js → esm/Container.js} +76 -124
- package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
- package/lib/esm/DateField.js +21 -0
- package/lib/{Field.d.ts → esm/Field.d.ts} +44 -98
- package/lib/{Field.js → esm/Field.js} +172 -206
- package/lib/esm/Fieldset.d.ts +16 -0
- package/lib/esm/Fieldset.js +45 -0
- package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
- package/lib/esm/FileObject.js +26 -0
- package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
- package/lib/esm/FileUpload.js +108 -0
- package/lib/esm/Form.d.ts +113 -0
- package/lib/esm/Form.js +176 -0
- package/lib/esm/FormInstance.d.ts +13 -0
- package/lib/esm/FormInstance.js +81 -0
- package/lib/esm/FormMetaData.d.ts +7 -0
- package/lib/esm/FormMetaData.js +10 -0
- package/lib/esm/InstanceManager.d.ts +9 -0
- package/lib/esm/InstanceManager.js +31 -0
- package/lib/esm/Node.d.ts +7 -0
- package/lib/esm/Node.js +16 -0
- package/lib/esm/Scriptable.d.ts +17 -0
- package/lib/{Scriptable.js → esm/Scriptable.js} +12 -55
- package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
- package/lib/{controller → esm/controller}/EventQueue.js +10 -26
- package/lib/esm/controller/Events.d.ts +85 -0
- package/lib/esm/controller/Events.js +149 -0
- package/lib/{controller → esm/controller}/Logger.d.ts +0 -6
- package/lib/{controller → esm/controller}/Logger.js +5 -11
- package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
- package/lib/{data → esm/data}/DataGroup.js +20 -35
- package/lib/{data → esm/data}/DataValue.d.ts +2 -8
- package/lib/esm/data/DataValue.js +46 -0
- package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
- package/lib/esm/data/EmptyDataValue.js +29 -0
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.js +21 -0
- package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +2 -24
- package/lib/{rules → esm/rules}/FunctionRuntime.js +44 -114
- package/lib/esm/rules/RuleEngine.d.ts +12 -0
- package/lib/esm/rules/RuleEngine.js +47 -0
- package/lib/{types → esm/types}/Json.d.ts +6 -22
- package/lib/esm/types/Json.js +7 -0
- package/lib/esm/types/Model.d.ts +131 -0
- package/lib/esm/types/Model.js +8 -0
- package/lib/esm/types/index.d.ts +2 -0
- package/lib/esm/types/index.js +2 -0
- package/lib/{utils → esm/utils}/DataRefParser.d.ts +2 -5
- package/lib/{utils → esm/utils}/DataRefParser.js +22 -49
- package/lib/{utils → esm/utils}/Fetch.d.ts +1 -0
- package/lib/esm/utils/Fetch.js +61 -0
- package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
- package/lib/esm/utils/FormCreationUtils.js +74 -0
- package/lib/esm/utils/FormUtils.d.ts +12 -0
- package/lib/esm/utils/FormUtils.js +187 -0
- package/lib/esm/utils/JsonUtils.d.ts +11 -0
- package/lib/esm/utils/JsonUtils.js +76 -0
- package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
- package/lib/esm/utils/LogUtils.js +6 -0
- package/lib/esm/utils/SchemaUtils.d.ts +3 -0
- package/lib/esm/utils/SchemaUtils.js +71 -0
- package/lib/esm/utils/TranslationUtils.d.ts +11 -0
- package/lib/esm/utils/TranslationUtils.js +115 -0
- package/lib/esm/utils/ValidationUtils.d.ts +19 -0
- package/lib/{utils → esm/utils}/ValidationUtils.js +29 -187
- package/package.json +17 -10
- package/lib/Checkbox.d.ts +0 -88
- package/lib/Checkbox.js +0 -49
- package/lib/CheckboxGroup.js +0 -43
- package/lib/Container.d.ts +0 -199
- package/lib/DateField.js +0 -35
- package/lib/Fieldset.d.ts +0 -34
- package/lib/Fieldset.js +0 -113
- package/lib/FileObject.js +0 -39
- package/lib/FileUpload.js +0 -155
- package/lib/Form.d.ts +0 -262
- package/lib/Form.js +0 -230
- package/lib/FormInstance.d.ts +0 -38
- package/lib/FormInstance.js +0 -119
- package/lib/FormMetaData.d.ts +0 -11
- package/lib/FormMetaData.js +0 -28
- 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 -223
- package/lib/controller/Controller.js +0 -287
- package/lib/controller/index.d.ts +0 -1
- package/lib/controller/index.js +0 -24
- package/lib/data/DataValue.js +0 -52
- 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.js +0 -19
- package/lib/types/Model.d.ts +0 -379
- 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 -29
- package/lib/utils/FormUtils.d.ts +0 -47
- package/lib/utils/FormUtils.js +0 -257
- package/lib/utils/JsonUtils.d.ts +0 -62
- package/lib/utils/JsonUtils.js +0 -143
- 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
package/lib/utils/Fetch.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Adobe, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.request = void 0;
|
|
11
|
-
const request = (url, data = null, options = {}) => {
|
|
12
|
-
const opts = Object.assign(Object.assign({}, defaultRequestOptions), options);
|
|
13
|
-
return fetch(url, Object.assign(Object.assign({}, opts), { body: data })).then((response) => {
|
|
14
|
-
var _a;
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
throw new Error(response.statusText);
|
|
17
|
-
}
|
|
18
|
-
if ((_a = response === null || response === void 0 ? void 0 : response.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
19
|
-
return response.json();
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return response.text();
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
exports.request = request;
|
|
27
|
-
const defaultRequestOptions = {
|
|
28
|
-
method: 'GET'
|
|
29
|
-
};
|
package/lib/utils/FormUtils.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ContainerModel } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Utility to generate a random word from seed
|
|
4
|
-
* @param l seed value
|
|
5
|
-
* @returns random word
|
|
6
|
-
*/
|
|
7
|
-
export declare const randomWord: (l: number) => string;
|
|
8
|
-
/**
|
|
9
|
-
* Utility to check if the value is empty
|
|
10
|
-
* @param value value
|
|
11
|
-
* @returns `true` if value is empty, `false` otherwise
|
|
12
|
-
*/
|
|
13
|
-
export declare const isEmpty: (value: any) => boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Returns the list of attachments with its data reference
|
|
16
|
-
* @param input form model
|
|
17
|
-
* @returns list of file attachments {@link FileObject} present in the form
|
|
18
|
-
*/
|
|
19
|
-
export declare const getAttachments: (input: ContainerModel) => any;
|
|
20
|
-
/**
|
|
21
|
-
* Converts file size in string to bytes based on IEC specification
|
|
22
|
-
* @param str file size
|
|
23
|
-
* @returns file size as bytes (in kb) based on IEC specification
|
|
24
|
-
*/
|
|
25
|
-
export declare const getFileSizeInBytes: (str: any) => number;
|
|
26
|
-
/**
|
|
27
|
-
* ID Generator
|
|
28
|
-
* @param initial
|
|
29
|
-
* @constructor
|
|
30
|
-
* @private
|
|
31
|
-
*/
|
|
32
|
-
export declare const IdGenerator: (initial?: number) => Generator<string, void, string>;
|
|
33
|
-
/**
|
|
34
|
-
* Utility to extract {@link FileObject} from string or HTML File data type
|
|
35
|
-
* @param file
|
|
36
|
-
* @returns list of {@link FileObject}
|
|
37
|
-
*/
|
|
38
|
-
export declare const extractFileInfo: (file: any) => any;
|
|
39
|
-
/**
|
|
40
|
-
* Utility to convert data URI to a `blob` object
|
|
41
|
-
* @param dataURI uri to convert to blob
|
|
42
|
-
* @returns `Blob` object for the data URI
|
|
43
|
-
*/
|
|
44
|
-
export declare const dataURItoBlob: (dataURI: string) => {
|
|
45
|
-
name: string;
|
|
46
|
-
blob: Blob;
|
|
47
|
-
} | null;
|
package/lib/utils/FormUtils.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Adobe, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.dataURItoBlob = exports.extractFileInfo = exports.IdGenerator = exports.getFileSizeInBytes = exports.getAttachments = exports.isEmpty = exports.randomWord = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Defines generic utilities to interact with form runtime model
|
|
13
|
-
*/
|
|
14
|
-
const JsonUtils_1 = require("./JsonUtils");
|
|
15
|
-
const FileObject_1 = require("../FileObject");
|
|
16
|
-
const ValidationUtils_1 = require("./ValidationUtils");
|
|
17
|
-
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'.split('');
|
|
18
|
-
const fileSizeRegex = /^(\d*\.?\d+)(\\?(?=[KMGT])([KMGT])(?:i?B)?|B?)$/i;
|
|
19
|
-
/**
|
|
20
|
-
* Utility to generate a random word from seed
|
|
21
|
-
* @param l seed value
|
|
22
|
-
* @returns random word
|
|
23
|
-
*/
|
|
24
|
-
const randomWord = (l) => {
|
|
25
|
-
const ret = [];
|
|
26
|
-
for (let i = 0; i <= l; i++) {
|
|
27
|
-
const randIndex = Math.floor(Math.random() * (chars.length));
|
|
28
|
-
ret.push(chars[randIndex]);
|
|
29
|
-
}
|
|
30
|
-
return ret.join('');
|
|
31
|
-
};
|
|
32
|
-
exports.randomWord = randomWord;
|
|
33
|
-
/**
|
|
34
|
-
* Utility to check if the value is empty
|
|
35
|
-
* @param value value
|
|
36
|
-
* @returns `true` if value is empty, `false` otherwise
|
|
37
|
-
*/
|
|
38
|
-
const isEmpty = (value) => {
|
|
39
|
-
return value === '' || value === null || value === undefined;
|
|
40
|
-
};
|
|
41
|
-
exports.isEmpty = isEmpty;
|
|
42
|
-
/**
|
|
43
|
-
* Returns the list of attachments with its data reference
|
|
44
|
-
* @param input form model
|
|
45
|
-
* @returns list of file attachments {@link FileObject} present in the form
|
|
46
|
-
*/
|
|
47
|
-
const getAttachments = (input) => {
|
|
48
|
-
const items = input.items || [];
|
|
49
|
-
return items === null || items === void 0 ? void 0 : items.reduce((acc, item) => {
|
|
50
|
-
let ret = null;
|
|
51
|
-
if (item.isContainer) {
|
|
52
|
-
ret = (0, exports.getAttachments)(item);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
if ((0, JsonUtils_1.isFile)(item.getState())) {
|
|
56
|
-
ret = {}; // @ts-ignore
|
|
57
|
-
const name = item.name || '';
|
|
58
|
-
const dataRef = (item.dataRef != null)
|
|
59
|
-
? item.dataRef
|
|
60
|
-
: (name.length > 0 ? item.name : undefined);
|
|
61
|
-
//@ts-ignore
|
|
62
|
-
if (item.value instanceof Array) {
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
ret[item.id] = item.value.map((x) => {
|
|
65
|
-
return Object.assign(Object.assign({}, x), { 'dataRef': dataRef });
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else if (item.value != null) {
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
ret[item.id] = Object.assign(Object.assign({}, item.value), { 'dataRef': dataRef });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return Object.assign(acc, ret);
|
|
75
|
-
}, {});
|
|
76
|
-
};
|
|
77
|
-
exports.getAttachments = getAttachments;
|
|
78
|
-
/**
|
|
79
|
-
* Converts file size in string to bytes based on IEC specification
|
|
80
|
-
* @param str file size
|
|
81
|
-
* @returns file size as bytes (in kb) based on IEC specification
|
|
82
|
-
*/
|
|
83
|
-
const getFileSizeInBytes = (str) => {
|
|
84
|
-
let retVal = 0;
|
|
85
|
-
if (typeof str === 'string') {
|
|
86
|
-
const matches = fileSizeRegex.exec(str.trim());
|
|
87
|
-
if (matches != null) {
|
|
88
|
-
retVal = sizeToBytes(parseFloat(matches[1]), (matches[2] || 'kb').toUpperCase());
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return retVal;
|
|
92
|
-
};
|
|
93
|
-
exports.getFileSizeInBytes = getFileSizeInBytes;
|
|
94
|
-
/**
|
|
95
|
-
* Converts number to bytes based on the symbol as per IEC specification
|
|
96
|
-
* @param size size as number
|
|
97
|
-
* @param symbol symbol to use (for example, kb, mb, gb or tb)
|
|
98
|
-
* @returns number as bytes based on the symbol
|
|
99
|
-
*/
|
|
100
|
-
const sizeToBytes = (size, symbol) => {
|
|
101
|
-
const sizes = { 'KB': 1, 'MB': 2, 'GB': 3, 'TB': 4 };
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
const i = Math.pow(1024, sizes[symbol]);
|
|
104
|
-
return Math.round(size * i);
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* ID Generator
|
|
108
|
-
* @param initial
|
|
109
|
-
* @constructor
|
|
110
|
-
* @private
|
|
111
|
-
*/
|
|
112
|
-
const IdGenerator = function* (initial = 50) {
|
|
113
|
-
const initialize = function () {
|
|
114
|
-
const arr = [];
|
|
115
|
-
for (let i = 0; i < initial; i++) {
|
|
116
|
-
arr.push((0, exports.randomWord)(10));
|
|
117
|
-
}
|
|
118
|
-
return arr;
|
|
119
|
-
};
|
|
120
|
-
const passedIds = {};
|
|
121
|
-
let ids = initialize();
|
|
122
|
-
do {
|
|
123
|
-
let x = ids.pop();
|
|
124
|
-
while (x in passedIds) {
|
|
125
|
-
if (ids.length === 0) {
|
|
126
|
-
ids = initialize();
|
|
127
|
-
}
|
|
128
|
-
x = ids.pop();
|
|
129
|
-
}
|
|
130
|
-
passedIds[x] = true;
|
|
131
|
-
yield ids.pop();
|
|
132
|
-
if (ids.length === 0) {
|
|
133
|
-
ids = initialize();
|
|
134
|
-
}
|
|
135
|
-
} while (ids.length > 0);
|
|
136
|
-
};
|
|
137
|
-
exports.IdGenerator = IdGenerator;
|
|
138
|
-
/**
|
|
139
|
-
* Utility to extract {@link FileObject} from string or HTML File data type
|
|
140
|
-
* @param file
|
|
141
|
-
* @returns list of {@link FileObject}
|
|
142
|
-
*/
|
|
143
|
-
const extractFileInfo = (file) => {
|
|
144
|
-
if (file !== null) {
|
|
145
|
-
let retVal = null;
|
|
146
|
-
if (file instanceof FileObject_1.FileObject) {
|
|
147
|
-
retVal = file;
|
|
148
|
-
}
|
|
149
|
-
else if (typeof File !== 'undefined' && file instanceof File) {
|
|
150
|
-
// case: file object
|
|
151
|
-
retVal = {
|
|
152
|
-
name: file.name,
|
|
153
|
-
mediaType: file.type,
|
|
154
|
-
size: file.size,
|
|
155
|
-
data: file
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
else if (typeof file === 'string' && (0, ValidationUtils_1.isDataUrl)(file)) {
|
|
159
|
-
// case: data URL
|
|
160
|
-
const result = (0, exports.dataURItoBlob)(file);
|
|
161
|
-
if (result !== null) {
|
|
162
|
-
const { blob, name } = result;
|
|
163
|
-
retVal = {
|
|
164
|
-
name: name,
|
|
165
|
-
mediaType: blob.type,
|
|
166
|
-
size: blob.size,
|
|
167
|
-
data: blob
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
// case: string as file object
|
|
173
|
-
let jFile = file;
|
|
174
|
-
try {
|
|
175
|
-
jFile = JSON.parse(file);
|
|
176
|
-
retVal = jFile;
|
|
177
|
-
if (!retVal.mediaType) {
|
|
178
|
-
retVal.mediaType = retVal.type;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
catch (ex) {
|
|
182
|
-
// do nothing
|
|
183
|
-
}
|
|
184
|
-
if (typeof (jFile === null || jFile === void 0 ? void 0 : jFile.data) === 'string' && (0, ValidationUtils_1.isDataUrl)(jFile === null || jFile === void 0 ? void 0 : jFile.data)) {
|
|
185
|
-
// case: data URL
|
|
186
|
-
const result = (0, exports.dataURItoBlob)(jFile === null || jFile === void 0 ? void 0 : jFile.data);
|
|
187
|
-
if (result !== null) {
|
|
188
|
-
const blob = result.blob;
|
|
189
|
-
retVal = {
|
|
190
|
-
name: jFile === null || jFile === void 0 ? void 0 : jFile.name,
|
|
191
|
-
mediaType: (jFile === null || jFile === void 0 ? void 0 : jFile.type) || (jFile === null || jFile === void 0 ? void 0 : jFile.mediaType),
|
|
192
|
-
size: blob.size,
|
|
193
|
-
data: blob
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
else if (typeof jFile === 'string') {
|
|
198
|
-
// case: data as external url
|
|
199
|
-
const fileName = jFile.split('/').pop();
|
|
200
|
-
retVal = {
|
|
201
|
-
name: fileName,
|
|
202
|
-
mediaType: 'application/octet-stream',
|
|
203
|
-
size: 0,
|
|
204
|
-
data: jFile
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
else if (typeof jFile === 'object') {
|
|
208
|
-
// todo: just added for ease of integration for the view layer
|
|
209
|
-
retVal = {
|
|
210
|
-
name: jFile === null || jFile === void 0 ? void 0 : jFile.name,
|
|
211
|
-
mediaType: (jFile === null || jFile === void 0 ? void 0 : jFile.type) || (jFile === null || jFile === void 0 ? void 0 : jFile.mediaType),
|
|
212
|
-
size: jFile === null || jFile === void 0 ? void 0 : jFile.size,
|
|
213
|
-
data: jFile === null || jFile === void 0 ? void 0 : jFile.data
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (retVal !== null && retVal.data != null) {
|
|
218
|
-
return new FileObject_1.FileObject(retVal);
|
|
219
|
-
}
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
exports.extractFileInfo = extractFileInfo;
|
|
227
|
-
/**
|
|
228
|
-
* Utility to convert data URI to a `blob` object
|
|
229
|
-
* @param dataURI uri to convert to blob
|
|
230
|
-
* @returns `Blob` object for the data URI
|
|
231
|
-
*/
|
|
232
|
-
const dataURItoBlob = (dataURI) => {
|
|
233
|
-
const regex = /^data:([a-z]+\/[a-z0-9-+.]+)?(?:;name=([^;]+))?(;base64)?,(.+)$/;
|
|
234
|
-
const groups = regex.exec(dataURI);
|
|
235
|
-
if (groups !== null) {
|
|
236
|
-
const type = groups[1] || '';
|
|
237
|
-
const name = groups[2] || 'unknown';
|
|
238
|
-
const isBase64 = typeof groups[3] === 'string';
|
|
239
|
-
if (isBase64) {
|
|
240
|
-
const binary = atob(groups[4]);
|
|
241
|
-
const array = [];
|
|
242
|
-
for (let i = 0; i < binary.length; i++) {
|
|
243
|
-
array.push(binary.charCodeAt(i));
|
|
244
|
-
}
|
|
245
|
-
const blob = new window.Blob([new Uint8Array(array)], { type });
|
|
246
|
-
return { name, blob };
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
const blob = new window.Blob([groups[4]], { type });
|
|
250
|
-
return { name, blob };
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
exports.dataURItoBlob = dataURItoBlob;
|
package/lib/utils/JsonUtils.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines generic utilities to interact with form model definition which is represented as json
|
|
3
|
-
*/
|
|
4
|
-
import { FieldsetJson, FieldJson } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Get the property value form the json
|
|
7
|
-
* @param data object as json
|
|
8
|
-
* @param key name of the key
|
|
9
|
-
* @param def default value
|
|
10
|
-
* @typeParam P type for the default value
|
|
11
|
-
*/
|
|
12
|
-
export declare const getProperty: <P>(data: any, key: string, def: P) => P;
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the input item provided is a form file attachment field
|
|
15
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
16
|
-
* @returns `true` if `item` is a form file attachment, `false` otherwise
|
|
17
|
-
*/
|
|
18
|
-
export declare const isFile: (item: FieldsetJson | FieldJson) => boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Utility to check if the given form field has any data constraints
|
|
21
|
-
* @param item form field to check
|
|
22
|
-
* @returns `true` if `item` has data constraints, `false` otherwise
|
|
23
|
-
*/
|
|
24
|
-
export declare const checkIfConstraintsArePresent: (item: FieldsetJson | FieldJson) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Checks if the input item provided is a form check box field
|
|
27
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
28
|
-
* @returns `true` if `item` is a form check box, `false` otherwise
|
|
29
|
-
*/
|
|
30
|
-
export declare const isCheckbox: (item: FieldsetJson | FieldJson) => boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Checks if the input item provided is a form check box group field
|
|
33
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
34
|
-
* @returns `true` if `item` is a form check box group, `false` otherwise
|
|
35
|
-
*/
|
|
36
|
-
export declare const isCheckboxGroup: (item: FieldsetJson | FieldJson) => boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Checks if the input item provided is a date field
|
|
39
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
40
|
-
* @returns `true` if `item` is a form check box group, `false` otherwise
|
|
41
|
-
*/
|
|
42
|
-
export declare const isDateField: (item: FieldsetJson | FieldJson) => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Clones an object completely including any nested objects or arrays
|
|
45
|
-
* @param obj
|
|
46
|
-
* @param idGenerator
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
49
|
-
export declare function deepClone(obj: any, idGenerator?: () => string): any;
|
|
50
|
-
/**
|
|
51
|
-
* Checks if the key got added in current object
|
|
52
|
-
* @param currentObj
|
|
53
|
-
* @param prevObj
|
|
54
|
-
* @param objKey
|
|
55
|
-
*/
|
|
56
|
-
export declare function checkIfKeyAdded(currentObj: any, prevObj: any, objKey: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Prettifies obj as json string
|
|
59
|
-
* @param obj object to prettify
|
|
60
|
-
* @return json string
|
|
61
|
-
*/
|
|
62
|
-
export declare const jsonString: (obj: any) => string;
|
package/lib/utils/JsonUtils.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Adobe, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.jsonString = exports.checkIfKeyAdded = exports.deepClone = exports.isDateField = exports.isCheckboxGroup = exports.isCheckbox = exports.checkIfConstraintsArePresent = exports.isFile = exports.getProperty = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Defines generic utilities to interact with form model definition which is represented as json
|
|
13
|
-
*/
|
|
14
|
-
const types_1 = require("../types");
|
|
15
|
-
const SchemaUtils_1 = require("./SchemaUtils");
|
|
16
|
-
/**
|
|
17
|
-
* Get the property value form the json
|
|
18
|
-
* @param data object as json
|
|
19
|
-
* @param key name of the key
|
|
20
|
-
* @param def default value
|
|
21
|
-
* @typeParam P type for the default value
|
|
22
|
-
*/
|
|
23
|
-
const getProperty = (data, key, def) => {
|
|
24
|
-
if (key in data) {
|
|
25
|
-
return data[key];
|
|
26
|
-
}
|
|
27
|
-
else if (!key.startsWith(':')) {
|
|
28
|
-
const prefixedKey = `:${key}`;
|
|
29
|
-
if (prefixedKey in data) {
|
|
30
|
-
return data[prefixedKey];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return def;
|
|
34
|
-
};
|
|
35
|
-
exports.getProperty = getProperty;
|
|
36
|
-
/**
|
|
37
|
-
* Checks if the input item provided is a form file attachment field
|
|
38
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
39
|
-
* @returns `true` if `item` is a form file attachment, `false` otherwise
|
|
40
|
-
*/
|
|
41
|
-
const isFile = function (item) {
|
|
42
|
-
return ((item === null || item === void 0 ? void 0 : item.type) === 'file' || (item === null || item === void 0 ? void 0 : item.type) === 'file[]') ||
|
|
43
|
-
(((item === null || item === void 0 ? void 0 : item.type) === 'string' || (item === null || item === void 0 ? void 0 : item.type) === 'string[]') &&
|
|
44
|
-
((item === null || item === void 0 ? void 0 : item.format) === 'binary' || (item === null || item === void 0 ? void 0 : item.format) === 'data-url'));
|
|
45
|
-
};
|
|
46
|
-
exports.isFile = isFile;
|
|
47
|
-
/**
|
|
48
|
-
* Utility to check if the given form field has any data constraints
|
|
49
|
-
* @param item form field to check
|
|
50
|
-
* @returns `true` if `item` has data constraints, `false` otherwise
|
|
51
|
-
*/
|
|
52
|
-
const checkIfConstraintsArePresent = function (item) {
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
return types_1.constraintProps.some(cp => item[cp] !== undefined);
|
|
55
|
-
};
|
|
56
|
-
exports.checkIfConstraintsArePresent = checkIfConstraintsArePresent;
|
|
57
|
-
/**
|
|
58
|
-
* Checks if the input item provided is a form check box field
|
|
59
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
60
|
-
* @returns `true` if `item` is a form check box, `false` otherwise
|
|
61
|
-
*/
|
|
62
|
-
const isCheckbox = function (item) {
|
|
63
|
-
const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
|
|
64
|
-
return fieldType === 'checkbox';
|
|
65
|
-
};
|
|
66
|
-
exports.isCheckbox = isCheckbox;
|
|
67
|
-
/**
|
|
68
|
-
* Checks if the input item provided is a form check box group field
|
|
69
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
70
|
-
* @returns `true` if `item` is a form check box group, `false` otherwise
|
|
71
|
-
*/
|
|
72
|
-
const isCheckboxGroup = function (item) {
|
|
73
|
-
const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
|
|
74
|
-
return fieldType === 'checkbox-group';
|
|
75
|
-
};
|
|
76
|
-
exports.isCheckboxGroup = isCheckboxGroup;
|
|
77
|
-
/**
|
|
78
|
-
* Checks if the input item provided is a date field
|
|
79
|
-
* @param item input item it could be {@link FieldsetJson | Fieldset} or {@link FieldJson | Field}
|
|
80
|
-
* @returns `true` if `item` is a form check box group, `false` otherwise
|
|
81
|
-
*/
|
|
82
|
-
const isDateField = function (item) {
|
|
83
|
-
const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
|
|
84
|
-
return (fieldType === 'text-input' && (item === null || item === void 0 ? void 0 : item.format) === 'date') || fieldType === 'date-input';
|
|
85
|
-
};
|
|
86
|
-
exports.isDateField = isDateField;
|
|
87
|
-
/**
|
|
88
|
-
* Clones an object completely including any nested objects or arrays
|
|
89
|
-
* @param obj
|
|
90
|
-
* @param idGenerator
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
function deepClone(obj, idGenerator) {
|
|
94
|
-
let result;
|
|
95
|
-
if (obj instanceof Array) {
|
|
96
|
-
result = [];
|
|
97
|
-
result = obj.map(x => deepClone(x, idGenerator));
|
|
98
|
-
}
|
|
99
|
-
else if (typeof obj === 'object' && obj !== null) {
|
|
100
|
-
result = {};
|
|
101
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
102
|
-
result[key] = deepClone(value, idGenerator);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
result = obj;
|
|
107
|
-
}
|
|
108
|
-
//if idGenerator is specified, and id exists in the object
|
|
109
|
-
if (idGenerator && result && result.id) {
|
|
110
|
-
result.id = idGenerator();
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
exports.deepClone = deepClone;
|
|
115
|
-
/**
|
|
116
|
-
* Checks if the key got added in current object
|
|
117
|
-
* @param currentObj
|
|
118
|
-
* @param prevObj
|
|
119
|
-
* @param objKey
|
|
120
|
-
*/
|
|
121
|
-
function checkIfKeyAdded(currentObj, prevObj, objKey) {
|
|
122
|
-
if (currentObj != null && prevObj != null) {
|
|
123
|
-
// add the new key
|
|
124
|
-
const newPrvObj = Object.assign({}, prevObj);
|
|
125
|
-
newPrvObj[objKey] = currentObj[objKey];
|
|
126
|
-
// do compare using json stringify
|
|
127
|
-
const newJsonStr = (0, exports.jsonString)(currentObj).replace((0, exports.jsonString)(newPrvObj), '');
|
|
128
|
-
return newJsonStr === '';
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.checkIfKeyAdded = checkIfKeyAdded;
|
|
135
|
-
/**
|
|
136
|
-
* Prettifies obj as json string
|
|
137
|
-
* @param obj object to prettify
|
|
138
|
-
* @return json string
|
|
139
|
-
*/
|
|
140
|
-
const jsonString = (obj) => {
|
|
141
|
-
return JSON.stringify(obj, null, 2);
|
|
142
|
-
};
|
|
143
|
-
exports.jsonString = jsonString;
|
package/lib/utils/LogUtils.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Adobe, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.logFormCallbacks = void 0;
|
|
11
|
-
const logFormCallbacks = (callbacks) => {
|
|
12
|
-
const s = Object.entries(callbacks).map(([id, fn]) => {
|
|
13
|
-
return `${id} : ${fn.length}`;
|
|
14
|
-
}).join(' ');
|
|
15
|
-
console.log(s);
|
|
16
|
-
};
|
|
17
|
-
exports.logFormCallbacks = logFormCallbacks;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines generic utilities to convert form model definition to json schema
|
|
3
|
-
*/
|
|
4
|
-
import { FormJson } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Returns the default view type for a given form field object based on `adaptive form specification`
|
|
7
|
-
* @param schema schema item for which default view type is to found
|
|
8
|
-
* @returns default view type
|
|
9
|
-
*/
|
|
10
|
-
export declare const defaultFieldTypes: (schema: any) => string;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a json schema from form model definition
|
|
13
|
-
* @param form {@link FormJson | form model definition}
|
|
14
|
-
* @returns json schema of form model definition
|
|
15
|
-
*/
|
|
16
|
-
export declare const exportDataSchema: (form: FormJson) => any;
|
package/lib/utils/SchemaUtils.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Adobe, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.exportDataSchema = exports.defaultFieldTypes = void 0;
|
|
11
|
-
// const primitives = ['string', 'boolean', 'number'];
|
|
12
|
-
// const containers = ['object', 'array', 'number'];
|
|
13
|
-
const objToMap = (o) => new Map(Object.entries(o));
|
|
14
|
-
const stringViewTypes = objToMap({ 'date': 'date-input', 'data-url': 'file-input', 'binary': 'file-input' });
|
|
15
|
-
const typeToViewTypes = objToMap({
|
|
16
|
-
'number': 'number-input',
|
|
17
|
-
'boolean': 'checkbox',
|
|
18
|
-
'object': 'panel',
|
|
19
|
-
'array': 'panel',
|
|
20
|
-
'file': 'file-input',
|
|
21
|
-
'file[]': 'file-input'
|
|
22
|
-
});
|
|
23
|
-
const arrayTypes = ['string[]', 'boolean[]', 'number[]', 'array'];
|
|
24
|
-
/**
|
|
25
|
-
* Returns the default view type for a given form field object based on `adaptive form specification`
|
|
26
|
-
* @param schema schema item for which default view type is to found
|
|
27
|
-
* @returns default view type
|
|
28
|
-
*/
|
|
29
|
-
const defaultFieldTypes = (schema) => {
|
|
30
|
-
const type = schema.type || 'string';
|
|
31
|
-
if ('enum' in schema) {
|
|
32
|
-
const enums = schema.enum;
|
|
33
|
-
if (enums.length > 2 || arrayTypes.indexOf(type) > -1) {
|
|
34
|
-
return 'drop-down';
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return 'checkbox';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (type === 'string' || type === 'string[]') {
|
|
41
|
-
return stringViewTypes.get(schema.format) || 'text-input';
|
|
42
|
-
}
|
|
43
|
-
return typeToViewTypes.get(type) || 'text-input';
|
|
44
|
-
};
|
|
45
|
-
exports.defaultFieldTypes = defaultFieldTypes;
|
|
46
|
-
const fieldSchema = (input) => {
|
|
47
|
-
var _a;
|
|
48
|
-
if ('items' in input) {
|
|
49
|
-
const fieldset = input;
|
|
50
|
-
const items = fieldset.items;
|
|
51
|
-
if (fieldset.type === 'array') {
|
|
52
|
-
return {
|
|
53
|
-
type: 'array',
|
|
54
|
-
items: fieldSchema(items[0]),
|
|
55
|
-
minItems: fieldset === null || fieldset === void 0 ? void 0 : fieldset.minItems,
|
|
56
|
-
maxItems: fieldset === null || fieldset === void 0 ? void 0 : fieldset.maxItems
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const iter = items.filter(x => x.name != null);
|
|
61
|
-
return {
|
|
62
|
-
type: 'object',
|
|
63
|
-
properties: Object.fromEntries(iter.map(item => [item.name, fieldSchema(item)])),
|
|
64
|
-
required: iter.filter(x => x.required).map(x => x.name)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const field = input;
|
|
70
|
-
const schemaProps = ['type', 'maxLength', 'minLength', 'minimum', 'maximum', 'format', 'pattern', 'step', 'enum'];
|
|
71
|
-
const schema = schemaProps.reduce((acc, prop) => {
|
|
72
|
-
const p = prop;
|
|
73
|
-
if (prop in field && field[p] != undefined) {
|
|
74
|
-
acc[prop] = field[p];
|
|
75
|
-
}
|
|
76
|
-
return acc;
|
|
77
|
-
}, {});
|
|
78
|
-
if (field.dataRef === 'none' || Object.keys(schema).length == 0) {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
return Object.assign({ title: (_a = field.label) === null || _a === void 0 ? void 0 : _a.value, description: field.description }, schema);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Creates a json schema from form model definition
|
|
86
|
-
* @param form {@link FormJson | form model definition}
|
|
87
|
-
* @returns json schema of form model definition
|
|
88
|
-
*/
|
|
89
|
-
const exportDataSchema = (form) => {
|
|
90
|
-
return fieldSchema(form);
|
|
91
|
-
};
|
|
92
|
-
exports.exportDataSchema = exportDataSchema;
|