@aemforms/af-core 0.22.87 → 0.22.89
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/esm/afb-runtime.js +44 -3
- package/esm/types/src/Captcha.d.ts +13 -2
- package/esm/types/src/FileObject.d.ts +1 -0
- package/esm/types/src/FileUpload.d.ts +1 -1
- package/esm/types/src/types/Json.d.ts +6 -0
- package/esm/types/src/types/Model.d.ts +9 -0
- package/lib/Captcha.d.ts +13 -2
- package/lib/Captcha.js +15 -0
- package/lib/FileObject.d.ts +1 -0
- package/lib/FileObject.js +3 -0
- package/lib/FileUpload.d.ts +1 -1
- package/lib/FileUpload.js +1 -1
- package/lib/rules/FunctionRuntime.js +20 -4
- package/lib/types/Json.d.ts +6 -0
- package/lib/types/Model.d.ts +9 -0
- package/lib/types/Model.js +6 -1
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -81,6 +81,11 @@ var FocusOption;
|
|
|
81
81
|
FocusOption["NEXT_ITEM"] = "nextItem";
|
|
82
82
|
FocusOption["PREVIOUS_ITEM"] = "previousItem";
|
|
83
83
|
})(FocusOption || (FocusOption = {}));
|
|
84
|
+
var CaptchaDisplayMode;
|
|
85
|
+
(function (CaptchaDisplayMode) {
|
|
86
|
+
CaptchaDisplayMode["INVISIBLE"] = "invisible";
|
|
87
|
+
CaptchaDisplayMode["VISIBLE"] = "visible";
|
|
88
|
+
})(CaptchaDisplayMode || (CaptchaDisplayMode = {}));
|
|
84
89
|
|
|
85
90
|
const objToMap = (o) => new Map(Object.entries(o));
|
|
86
91
|
const stringViewTypes = objToMap({ 'date': 'date-input', 'data-url': 'file-input', 'binary': 'file-input' });
|
|
@@ -592,6 +597,9 @@ class FileObject {
|
|
|
592
597
|
get type() {
|
|
593
598
|
return this.mediaType;
|
|
594
599
|
}
|
|
600
|
+
set type(type) {
|
|
601
|
+
this.mediaType = type;
|
|
602
|
+
}
|
|
595
603
|
toJSON() {
|
|
596
604
|
return {
|
|
597
605
|
'name': this.name,
|
|
@@ -2699,6 +2707,21 @@ class FunctionRuntimeImpl {
|
|
|
2699
2707
|
dispatchEvent: (target, eventName, payload) => {
|
|
2700
2708
|
const args = [target, eventName, payload];
|
|
2701
2709
|
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
2710
|
+
},
|
|
2711
|
+
getFiles: (qualifiedName) => {
|
|
2712
|
+
const filesMap = {};
|
|
2713
|
+
if (!qualifiedName) {
|
|
2714
|
+
interpreter.globals.form.visit(function callback(f) {
|
|
2715
|
+
if (f.fieldType === 'file-input' && f.value) {
|
|
2716
|
+
filesMap[f.qualifiedName] = f.serialize();
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
const field = interpreter.globals.form.resolveQualifiedName(qualifiedName);
|
|
2721
|
+
if (field?.fieldType === 'file-input' && field?.value) {
|
|
2722
|
+
filesMap[qualifiedName] = field.serialize();
|
|
2723
|
+
}
|
|
2724
|
+
return filesMap;
|
|
2702
2725
|
}
|
|
2703
2726
|
}
|
|
2704
2727
|
};
|
|
@@ -2819,8 +2842,8 @@ class FunctionRuntimeImpl {
|
|
|
2819
2842
|
validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
2820
2843
|
}
|
|
2821
2844
|
const form = interpreter.globals.form;
|
|
2822
|
-
if (form.captcha && form.captcha.
|
|
2823
|
-
&& form.captcha.properties['fd:captcha']
|
|
2845
|
+
if (form.captcha && (form.captcha.captchaDisplayMode === CaptchaDisplayMode.INVISIBLE ||
|
|
2846
|
+
(form.captcha.properties['fd:captcha']?.config?.version === 'enterprise' && form.captcha.properties['fd:captcha']?.config?.keyType === 'score'))) {
|
|
2824
2847
|
if (typeof interpreter.runtime.functionTable.fetchCaptchaToken?._func !== 'function') {
|
|
2825
2848
|
interpreter.globals.form.logger.error('fetchCaptchaToken is not defined');
|
|
2826
2849
|
interpreter.globals.form.dispatch(new SubmitError({ type: 'FetchCaptchaTokenNotDefined' }));
|
|
@@ -4307,7 +4330,7 @@ class FileUpload extends Field {
|
|
|
4307
4330
|
}
|
|
4308
4331
|
return dataNodeValue;
|
|
4309
4332
|
}
|
|
4310
|
-
async
|
|
4333
|
+
async serialize() {
|
|
4311
4334
|
const val = this._jsonModel.value;
|
|
4312
4335
|
if (val === undefined) {
|
|
4313
4336
|
return null;
|
|
@@ -4474,12 +4497,30 @@ class EmailInput extends Field {
|
|
|
4474
4497
|
}
|
|
4475
4498
|
|
|
4476
4499
|
class Captcha extends Field {
|
|
4500
|
+
_captchaDisplayMode;
|
|
4501
|
+
_captchaProvider;
|
|
4502
|
+
_captchaSiteKey;
|
|
4503
|
+
constructor(params, _options) {
|
|
4504
|
+
super(params, _options);
|
|
4505
|
+
this._captchaDisplayMode = params.captchaDisplayMode;
|
|
4506
|
+
this._captchaProvider = params.captchaProvider;
|
|
4507
|
+
this._captchaSiteKey = params.siteKey;
|
|
4508
|
+
}
|
|
4477
4509
|
getDataNode() {
|
|
4478
4510
|
return undefined;
|
|
4479
4511
|
}
|
|
4480
4512
|
custom_setProperty(action) {
|
|
4481
4513
|
this.applyUpdates(action.payload);
|
|
4482
4514
|
}
|
|
4515
|
+
get captchaDisplayMode() {
|
|
4516
|
+
return this._captchaDisplayMode;
|
|
4517
|
+
}
|
|
4518
|
+
get captchaProvider() {
|
|
4519
|
+
return this._captchaProvider;
|
|
4520
|
+
}
|
|
4521
|
+
get captchaSiteKey() {
|
|
4522
|
+
return this._captchaSiteKey;
|
|
4523
|
+
}
|
|
4483
4524
|
}
|
|
4484
4525
|
|
|
4485
4526
|
class Button extends Field {
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import Field from './Field';
|
|
2
|
-
import { Action } from './types';
|
|
3
|
-
declare class Captcha extends Field {
|
|
2
|
+
import { Action, CaptchaDisplayMode, CaptchaJson, CaptchaModel, ContainerModel, FormModel } from './types';
|
|
3
|
+
declare class Captcha extends Field implements CaptchaModel {
|
|
4
|
+
private _captchaDisplayMode;
|
|
5
|
+
private _captchaProvider;
|
|
6
|
+
private _captchaSiteKey;
|
|
7
|
+
constructor(params: CaptchaJson, _options: {
|
|
8
|
+
form: FormModel;
|
|
9
|
+
parent: ContainerModel;
|
|
10
|
+
mode?: 'create' | 'restore';
|
|
11
|
+
});
|
|
4
12
|
getDataNode(): undefined;
|
|
5
13
|
custom_setProperty(action: Action): void;
|
|
14
|
+
get captchaDisplayMode(): CaptchaDisplayMode | undefined;
|
|
15
|
+
get captchaProvider(): string | undefined;
|
|
16
|
+
get captchaSiteKey(): string | undefined;
|
|
6
17
|
}
|
|
7
18
|
export default Captcha;
|
|
@@ -21,7 +21,7 @@ declare class FileUpload extends Field implements FieldModel {
|
|
|
21
21
|
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
22
22
|
protected getInternalType(): "file" | "file[]";
|
|
23
23
|
protected getDataNodeValue(typedValue: any): any;
|
|
24
|
-
|
|
24
|
+
serialize(): Promise<unknown[] | null>;
|
|
25
25
|
importData(dataModel: DataGroup): void;
|
|
26
26
|
}
|
|
27
27
|
export default FileUpload;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CaptchaDisplayMode } from './Model';
|
|
1
2
|
export type Items<T> = {
|
|
2
3
|
[key: string]: T;
|
|
3
4
|
};
|
|
@@ -100,6 +101,11 @@ export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
100
101
|
emptyValue?: 'null' | 'undefined' | '';
|
|
101
102
|
checked?: boolean;
|
|
102
103
|
};
|
|
104
|
+
export type CaptchaJson = FieldJson & {
|
|
105
|
+
captchaDisplayMode?: CaptchaDisplayMode | undefined;
|
|
106
|
+
captchaProvider?: string | undefined;
|
|
107
|
+
siteKey?: string | undefined;
|
|
108
|
+
};
|
|
103
109
|
export type ContainerJson = BaseJson & {
|
|
104
110
|
items: Array<FieldJson | ContainerJson>;
|
|
105
111
|
initialItems?: number;
|
|
@@ -83,6 +83,11 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
|
|
|
83
83
|
readonly displayValueExpression?: string;
|
|
84
84
|
readonly editValue?: string;
|
|
85
85
|
}
|
|
86
|
+
export interface CaptchaModel extends FieldModel {
|
|
87
|
+
captchaDisplayMode: CaptchaDisplayMode | undefined;
|
|
88
|
+
captchaProvider: string | undefined;
|
|
89
|
+
captchaSiteKey: string | undefined;
|
|
90
|
+
}
|
|
86
91
|
export interface FormMetaDataModel {
|
|
87
92
|
readonly version?: string;
|
|
88
93
|
readonly grammar: string;
|
|
@@ -144,4 +149,8 @@ export declare enum FocusOption {
|
|
|
144
149
|
NEXT_ITEM = "nextItem",
|
|
145
150
|
PREVIOUS_ITEM = "previousItem"
|
|
146
151
|
}
|
|
152
|
+
export declare enum CaptchaDisplayMode {
|
|
153
|
+
INVISIBLE = "invisible",
|
|
154
|
+
VISIBLE = "visible"
|
|
155
|
+
}
|
|
147
156
|
export {};
|
package/lib/Captcha.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import Field from './Field';
|
|
2
|
-
import { Action } from './types';
|
|
3
|
-
declare class Captcha extends Field {
|
|
2
|
+
import { Action, CaptchaDisplayMode, CaptchaJson, CaptchaModel, ContainerModel, FormModel } from './types';
|
|
3
|
+
declare class Captcha extends Field implements CaptchaModel {
|
|
4
|
+
private _captchaDisplayMode;
|
|
5
|
+
private _captchaProvider;
|
|
6
|
+
private _captchaSiteKey;
|
|
7
|
+
constructor(params: CaptchaJson, _options: {
|
|
8
|
+
form: FormModel;
|
|
9
|
+
parent: ContainerModel;
|
|
10
|
+
mode?: 'create' | 'restore';
|
|
11
|
+
});
|
|
4
12
|
getDataNode(): undefined;
|
|
5
13
|
custom_setProperty(action: Action): void;
|
|
14
|
+
get captchaDisplayMode(): CaptchaDisplayMode | undefined;
|
|
15
|
+
get captchaProvider(): string | undefined;
|
|
16
|
+
get captchaSiteKey(): string | undefined;
|
|
6
17
|
}
|
|
7
18
|
export default Captcha;
|
package/lib/Captcha.js
CHANGED
|
@@ -5,11 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Field_1 = __importDefault(require("./Field"));
|
|
7
7
|
class Captcha extends Field_1.default {
|
|
8
|
+
constructor(params, _options) {
|
|
9
|
+
super(params, _options);
|
|
10
|
+
this._captchaDisplayMode = params.captchaDisplayMode;
|
|
11
|
+
this._captchaProvider = params.captchaProvider;
|
|
12
|
+
this._captchaSiteKey = params.siteKey;
|
|
13
|
+
}
|
|
8
14
|
getDataNode() {
|
|
9
15
|
return undefined;
|
|
10
16
|
}
|
|
11
17
|
custom_setProperty(action) {
|
|
12
18
|
this.applyUpdates(action.payload);
|
|
13
19
|
}
|
|
20
|
+
get captchaDisplayMode() {
|
|
21
|
+
return this._captchaDisplayMode;
|
|
22
|
+
}
|
|
23
|
+
get captchaProvider() {
|
|
24
|
+
return this._captchaProvider;
|
|
25
|
+
}
|
|
26
|
+
get captchaSiteKey() {
|
|
27
|
+
return this._captchaSiteKey;
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
exports.default = Captcha;
|
package/lib/FileObject.d.ts
CHANGED
package/lib/FileObject.js
CHANGED
package/lib/FileUpload.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare class FileUpload extends Field implements FieldModel {
|
|
|
21
21
|
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
22
22
|
protected getInternalType(): "file" | "file[]";
|
|
23
23
|
protected getDataNodeValue(typedValue: any): any;
|
|
24
|
-
|
|
24
|
+
serialize(): Promise<unknown[] | null>;
|
|
25
25
|
importData(dataModel: DataGroup): void;
|
|
26
26
|
}
|
|
27
27
|
export default FileUpload;
|
package/lib/FileUpload.js
CHANGED
|
@@ -15,6 +15,7 @@ const Fetch_1 = require("../utils/Fetch");
|
|
|
15
15
|
const FileObject_1 = require("../FileObject");
|
|
16
16
|
const FormUtils_1 = require("../utils/FormUtils");
|
|
17
17
|
const JsonUtils_1 = require("../utils/JsonUtils");
|
|
18
|
+
const types_1 = require("../types");
|
|
18
19
|
const getCustomEventName = (name) => {
|
|
19
20
|
const eName = name;
|
|
20
21
|
if (eName.length > 0 && eName.startsWith('custom:')) {
|
|
@@ -238,6 +239,21 @@ class FunctionRuntimeImpl {
|
|
|
238
239
|
dispatchEvent: (target, eventName, payload) => {
|
|
239
240
|
const args = [target, eventName, payload];
|
|
240
241
|
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
242
|
+
},
|
|
243
|
+
getFiles: (qualifiedName) => {
|
|
244
|
+
const filesMap = {};
|
|
245
|
+
if (!qualifiedName) {
|
|
246
|
+
interpreter.globals.form.visit(function callback(f) {
|
|
247
|
+
if (f.fieldType === 'file-input' && f.value) {
|
|
248
|
+
filesMap[f.qualifiedName] = f.serialize();
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const field = interpreter.globals.form.resolveQualifiedName(qualifiedName);
|
|
253
|
+
if ((field === null || field === void 0 ? void 0 : field.fieldType) === 'file-input' && (field === null || field === void 0 ? void 0 : field.value)) {
|
|
254
|
+
filesMap[qualifiedName] = field.serialize();
|
|
255
|
+
}
|
|
256
|
+
return filesMap;
|
|
241
257
|
}
|
|
242
258
|
}
|
|
243
259
|
};
|
|
@@ -339,7 +355,7 @@ class FunctionRuntimeImpl {
|
|
|
339
355
|
},
|
|
340
356
|
submitForm: {
|
|
341
357
|
_func: (args, data, interpreter) => __awaiter(this, void 0, void 0, function* () {
|
|
342
|
-
var _a;
|
|
358
|
+
var _a, _b, _c, _d, _e;
|
|
343
359
|
let success = null;
|
|
344
360
|
let error = null;
|
|
345
361
|
let submit_data;
|
|
@@ -359,9 +375,9 @@ class FunctionRuntimeImpl {
|
|
|
359
375
|
validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
360
376
|
}
|
|
361
377
|
const form = interpreter.globals.form;
|
|
362
|
-
if (form.captcha && form.captcha.
|
|
363
|
-
&& form.captcha.properties['fd:captcha'].config.keyType === 'score') {
|
|
364
|
-
if (typeof ((
|
|
378
|
+
if (form.captcha && (form.captcha.captchaDisplayMode === types_1.CaptchaDisplayMode.INVISIBLE ||
|
|
379
|
+
(((_b = (_a = form.captcha.properties['fd:captcha']) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.version) === 'enterprise' && ((_d = (_c = form.captcha.properties['fd:captcha']) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.keyType) === 'score'))) {
|
|
380
|
+
if (typeof ((_e = interpreter.runtime.functionTable.fetchCaptchaToken) === null || _e === void 0 ? void 0 : _e._func) !== 'function') {
|
|
365
381
|
interpreter.globals.form.logger.error('fetchCaptchaToken is not defined');
|
|
366
382
|
interpreter.globals.form.dispatch(new Events_1.SubmitError({ type: 'FetchCaptchaTokenNotDefined' }));
|
|
367
383
|
return {};
|
package/lib/types/Json.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CaptchaDisplayMode } from './Model';
|
|
1
2
|
export declare type Items<T> = {
|
|
2
3
|
[key: string]: T;
|
|
3
4
|
};
|
|
@@ -100,6 +101,11 @@ export declare type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
100
101
|
emptyValue?: 'null' | 'undefined' | '';
|
|
101
102
|
checked?: boolean;
|
|
102
103
|
};
|
|
104
|
+
export declare type CaptchaJson = FieldJson & {
|
|
105
|
+
captchaDisplayMode?: CaptchaDisplayMode | undefined;
|
|
106
|
+
captchaProvider?: string | undefined;
|
|
107
|
+
siteKey?: string | undefined;
|
|
108
|
+
};
|
|
103
109
|
export declare type ContainerJson = BaseJson & {
|
|
104
110
|
items: Array<FieldJson | ContainerJson>;
|
|
105
111
|
initialItems?: number;
|
package/lib/types/Model.d.ts
CHANGED
|
@@ -83,6 +83,11 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
|
|
|
83
83
|
readonly displayValueExpression?: string;
|
|
84
84
|
readonly editValue?: string;
|
|
85
85
|
}
|
|
86
|
+
export interface CaptchaModel extends FieldModel {
|
|
87
|
+
captchaDisplayMode: CaptchaDisplayMode | undefined;
|
|
88
|
+
captchaProvider: string | undefined;
|
|
89
|
+
captchaSiteKey: string | undefined;
|
|
90
|
+
}
|
|
86
91
|
export interface FormMetaDataModel {
|
|
87
92
|
readonly version?: string;
|
|
88
93
|
readonly grammar: string;
|
|
@@ -144,4 +149,8 @@ export declare enum FocusOption {
|
|
|
144
149
|
NEXT_ITEM = "nextItem",
|
|
145
150
|
PREVIOUS_ITEM = "previousItem"
|
|
146
151
|
}
|
|
152
|
+
export declare enum CaptchaDisplayMode {
|
|
153
|
+
INVISIBLE = "invisible",
|
|
154
|
+
VISIBLE = "visible"
|
|
155
|
+
}
|
|
147
156
|
export {};
|
package/lib/types/Model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FocusOption = exports.ValidationError = void 0;
|
|
3
|
+
exports.CaptchaDisplayMode = exports.FocusOption = exports.ValidationError = void 0;
|
|
4
4
|
class ValidationError {
|
|
5
5
|
constructor(fieldName = '', errorMessages = []) {
|
|
6
6
|
this.errorMessages = errorMessages;
|
|
@@ -13,3 +13,8 @@ var FocusOption;
|
|
|
13
13
|
FocusOption["NEXT_ITEM"] = "nextItem";
|
|
14
14
|
FocusOption["PREVIOUS_ITEM"] = "previousItem";
|
|
15
15
|
})(FocusOption = exports.FocusOption || (exports.FocusOption = {}));
|
|
16
|
+
var CaptchaDisplayMode;
|
|
17
|
+
(function (CaptchaDisplayMode) {
|
|
18
|
+
CaptchaDisplayMode["INVISIBLE"] = "invisible";
|
|
19
|
+
CaptchaDisplayMode["VISIBLE"] = "visible";
|
|
20
|
+
})(CaptchaDisplayMode = exports.CaptchaDisplayMode || (exports.CaptchaDisplayMode = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.89",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@adobe/json-formula": "0.1.50",
|
|
40
|
-
"@aemforms/af-formatters": "^0.22.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.89"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|