@aemforms/af-core 0.22.86 → 0.22.88

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.
@@ -592,6 +592,9 @@ class FileObject {
592
592
  get type() {
593
593
  return this.mediaType;
594
594
  }
595
+ set type(type) {
596
+ this.mediaType = type;
597
+ }
595
598
  toJSON() {
596
599
  return {
597
600
  'name': this.name,
@@ -2699,6 +2702,21 @@ class FunctionRuntimeImpl {
2699
2702
  dispatchEvent: (target, eventName, payload) => {
2700
2703
  const args = [target, eventName, payload];
2701
2704
  return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
2705
+ },
2706
+ getFiles: (qualifiedName) => {
2707
+ const filesMap = {};
2708
+ if (!qualifiedName) {
2709
+ interpreter.globals.form.visit(function callback(f) {
2710
+ if (f.fieldType === 'file-input' && f.value) {
2711
+ filesMap[f.qualifiedName] = f.serialize();
2712
+ }
2713
+ });
2714
+ }
2715
+ const field = interpreter.globals.form.resolveQualifiedName(qualifiedName);
2716
+ if (field?.fieldType === 'file-input' && field?.value) {
2717
+ filesMap[qualifiedName] = field.serialize();
2718
+ }
2719
+ return filesMap;
2702
2720
  }
2703
2721
  }
2704
2722
  };
@@ -3100,7 +3118,7 @@ class Form extends Container {
3100
3118
  const options = {
3101
3119
  lang: this.lang,
3102
3120
  captchaInfo: captchaInfoObj,
3103
- additionalSubmitMetadata: { ...this.additionalSubmitMetadata }
3121
+ ...this.additionalSubmitMetadata
3104
3122
  };
3105
3123
  return new SubmitMetaData(options);
3106
3124
  }
@@ -4307,7 +4325,7 @@ class FileUpload extends Field {
4307
4325
  }
4308
4326
  return dataNodeValue;
4309
4327
  }
4310
- async _serialize() {
4328
+ async serialize() {
4311
4329
  const val = this._jsonModel.value;
4312
4330
  if (val === undefined) {
4313
4331
  return null;
@@ -6,6 +6,7 @@ export declare class FileObject implements IFileObject {
6
6
  size: number;
7
7
  constructor(init?: Partial<FileObject>);
8
8
  get type(): string;
9
+ set type(type: string);
9
10
  toJSON(): {
10
11
  name: string;
11
12
  size: number;
@@ -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
- private _serialize;
24
+ serialize(): Promise<unknown[] | null>;
25
25
  importData(dataModel: DataGroup): void;
26
26
  }
27
27
  export default FileUpload;
@@ -1,10 +1,10 @@
1
1
  import Container from './Container';
2
- import { Action, BaseModel, FieldModel, FieldsetModel, FormCreationMode, FormJson, FocusOption, FormModel, IFormFieldFactory } from './types/index';
3
2
  import FormMetaData from './FormMetaData';
4
3
  import SubmitMetaData from './SubmitMetaData';
5
4
  import EventQueue from './controller/EventQueue';
6
- import { Logger, LogLevel } from './controller/Logger';
5
+ import { LogLevel, Logger } from './controller/Logger';
7
6
  import RuleEngine from './rules/RuleEngine';
7
+ import { Action, BaseModel, FieldModel, FieldsetModel, FocusOption, FormCreationMode, FormJson, FormModel, IFormFieldFactory } from './types/index';
8
8
  import { Version } from './utils/Version';
9
9
  export declare const currentVersion: Version;
10
10
  declare class Form extends Container<FormJson> implements FormModel {
@@ -6,6 +6,7 @@ export declare class FileObject implements IFileObject {
6
6
  size: number;
7
7
  constructor(init?: Partial<FileObject>);
8
8
  get type(): string;
9
+ set type(type: string);
9
10
  toJSON(): {
10
11
  name: string;
11
12
  size: number;
package/lib/FileObject.js CHANGED
@@ -11,6 +11,9 @@ class FileObject {
11
11
  get type() {
12
12
  return this.mediaType;
13
13
  }
14
+ set type(type) {
15
+ this.mediaType = type;
16
+ }
14
17
  toJSON() {
15
18
  return {
16
19
  'name': this.name,
@@ -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
- private _serialize;
24
+ serialize(): Promise<unknown[] | null>;
25
25
  importData(dataModel: DataGroup): void;
26
26
  }
27
27
  export default FileUpload;
package/lib/FileUpload.js CHANGED
@@ -93,7 +93,7 @@ class FileUpload extends Field_1.default {
93
93
  }
94
94
  return dataNodeValue;
95
95
  }
96
- _serialize() {
96
+ serialize() {
97
97
  return __awaiter(this, void 0, void 0, function* () {
98
98
  const val = this._jsonModel.value;
99
99
  if (val === undefined) {
package/lib/Form.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import Container from './Container';
2
- import { Action, BaseModel, FieldModel, FieldsetModel, FormCreationMode, FormJson, FocusOption, FormModel, IFormFieldFactory } from './types/index';
3
2
  import FormMetaData from './FormMetaData';
4
3
  import SubmitMetaData from './SubmitMetaData';
5
4
  import EventQueue from './controller/EventQueue';
6
- import { Logger, LogLevel } from './controller/Logger';
5
+ import { LogLevel, Logger } from './controller/Logger';
7
6
  import RuleEngine from './rules/RuleEngine';
7
+ import { Action, BaseModel, FieldModel, FieldsetModel, FocusOption, FormCreationMode, FormJson, FormModel, IFormFieldFactory } from './types/index';
8
8
  import { Version } from './utils/Version';
9
9
  export declare const currentVersion: Version;
10
10
  declare class Form extends Container<FormJson> implements FormModel {
package/lib/Form.js CHANGED
@@ -11,15 +11,15 @@ var _Form_instances, _Form_getNavigableChildren, _Form_getFirstNavigableChild, _
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.currentVersion = void 0;
13
13
  const Container_1 = __importDefault(require("./Container"));
14
- const index_1 = require("./types/index");
15
14
  const FormMetaData_1 = __importDefault(require("./FormMetaData"));
16
15
  const SubmitMetaData_1 = __importDefault(require("./SubmitMetaData"));
17
16
  const EventQueue_1 = __importDefault(require("./controller/EventQueue"));
17
+ const Events_1 = require("./controller/Events");
18
18
  const Logger_1 = require("./controller/Logger");
19
- const FormUtils_1 = require("./utils/FormUtils");
20
19
  const DataGroup_1 = __importDefault(require("./data/DataGroup"));
21
20
  const FunctionRuntime_1 = require("./rules/FunctionRuntime");
22
- const Events_1 = require("./controller/Events");
21
+ const index_1 = require("./types/index");
22
+ const FormUtils_1 = require("./utils/FormUtils");
23
23
  const Version_1 = require("./utils/Version");
24
24
  exports.currentVersion = new Version_1.Version('0.13');
25
25
  const changeEventVersion = new Version_1.Version('0.13');
@@ -126,11 +126,7 @@ class Form extends Container_1.default {
126
126
  captchaInfoObj[field.qualifiedName] = field.value;
127
127
  }
128
128
  });
129
- const options = {
130
- lang: this.lang,
131
- captchaInfo: captchaInfoObj,
132
- additionalSubmitMetadata: Object.assign({}, this.additionalSubmitMetadata)
133
- };
129
+ const options = Object.assign({ lang: this.lang, captchaInfo: captchaInfoObj }, this.additionalSubmitMetadata);
134
130
  return new SubmitMetaData_1.default(options);
135
131
  }
136
132
  setFocus(field, focusOption) {
@@ -238,6 +238,21 @@ class FunctionRuntimeImpl {
238
238
  dispatchEvent: (target, eventName, payload) => {
239
239
  const args = [target, eventName, payload];
240
240
  return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
241
+ },
242
+ getFiles: (qualifiedName) => {
243
+ const filesMap = {};
244
+ if (!qualifiedName) {
245
+ interpreter.globals.form.visit(function callback(f) {
246
+ if (f.fieldType === 'file-input' && f.value) {
247
+ filesMap[f.qualifiedName] = f.serialize();
248
+ }
249
+ });
250
+ }
251
+ const field = interpreter.globals.form.resolveQualifiedName(qualifiedName);
252
+ if ((field === null || field === void 0 ? void 0 : field.fieldType) === 'file-input' && (field === null || field === void 0 ? void 0 : field.value)) {
253
+ filesMap[qualifiedName] = field.serialize();
254
+ }
255
+ return filesMap;
241
256
  }
242
257
  }
243
258
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.86",
3
+ "version": "0.22.88",
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.86"
40
+ "@aemforms/af-formatters": "^0.22.88"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",