@aemforms/af-core 0.22.31 → 0.22.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +6 -6
- package/lib/{esm/BaseNode-f84b22c6.js → BaseNode.js} +58 -94
- package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
- package/lib/Checkbox.js +29 -0
- package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
- package/lib/CheckboxGroup.js +24 -0
- package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
- package/lib/{esm/Container.js → Container.js} +51 -77
- package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
- package/lib/DateField.js +26 -0
- package/lib/{esm/Field.d.ts → Field.d.ts} +7 -7
- package/lib/{esm/Field.js → Field.js} +84 -104
- package/lib/{esm/Fieldset.d.ts → Fieldset.d.ts} +7 -7
- package/lib/{esm/Fieldset.js → Fieldset.js} +14 -43
- package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
- package/lib/FileObject.js +29 -0
- package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
- package/lib/FileUpload.js +124 -0
- package/lib/{esm/Form.d.ts → Form.d.ts} +12 -12
- package/lib/{esm/Form.js → Form.js} +34 -65
- package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
- package/lib/FormInstance.js +94 -0
- package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
- package/lib/FormMetaData.js +15 -0
- package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
- package/lib/InstanceManager.js +35 -0
- package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
- package/lib/Node.js +15 -0
- package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
- package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
- package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
- package/lib/{esm/controller → controller}/EventQueue.js +8 -32
- package/lib/{esm/controller → controller}/Events.d.ts +2 -2
- package/lib/{esm/controller → controller}/Events.js +22 -26
- package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
- package/lib/controller/Logger.js +33 -0
- package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
- package/lib/{esm/data → data}/DataGroup.js +20 -38
- package/lib/{esm/data → data}/DataValue.d.ts +1 -1
- package/lib/{esm/data → data}/DataValue.js +4 -26
- package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
- package/lib/data/EmptyDataValue.js +34 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +57 -0
- package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
- package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
- package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
- package/lib/rules/RuleEngine.js +51 -0
- package/lib/{esm/types → types}/Json.d.ts +16 -16
- package/lib/types/Json.js +10 -0
- package/lib/{esm/types → types}/Model.d.ts +9 -9
- package/lib/types/Model.js +10 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/{esm/utils → utils}/DataRefParser.d.ts +4 -4
- package/lib/{esm/utils → utils}/DataRefParser.js +30 -45
- package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
- package/lib/utils/Fetch.js +74 -0
- package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
- package/lib/utils/FormCreationUtils.js +67 -0
- package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
- package/lib/{esm/utils → utils}/FormUtils.js +62 -46
- package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
- package/lib/utils/JsonUtils.js +89 -0
- package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
- package/lib/utils/LogUtils.js +10 -0
- package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
- package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
- package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
- package/lib/utils/TranslationUtils.js +125 -0
- package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
- package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
- package/package.json +8 -13
- package/lib/cjs/index.cjs +0 -7426
- package/lib/esm/BaseNode.js +0 -26
- package/lib/esm/Checkbox.js +0 -63
- package/lib/esm/CheckboxGroup.js +0 -60
- package/lib/esm/DateField.js +0 -57
- package/lib/esm/FileObject.js +0 -48
- package/lib/esm/FileUpload.js +0 -141
- package/lib/esm/FormInstance.js +0 -129
- package/lib/esm/FormMetaData.js +0 -35
- package/lib/esm/InstanceManager.js +0 -58
- package/lib/esm/Node.js +0 -40
- package/lib/esm/controller/Logger.js +0 -52
- package/lib/esm/data/EmptyDataValue.js +0 -51
- package/lib/esm/index.d.ts +0 -21
- package/lib/esm/index.js +0 -55
- package/lib/esm/rules/RuleEngine.js +0 -76
- package/lib/esm/types/Json.js +0 -29
- package/lib/esm/types/Model.js +0 -30
- package/lib/esm/types/index.d.ts +0 -2
- package/lib/esm/types/index.js +0 -22
- package/lib/esm/utils/Fetch.js +0 -83
- package/lib/esm/utils/FormCreationUtils.js +0 -112
- package/lib/esm/utils/JsonUtils.js +0 -99
- package/lib/esm/utils/LogUtils.js +0 -28
- package/lib/esm/utils/TranslationUtils.js +0 -138
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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';
|
|
23
|
-
import { FileObject } from '../FileObject.js';
|
|
24
|
-
import { getAttachments } from '../utils/FormUtils.js';
|
|
25
|
-
import { jsonString } from '../utils/JsonUtils.js';
|
|
26
|
-
import '../types/Json.js';
|
|
27
|
-
import '../utils/SchemaUtils.js';
|
|
28
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FunctionRuntime = exports.submit = exports.request = void 0;
|
|
13
|
+
const Events_1 = require("../controller/Events");
|
|
14
|
+
const Fetch_1 = require("../utils/Fetch");
|
|
15
|
+
const FileObject_1 = require("../FileObject");
|
|
16
|
+
const FormUtils_1 = require("../utils/FormUtils");
|
|
17
|
+
const JsonUtils_1 = require("../utils/JsonUtils");
|
|
29
18
|
const getCustomEventName = (name) => {
|
|
30
19
|
const eName = name;
|
|
31
20
|
if (eName.length > 0 && eName.startsWith('custom:')) {
|
|
@@ -33,7 +22,8 @@ const getCustomEventName = (name) => {
|
|
|
33
22
|
}
|
|
34
23
|
return eName;
|
|
35
24
|
};
|
|
36
|
-
const request =
|
|
25
|
+
const request = (context, uri, httpVerb, payload, success, error, headers) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
37
27
|
const endpoint = uri;
|
|
38
28
|
const requestOptions = {
|
|
39
29
|
method: httpVerb
|
|
@@ -41,7 +31,7 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
41
31
|
let result;
|
|
42
32
|
let inputPayload;
|
|
43
33
|
try {
|
|
44
|
-
if (payload && payload instanceof FileObject && payload.data instanceof File) {
|
|
34
|
+
if (payload && payload instanceof FileObject_1.FileObject && payload.data instanceof File) {
|
|
45
35
|
const formData = new FormData();
|
|
46
36
|
formData.append(payload.name, payload.data);
|
|
47
37
|
inputPayload = formData;
|
|
@@ -52,15 +42,12 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
52
42
|
else if (payload && typeof payload === 'object' && Object.keys(payload).length > 0) {
|
|
53
43
|
const headerNames = Object.keys(headers);
|
|
54
44
|
if (headerNames.length > 0) {
|
|
55
|
-
requestOptions.headers = {
|
|
56
|
-
...headers,
|
|
57
|
-
...(headerNames.indexOf('Content-Type') === -1 ? { 'Content-Type': 'application/json' } : {})
|
|
58
|
-
};
|
|
45
|
+
requestOptions.headers = Object.assign(Object.assign({}, headers), (headerNames.indexOf('Content-Type') === -1 ? { 'Content-Type': 'application/json' } : {}));
|
|
59
46
|
}
|
|
60
47
|
else {
|
|
61
48
|
requestOptions.headers = { 'Content-Type': 'application/json' };
|
|
62
49
|
}
|
|
63
|
-
const contentType = requestOptions
|
|
50
|
+
const contentType = ((_a = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) === null || _a === void 0 ? void 0 : _a['Content-Type']) || 'application/json';
|
|
64
51
|
if (contentType === 'application/json') {
|
|
65
52
|
inputPayload = JSON.stringify(payload);
|
|
66
53
|
}
|
|
@@ -71,22 +58,23 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
71
58
|
inputPayload = urlEncoded(payload);
|
|
72
59
|
}
|
|
73
60
|
}
|
|
74
|
-
result =
|
|
61
|
+
result = yield (0, Fetch_1.request)(endpoint, inputPayload, requestOptions);
|
|
75
62
|
}
|
|
76
63
|
catch (e) {
|
|
77
64
|
context.form.logger.error('Error invoking a rest API');
|
|
78
65
|
const eName = getCustomEventName(error);
|
|
79
|
-
context.form.dispatch(new CustomEvent(eName, {}, true));
|
|
66
|
+
context.form.dispatch(new Events_1.CustomEvent(eName, {}, true));
|
|
80
67
|
return;
|
|
81
68
|
}
|
|
82
69
|
const eName = getCustomEventName(success);
|
|
83
|
-
context.form.dispatch(new CustomEvent(eName, result, true));
|
|
84
|
-
};
|
|
70
|
+
context.form.dispatch(new Events_1.CustomEvent(eName, result, true));
|
|
71
|
+
});
|
|
72
|
+
exports.request = request;
|
|
85
73
|
const urlEncoded = (data) => {
|
|
86
74
|
const formData = new URLSearchParams();
|
|
87
75
|
Object.entries(data).forEach(([key, value]) => {
|
|
88
76
|
if (value != null && typeof value === 'object') {
|
|
89
|
-
formData.append(key, jsonString(value));
|
|
77
|
+
formData.append(key, (0, JsonUtils_1.jsonString)(value));
|
|
90
78
|
}
|
|
91
79
|
else {
|
|
92
80
|
formData.append(key, value);
|
|
@@ -98,15 +86,15 @@ const multipartFormData = (data, attachments) => {
|
|
|
98
86
|
const formData = new FormData();
|
|
99
87
|
Object.entries(data).forEach(([key, value]) => {
|
|
100
88
|
if (value != null && typeof value === 'object') {
|
|
101
|
-
formData.append(key, jsonString(value));
|
|
89
|
+
formData.append(key, (0, JsonUtils_1.jsonString)(value));
|
|
102
90
|
}
|
|
103
91
|
else {
|
|
104
92
|
formData.append(key, value);
|
|
105
93
|
}
|
|
106
94
|
});
|
|
107
95
|
const addAttachmentToFormData = (objValue, formData) => {
|
|
108
|
-
if (objValue
|
|
109
|
-
let attIdentifier = `${objValue
|
|
96
|
+
if ((objValue === null || objValue === void 0 ? void 0 : objValue.data) instanceof File) {
|
|
97
|
+
let attIdentifier = `${objValue === null || objValue === void 0 ? void 0 : objValue.dataRef}/${objValue === null || objValue === void 0 ? void 0 : objValue.name}`;
|
|
110
98
|
if (!attIdentifier.startsWith('/')) {
|
|
111
99
|
attIdentifier = `/${attIdentifier}`;
|
|
112
100
|
}
|
|
@@ -126,13 +114,13 @@ const multipartFormData = (data, attachments) => {
|
|
|
126
114
|
}
|
|
127
115
|
return formData;
|
|
128
116
|
};
|
|
129
|
-
const submit =
|
|
117
|
+
const submit = (context, success, error, submitAs = 'multipart/form-data', input_data = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
118
|
const endpoint = context.form.action;
|
|
131
119
|
let data = input_data;
|
|
132
120
|
if (typeof data != 'object' || data == null) {
|
|
133
121
|
data = context.form.exportData();
|
|
134
122
|
}
|
|
135
|
-
const attachments = getAttachments(context.form);
|
|
123
|
+
const attachments = (0, FormUtils_1.getAttachments)(context.form);
|
|
136
124
|
let submitContentType = submitAs;
|
|
137
125
|
const submitDataAndMetaData = { 'data': data, 'submitMetadata': { 'lang': context.form.lang } };
|
|
138
126
|
let formData = submitDataAndMetaData;
|
|
@@ -140,34 +128,37 @@ const submit = async (context, success, error, submitAs = 'multipart/form-data',
|
|
|
140
128
|
formData = multipartFormData(submitDataAndMetaData, attachments);
|
|
141
129
|
submitContentType = 'multipart/form-data';
|
|
142
130
|
}
|
|
143
|
-
|
|
131
|
+
yield (0, exports.request)(context, endpoint, 'POST', formData, success, error, {
|
|
144
132
|
'Content-Type': submitContentType
|
|
145
133
|
});
|
|
146
|
-
};
|
|
134
|
+
});
|
|
135
|
+
exports.submit = submit;
|
|
147
136
|
const createAction = (name, payload = {}) => {
|
|
148
137
|
switch (name) {
|
|
149
138
|
case 'change':
|
|
150
|
-
return new Change(payload);
|
|
139
|
+
return new Events_1.Change(payload);
|
|
151
140
|
case 'submit':
|
|
152
|
-
return new Submit(payload);
|
|
141
|
+
return new Events_1.Submit(payload);
|
|
153
142
|
case 'click':
|
|
154
|
-
return new Click(payload);
|
|
143
|
+
return new Events_1.Click(payload);
|
|
155
144
|
case 'addItem':
|
|
156
|
-
return new AddItem(payload);
|
|
145
|
+
return new Events_1.AddItem(payload);
|
|
157
146
|
case 'removeItem':
|
|
158
|
-
return new RemoveItem(payload);
|
|
147
|
+
return new Events_1.RemoveItem(payload);
|
|
159
148
|
case 'reset':
|
|
160
|
-
return new Reset(payload);
|
|
149
|
+
return new Events_1.Reset(payload);
|
|
161
150
|
case 'addInstance':
|
|
162
|
-
return new AddInstance(payload);
|
|
151
|
+
return new Events_1.AddInstance(payload);
|
|
163
152
|
case 'removeInstance':
|
|
164
|
-
return new RemoveInstance(payload);
|
|
153
|
+
return new Events_1.RemoveInstance(payload);
|
|
165
154
|
default:
|
|
166
155
|
console.error('invalid action');
|
|
167
156
|
}
|
|
168
157
|
};
|
|
169
158
|
class FunctionRuntimeImpl {
|
|
170
|
-
|
|
159
|
+
constructor() {
|
|
160
|
+
this.customFunctions = {};
|
|
161
|
+
}
|
|
171
162
|
registerFunctions(functions) {
|
|
172
163
|
Object.entries(functions).forEach(([name, funcDef]) => {
|
|
173
164
|
let finalFunction = funcDef;
|
|
@@ -275,7 +266,7 @@ class FunctionRuntimeImpl {
|
|
|
275
266
|
const error = toString(args[1]);
|
|
276
267
|
const submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
|
|
277
268
|
const submit_data = args.length > 3 ? valueOf(args[3]) : null;
|
|
278
|
-
interpreter.globals.form.dispatch(new Submit({
|
|
269
|
+
interpreter.globals.form.dispatch(new Events_1.Submit({
|
|
279
270
|
success,
|
|
280
271
|
error,
|
|
281
272
|
submit_as,
|
|
@@ -301,7 +292,7 @@ class FunctionRuntimeImpl {
|
|
|
301
292
|
success = valueOf(args[4]);
|
|
302
293
|
error = valueOf(args[5]);
|
|
303
294
|
}
|
|
304
|
-
request(interpreter.globals, uri, httpVerb, payload, success, error, headers);
|
|
295
|
+
(0, exports.request)(interpreter.globals, uri, httpVerb, payload, success, error, headers);
|
|
305
296
|
return {};
|
|
306
297
|
},
|
|
307
298
|
_signature: []
|
|
@@ -319,7 +310,7 @@ class FunctionRuntimeImpl {
|
|
|
319
310
|
}
|
|
320
311
|
let event;
|
|
321
312
|
if (eventName.startsWith('custom:')) {
|
|
322
|
-
event = new CustomEvent(eventName.substring('custom:'.length), payload, dispatch);
|
|
313
|
+
event = new Events_1.CustomEvent(eventName.substring('custom:'.length), payload, dispatch);
|
|
323
314
|
}
|
|
324
315
|
else {
|
|
325
316
|
event = createAction(eventName, payload);
|
|
@@ -337,9 +328,7 @@ class FunctionRuntimeImpl {
|
|
|
337
328
|
_signature: []
|
|
338
329
|
}
|
|
339
330
|
};
|
|
340
|
-
return {
|
|
331
|
+
return Object.assign(Object.assign({}, defaultFunctions), this.customFunctions);
|
|
341
332
|
}
|
|
342
333
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
export { FunctionRuntime, request, submit };
|
|
334
|
+
exports.FunctionRuntime = new FunctionRuntimeImpl();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const json_formula_1 = __importDefault(require("@adobe/json-formula"));
|
|
7
|
+
const FunctionRuntime_1 = require("./FunctionRuntime");
|
|
8
|
+
class RuleEngine {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._globalNames = [
|
|
11
|
+
'$form',
|
|
12
|
+
'$field',
|
|
13
|
+
'$event'
|
|
14
|
+
];
|
|
15
|
+
this.debugInfo = [];
|
|
16
|
+
const customFunctions = FunctionRuntime_1.FunctionRuntime.getFunctions();
|
|
17
|
+
this.formulaEngine = new json_formula_1.default(customFunctions, undefined, this.debugInfo);
|
|
18
|
+
}
|
|
19
|
+
compileRule(rule) {
|
|
20
|
+
return this.formulaEngine.compile(rule, this._globalNames);
|
|
21
|
+
}
|
|
22
|
+
execute(node, data, globals, useValueOf = false) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f;
|
|
24
|
+
const oldContext = this._context;
|
|
25
|
+
this._context = globals;
|
|
26
|
+
let res = undefined;
|
|
27
|
+
try {
|
|
28
|
+
res = this.formulaEngine.run(node, data, 'en-US', globals);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
(_c = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.logger) === null || _c === void 0 ? void 0 : _c.error(err);
|
|
32
|
+
}
|
|
33
|
+
while (this.debugInfo.length > 0) {
|
|
34
|
+
(_f = (_e = (_d = this._context) === null || _d === void 0 ? void 0 : _d.form) === null || _e === void 0 ? void 0 : _e.logger) === null || _f === void 0 ? void 0 : _f.debug(this.debugInfo.pop());
|
|
35
|
+
}
|
|
36
|
+
let finalRes = res;
|
|
37
|
+
if (useValueOf) {
|
|
38
|
+
if (typeof res === 'object' && res !== null) {
|
|
39
|
+
finalRes = Object.getPrototypeOf(res).valueOf.call(res);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
this._context = oldContext;
|
|
43
|
+
return finalRes;
|
|
44
|
+
}
|
|
45
|
+
trackDependency(subscriber) {
|
|
46
|
+
if (this._context && this._context.field !== undefined && this._context.field !== subscriber) {
|
|
47
|
+
subscriber._addDependent(this._context.field);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = RuleEngine;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export type Items<T> = {
|
|
1
|
+
export declare type Items<T> = {
|
|
2
2
|
[key: string]: T;
|
|
3
3
|
};
|
|
4
|
-
export type Primitives = string | number | boolean | null | undefined;
|
|
5
|
-
export type Label = {
|
|
4
|
+
export declare type Primitives = string | number | boolean | null | undefined;
|
|
5
|
+
export declare type Label = {
|
|
6
6
|
value: string;
|
|
7
7
|
richText?: boolean;
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
};
|
|
10
|
-
type TranslationConstraintsJson = {
|
|
10
|
+
declare type TranslationConstraintsJson = {
|
|
11
11
|
enumNames?: string[];
|
|
12
12
|
enum?: any[];
|
|
13
13
|
};
|
|
14
|
-
export type ConstraintsJson = TranslationConstraintsJson & {
|
|
14
|
+
export declare type ConstraintsJson = TranslationConstraintsJson & {
|
|
15
15
|
accept?: string[];
|
|
16
16
|
enforceEnum?: boolean;
|
|
17
17
|
exclusiveMinimum?: number;
|
|
@@ -33,7 +33,7 @@ export type ConstraintsJson = TranslationConstraintsJson & {
|
|
|
33
33
|
validationExpression?: string;
|
|
34
34
|
uniqueItems?: boolean;
|
|
35
35
|
};
|
|
36
|
-
export type ConstraintsMessages = {
|
|
36
|
+
export declare type ConstraintsMessages = {
|
|
37
37
|
accept?: string;
|
|
38
38
|
enum?: string;
|
|
39
39
|
exclusiveMinimum?: string;
|
|
@@ -53,14 +53,14 @@ export type ConstraintsMessages = {
|
|
|
53
53
|
type?: string;
|
|
54
54
|
validationExpression?: string;
|
|
55
55
|
};
|
|
56
|
-
export type RulesJson = {
|
|
56
|
+
export declare type RulesJson = {
|
|
57
57
|
rules?: Items<string>;
|
|
58
58
|
events?: Items<string[] | string | undefined>;
|
|
59
59
|
};
|
|
60
|
-
type TranslationBaseJson = {
|
|
60
|
+
declare type TranslationBaseJson = {
|
|
61
61
|
description?: string;
|
|
62
62
|
};
|
|
63
|
-
export type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
|
|
63
|
+
export declare type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
|
|
64
64
|
dataRef?: string | null;
|
|
65
65
|
lang?: string;
|
|
66
66
|
':type'?: string;
|
|
@@ -80,10 +80,10 @@ export type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
|
|
|
80
80
|
altText?: string;
|
|
81
81
|
viewType?: string;
|
|
82
82
|
};
|
|
83
|
-
type TranslationFieldJson = {
|
|
83
|
+
declare type TranslationFieldJson = {
|
|
84
84
|
placeholder?: string;
|
|
85
85
|
};
|
|
86
|
-
export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
86
|
+
export declare type FieldJson = BaseJson & TranslationFieldJson & {
|
|
87
87
|
readOnly?: boolean;
|
|
88
88
|
valid?: boolean;
|
|
89
89
|
default?: any;
|
|
@@ -94,20 +94,20 @@ export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
94
94
|
displayValue?: string;
|
|
95
95
|
emptyValue?: 'null' | 'undefined' | '';
|
|
96
96
|
};
|
|
97
|
-
export type ContainerJson = BaseJson & {
|
|
97
|
+
export declare type ContainerJson = BaseJson & {
|
|
98
98
|
items: Array<FieldJson | ContainerJson>;
|
|
99
99
|
initialItems?: number;
|
|
100
100
|
activeChild?: string;
|
|
101
101
|
};
|
|
102
|
-
export type MetaDataJson = {
|
|
102
|
+
export declare type MetaDataJson = {
|
|
103
103
|
version?: string;
|
|
104
104
|
grammar?: string;
|
|
105
105
|
};
|
|
106
|
-
export type FieldsetJson = ContainerJson & {
|
|
106
|
+
export declare type FieldsetJson = ContainerJson & {
|
|
107
107
|
'type'?: 'array' | 'object';
|
|
108
108
|
readOnly?: boolean;
|
|
109
109
|
};
|
|
110
|
-
export type FormJson = ContainerJson & {
|
|
110
|
+
export declare type FormJson = ContainerJson & {
|
|
111
111
|
metadata?: MetaDataJson;
|
|
112
112
|
data?: any;
|
|
113
113
|
title?: string;
|
|
@@ -115,7 +115,7 @@ export type FormJson = ContainerJson & {
|
|
|
115
115
|
adaptiveForm?: string;
|
|
116
116
|
lang?: string;
|
|
117
117
|
};
|
|
118
|
-
export type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
|
|
118
|
+
export declare type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
|
|
119
119
|
export declare const translationProps: string[];
|
|
120
120
|
export declare const constraintProps: string[];
|
|
121
121
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.constraintProps = exports.translationProps = void 0;
|
|
4
|
+
exports.translationProps = ['description', 'placeholder', 'enum', 'enumNames', 'label.value', 'constraintMessages.accept',
|
|
5
|
+
'constraintMessages.enum', 'constraintMessages.exclusiveMinimum', 'constraintMessages.exclusiveMaximum', 'constraintMessages.format', 'constraintMessages.maxFileSize', 'constraintMessages.maxLength',
|
|
6
|
+
'constraintMessages.maximum', 'constraintMessages.maxItems', 'constraintMessages.minLength', 'constraintMessages.minimum', 'constraintMessages.minItems', 'constraintMessages.pattern', 'constraintMessages.required',
|
|
7
|
+
'constraintMessages.step', 'constraintMessages.type', 'constraintMessages.validationExpression'];
|
|
8
|
+
exports.constraintProps = ['accept', 'enum', 'exclusiveMinimum', 'exclusiveMaximum',
|
|
9
|
+
'format', 'maxFileSize', 'maxLength', 'maximum', 'maxItems',
|
|
10
|
+
'minLength', 'minimum', 'minItems', 'pattern', 'required', 'step', 'validationExpression', 'enumNames'];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ConstraintsJson, ContainerJson, FieldJson, FieldsetJson, FormJson, Label, MetaDataJson } from './Json
|
|
2
|
-
import RuleEngine from '../rules/RuleEngine
|
|
3
|
-
import EventQueue from '../controller/EventQueue
|
|
4
|
-
import DataGroup from '../data/DataGroup
|
|
5
|
-
import { Logger } from '../controller/Logger
|
|
1
|
+
import { ConstraintsJson, ContainerJson, FieldJson, FieldsetJson, FormJson, Label, MetaDataJson } from './Json';
|
|
2
|
+
import RuleEngine from '../rules/RuleEngine';
|
|
3
|
+
import EventQueue from '../controller/EventQueue';
|
|
4
|
+
import DataGroup from '../data/DataGroup';
|
|
5
|
+
import { Logger } from '../controller/Logger';
|
|
6
6
|
export interface ScriptableField {
|
|
7
7
|
rules?: {
|
|
8
8
|
[key: string]: string;
|
|
@@ -15,15 +15,15 @@ export interface ScriptableField {
|
|
|
15
15
|
interface WithState<T> {
|
|
16
16
|
getState: () => any;
|
|
17
17
|
}
|
|
18
|
-
type stateProps = {
|
|
18
|
+
declare type stateProps = {
|
|
19
19
|
id: string;
|
|
20
20
|
index: number;
|
|
21
21
|
':type': string;
|
|
22
22
|
};
|
|
23
|
-
export type State<T> = stateProps & (T extends ContainerJson ? T & {
|
|
23
|
+
export declare type State<T> = stateProps & (T extends ContainerJson ? T & {
|
|
24
24
|
items: Array<State<FieldJson | ContainerJson>>;
|
|
25
25
|
} : T);
|
|
26
|
-
export type Subscription = {
|
|
26
|
+
export declare 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 type callbackFn = (action: Action) => void;
|
|
37
|
+
export declare type callbackFn = (action: Action) => void;
|
|
38
38
|
export interface WithController {
|
|
39
39
|
subscribe(callback: callbackFn, eventName?: string): Subscription;
|
|
40
40
|
dispatch(action: Action): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
class ValidationError {
|
|
5
|
+
constructor(fieldName = '', errorMessages = []) {
|
|
6
|
+
this.errorMessages = errorMessages;
|
|
7
|
+
this.fieldName = fieldName;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ValidationError = ValidationError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Json"), exports);
|
|
18
|
+
__exportStar(require("./Model"), exports);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import DataGroup from '../data/DataGroup
|
|
2
|
-
import DataValue from '../data/DataValue
|
|
3
|
-
type TokenType = string;
|
|
1
|
+
import DataGroup from '../data/DataGroup';
|
|
2
|
+
import DataValue from '../data/DataValue';
|
|
3
|
+
declare type TokenType = string;
|
|
4
4
|
export declare const TOK_GLOBAL: TokenType;
|
|
5
5
|
export declare const TOK_REPEATABLE: TokenType;
|
|
6
|
-
export type Token = {
|
|
6
|
+
export declare type Token = {
|
|
7
7
|
type: TokenType;
|
|
8
8
|
value: string | number;
|
|
9
9
|
start: number;
|