@lowdefy/operators 5.5.1 → 5.6.0

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.
@@ -12,7 +12,7 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { applyArrayIndices, get, serializer, type } from '@lowdefy/helpers';
15
+ */ import { ReservedKeyError, applyArrayIndices, get, serializer, type } from '@lowdefy/helpers';
16
16
  function getFromObject({ params, object, arrayIndices, operator, location }) {
17
17
  if (params === true) params = {
18
18
  all: true
@@ -23,20 +23,26 @@ function getFromObject({ params, object, arrayIndices, operator, location }) {
23
23
  if (!type.isObject(params)) {
24
24
  throw new Error(`${operator} params must be of type string, integer, boolean or object.`);
25
25
  }
26
- if (params.key === null) return get(params, 'default', {
26
+ const defaultValue = get(params, 'default', {
27
27
  default: null,
28
28
  copy: true
29
29
  });
30
+ if (params.key === null) return defaultValue;
30
31
  if (params.all === true) return serializer.copy(object);
31
32
  if (!type.isString(params.key) && !type.isInt(params.key)) {
32
33
  throw new Error(`${operator}.key must be of type string or integer.`);
33
34
  }
34
- return get(object, applyArrayIndices(arrayIndices, params.key), {
35
- default: get(params, 'default', {
36
- default: null,
35
+ try {
36
+ return get(object, applyArrayIndices(arrayIndices, params.key), {
37
+ default: defaultValue,
37
38
  copy: true
38
- }),
39
- copy: true
40
- });
39
+ });
40
+ } catch (error) {
41
+ // Tier 2: a runtime read of an app-developer keypath. There is no loud failure that helps here —
42
+ // a thrown error in the browser is worse than the default, and the reserved rule's job (refusing
43
+ // the read) is already done. Author-written identifiers fail loudly at build instead.
44
+ if (error instanceof ReservedKeyError) return defaultValue;
45
+ throw error;
46
+ }
41
47
  }
42
48
  export default getFromObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators",
3
- "version": "5.5.1",
3
+ "version": "5.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -34,8 +34,8 @@
34
34
  "dist/*"
35
35
  ],
36
36
  "dependencies": {
37
- "@lowdefy/errors": "5.5.1",
38
- "@lowdefy/helpers": "5.5.1"
37
+ "@lowdefy/errors": "5.6.0",
38
+ "@lowdefy/helpers": "5.6.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@jest/globals": "28.1.3",