@aemforms/af-core 0.22.87 → 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
  };
@@ -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;
@@ -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) {
@@ -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.87",
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.87"
40
+ "@aemforms/af-formatters": "^0.22.88"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",