@aemforms/af-core 0.22.125 → 0.22.127

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.
@@ -1584,26 +1584,31 @@ class BaseNode {
1584
1584
  _data = NullDataValue;
1585
1585
  }
1586
1586
  else if (dataRef !== undefined && !this.repeatable) {
1587
- if (this._tokens.length === 0) {
1588
- this._tokens = tokenize(dataRef);
1589
- }
1590
- let searchData = contextualDataModel;
1591
- if (this._tokens[0].type === TOK_GLOBAL) {
1592
- searchData = this.form.getDataNode();
1593
- }
1594
- else if (this._tokens[0].type === TOK_REPEATABLE) {
1595
- let repeatRoot = this.parent;
1596
- while (!repeatRoot.repeatable && repeatRoot !== this.form) {
1597
- repeatRoot = repeatRoot.parent;
1587
+ try {
1588
+ if (this._tokens.length === 0) {
1589
+ this._tokens = tokenize(dataRef);
1590
+ }
1591
+ let searchData = contextualDataModel;
1592
+ if (this._tokens[0].type === TOK_GLOBAL) {
1593
+ searchData = this.form.getDataNode();
1594
+ }
1595
+ else if (this._tokens[0].type === TOK_REPEATABLE) {
1596
+ let repeatRoot = this.parent;
1597
+ while (!repeatRoot.repeatable && repeatRoot !== this.form) {
1598
+ repeatRoot = repeatRoot.parent;
1599
+ }
1600
+ searchData = repeatRoot.getDataNode();
1601
+ }
1602
+ if (typeof searchData !== 'undefined') {
1603
+ const name = this._tokens[this._tokens.length - 1].value;
1604
+ const create = this.defaultDataModel(name);
1605
+ _data = resolveData(searchData, this._tokens, create);
1606
+ _parent = resolveData(searchData, this._tokens.slice(0, -1));
1607
+ _key = name;
1598
1608
  }
1599
- searchData = repeatRoot.getDataNode();
1600
1609
  }
1601
- if (typeof searchData !== 'undefined') {
1602
- const name = this._tokens[this._tokens.length - 1].value;
1603
- const create = this.defaultDataModel(name);
1604
- _data = resolveData(searchData, this._tokens, create);
1605
- _parent = resolveData(searchData, this._tokens.slice(0, -1));
1606
- _key = name;
1610
+ catch (error) {
1611
+ console.error(`Error parsing dataRef "${dataRef}" for field "${this.id}". The data of this field will not be exported.`);
1607
1612
  }
1608
1613
  }
1609
1614
  else {
@@ -3313,6 +3318,67 @@ class FunctionRuntimeImpl {
3313
3318
  return encData;
3314
3319
  },
3315
3320
  _signature: []
3321
+ },
3322
+ getQueryParameter: {
3323
+ _func: (args, data, interpreter) => {
3324
+ const param = toString(args[0]);
3325
+ if (!param) {
3326
+ interpreter.globals.form.logger.error('Argument is missing in getQueryParameter. A parameter is expected');
3327
+ return '';
3328
+ }
3329
+ if (interpreter.globals.form?.properties?.queryParams?.[param]) {
3330
+ return interpreter.globals.form.properties.queryParams[param];
3331
+ }
3332
+ try {
3333
+ const urlParams = new URLSearchParams(window?.location?.search || '');
3334
+ return urlParams.get(param);
3335
+ }
3336
+ catch (e) {
3337
+ interpreter.globals.form.logger.warn('Error reading URL parameters:', e);
3338
+ }
3339
+ return '';
3340
+ },
3341
+ _signature: []
3342
+ },
3343
+ getBrowserDetail: {
3344
+ _func: (args, data, interpreter) => {
3345
+ const param = toString(args[0]);
3346
+ if (!param) {
3347
+ interpreter.globals.form.logger.error('Argument is missing in getBrowserDetail. A parameter is expected');
3348
+ return '';
3349
+ }
3350
+ if (interpreter.globals.form?.properties?.browserDetails?.[param]) {
3351
+ return interpreter.globals.form.properties.browserDetails[param];
3352
+ }
3353
+ if (typeof navigator !== 'undefined' && param in navigator) {
3354
+ return navigator[param] || '';
3355
+ }
3356
+ else {
3357
+ interpreter.globals.form.logger.warn(`Invalid or unsupported browser detail requested: "${param}"`);
3358
+ return '';
3359
+ }
3360
+ },
3361
+ _signature: []
3362
+ },
3363
+ getURLDetail: {
3364
+ _func: (args, data, interpreter) => {
3365
+ const param = toString(args[0]);
3366
+ if (!param) {
3367
+ interpreter.globals.form.logger.error('Argument is missing in getURLDetail. A parameter is expected');
3368
+ return '';
3369
+ }
3370
+ if (interpreter.globals.form?.properties?.urlDetails?.[param]) {
3371
+ return interpreter.globals.form.properties.urlDetails[param];
3372
+ }
3373
+ if (typeof window !== 'undefined' && typeof window.location !== 'undefined' && param in window.location) {
3374
+ return window.location[param] || '';
3375
+ }
3376
+ else {
3377
+ interpreter.globals.form.logger.warn(`Invalid or unsupported url parameter requested: "${param}"`);
3378
+ return '';
3379
+ }
3380
+ },
3381
+ _signature: []
3316
3382
  }
3317
3383
  };
3318
3384
  return { ...defaultFunctions, ...FunctionRuntimeImpl.getInstance().customFunctions };
@@ -83,6 +83,18 @@ declare class FunctionRuntimeImpl {
83
83
  _func: (args: Array<unknown>, data: unknown, interpreter: any) => Promise<any>;
84
84
  _signature: never[];
85
85
  };
86
+ getQueryParameter: {
87
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
88
+ _signature: never[];
89
+ };
90
+ getBrowserDetail: {
91
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
92
+ _signature: never[];
93
+ };
94
+ getURLDetail: {
95
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
96
+ _signature: never[];
97
+ };
86
98
  };
87
99
  }
88
100
  export declare const FunctionRuntime: FunctionRuntimeImpl;
package/lib/BaseNode.js CHANGED
@@ -380,26 +380,31 @@ class BaseNode {
380
380
  _data = EmptyDataValue_1.default;
381
381
  }
382
382
  else if (dataRef !== undefined && !this.repeatable) {
383
- if (this._tokens.length === 0) {
384
- this._tokens = (0, DataRefParser_1.tokenize)(dataRef);
385
- }
386
- let searchData = contextualDataModel;
387
- if (this._tokens[0].type === DataRefParser_1.TOK_GLOBAL) {
388
- searchData = this.form.getDataNode();
389
- }
390
- else if (this._tokens[0].type === DataRefParser_1.TOK_REPEATABLE) {
391
- let repeatRoot = this.parent;
392
- while (!repeatRoot.repeatable && repeatRoot !== this.form) {
393
- repeatRoot = repeatRoot.parent;
383
+ try {
384
+ if (this._tokens.length === 0) {
385
+ this._tokens = (0, DataRefParser_1.tokenize)(dataRef);
386
+ }
387
+ let searchData = contextualDataModel;
388
+ if (this._tokens[0].type === DataRefParser_1.TOK_GLOBAL) {
389
+ searchData = this.form.getDataNode();
390
+ }
391
+ else if (this._tokens[0].type === DataRefParser_1.TOK_REPEATABLE) {
392
+ let repeatRoot = this.parent;
393
+ while (!repeatRoot.repeatable && repeatRoot !== this.form) {
394
+ repeatRoot = repeatRoot.parent;
395
+ }
396
+ searchData = repeatRoot.getDataNode();
397
+ }
398
+ if (typeof searchData !== 'undefined') {
399
+ const name = this._tokens[this._tokens.length - 1].value;
400
+ const create = this.defaultDataModel(name);
401
+ _data = (0, DataRefParser_1.resolveData)(searchData, this._tokens, create);
402
+ _parent = (0, DataRefParser_1.resolveData)(searchData, this._tokens.slice(0, -1));
403
+ _key = name;
394
404
  }
395
- searchData = repeatRoot.getDataNode();
396
405
  }
397
- if (typeof searchData !== 'undefined') {
398
- const name = this._tokens[this._tokens.length - 1].value;
399
- const create = this.defaultDataModel(name);
400
- _data = (0, DataRefParser_1.resolveData)(searchData, this._tokens, create);
401
- _parent = (0, DataRefParser_1.resolveData)(searchData, this._tokens.slice(0, -1));
402
- _key = name;
406
+ catch (error) {
407
+ console.error(`Error parsing dataRef "${dataRef}" for field "${this.id}". The data of this field will not be exported.`);
403
408
  }
404
409
  }
405
410
  else {
@@ -83,6 +83,18 @@ declare class FunctionRuntimeImpl {
83
83
  _func: (args: Array<unknown>, data: unknown, interpreter: any) => Promise<any>;
84
84
  _signature: never[];
85
85
  };
86
+ getQueryParameter: {
87
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
88
+ _signature: never[];
89
+ };
90
+ getBrowserDetail: {
91
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
92
+ _signature: never[];
93
+ };
94
+ getURLDetail: {
95
+ _func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
96
+ _signature: never[];
97
+ };
86
98
  };
87
99
  }
88
100
  export declare const FunctionRuntime: FunctionRuntimeImpl;
@@ -668,6 +668,70 @@ class FunctionRuntimeImpl {
668
668
  return encData;
669
669
  }),
670
670
  _signature: []
671
+ },
672
+ getQueryParameter: {
673
+ _func: (args, data, interpreter) => {
674
+ var _a, _b, _c, _d;
675
+ const param = toString(args[0]);
676
+ if (!param) {
677
+ interpreter.globals.form.logger.error('Argument is missing in getQueryParameter. A parameter is expected');
678
+ return '';
679
+ }
680
+ if ((_c = (_b = (_a = interpreter.globals.form) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.queryParams) === null || _c === void 0 ? void 0 : _c[param]) {
681
+ return interpreter.globals.form.properties.queryParams[param];
682
+ }
683
+ try {
684
+ const urlParams = new URLSearchParams(((_d = window === null || window === void 0 ? void 0 : window.location) === null || _d === void 0 ? void 0 : _d.search) || '');
685
+ return urlParams.get(param);
686
+ }
687
+ catch (e) {
688
+ interpreter.globals.form.logger.warn('Error reading URL parameters:', e);
689
+ }
690
+ return '';
691
+ },
692
+ _signature: []
693
+ },
694
+ getBrowserDetail: {
695
+ _func: (args, data, interpreter) => {
696
+ var _a, _b, _c;
697
+ const param = toString(args[0]);
698
+ if (!param) {
699
+ interpreter.globals.form.logger.error('Argument is missing in getBrowserDetail. A parameter is expected');
700
+ return '';
701
+ }
702
+ if ((_c = (_b = (_a = interpreter.globals.form) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.browserDetails) === null || _c === void 0 ? void 0 : _c[param]) {
703
+ return interpreter.globals.form.properties.browserDetails[param];
704
+ }
705
+ if (typeof navigator !== 'undefined' && param in navigator) {
706
+ return navigator[param] || '';
707
+ }
708
+ else {
709
+ interpreter.globals.form.logger.warn(`Invalid or unsupported browser detail requested: "${param}"`);
710
+ return '';
711
+ }
712
+ },
713
+ _signature: []
714
+ },
715
+ getURLDetail: {
716
+ _func: (args, data, interpreter) => {
717
+ var _a, _b, _c;
718
+ const param = toString(args[0]);
719
+ if (!param) {
720
+ interpreter.globals.form.logger.error('Argument is missing in getURLDetail. A parameter is expected');
721
+ return '';
722
+ }
723
+ if ((_c = (_b = (_a = interpreter.globals.form) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.urlDetails) === null || _c === void 0 ? void 0 : _c[param]) {
724
+ return interpreter.globals.form.properties.urlDetails[param];
725
+ }
726
+ if (typeof window !== 'undefined' && typeof window.location !== 'undefined' && param in window.location) {
727
+ return window.location[param] || '';
728
+ }
729
+ else {
730
+ interpreter.globals.form.logger.warn(`Invalid or unsupported url parameter requested: "${param}"`);
731
+ return '';
732
+ }
733
+ },
734
+ _signature: []
671
735
  }
672
736
  };
673
737
  return Object.assign(Object.assign({}, defaultFunctions), FunctionRuntimeImpl.getInstance().customFunctions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.125",
3
+ "version": "0.22.127",
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.125"
40
+ "@aemforms/af-formatters": "^0.22.127"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",