@appsemble/utils 0.30.2 → 0.30.3

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/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.30.2/config/assets/logo.svg) Appsemble Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.30.3/config/assets/logo.svg) Appsemble Utilities
2
2
 
3
3
  > Internal utility functions used across multiple Appsemble projects.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/utils)](https://www.npmjs.com/package/@appsemble/utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.30.2/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.30.2)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.30.3/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.30.3)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -26,5 +26,5 @@ not guaranteed.
26
26
 
27
27
  ## License
28
28
 
29
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.30.2/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.30.3/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
package/api/paths/apps.js CHANGED
@@ -121,11 +121,11 @@ export const pathItems = {
121
121
  in: 'query',
122
122
  },
123
123
  ],
124
- description: 'Get all existing apps.',
124
+ description: 'Get all publically available apps.',
125
125
  operationId: 'queryApps',
126
126
  responses: {
127
127
  200: {
128
- description: 'The list of all apps.',
128
+ description: 'The list of all public apps.',
129
129
  content: {
130
130
  'application/json': {
131
131
  schema: {
@@ -9,11 +9,11 @@ export const pathItems = {
9
9
  in: 'query',
10
10
  },
11
11
  ],
12
- description: 'Get all apps that are editable by the user.',
12
+ description: 'Get all apps from organizations that the user is in.',
13
13
  operationId: 'queryCurrentUserApps',
14
14
  responses: {
15
15
  200: {
16
- description: 'The list of all editable apps.',
16
+ description: 'The list of all apps the user is in.',
17
17
  content: {
18
18
  'application/json': {
19
19
  schema: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/utils",
3
- "version": "0.30.2",
3
+ "version": "0.30.3",
4
4
  "description": "Utility functions used in Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -37,7 +37,7 @@
37
37
  "test": "vitest"
38
38
  },
39
39
  "dependencies": {
40
- "@appsemble/types": "0.30.2",
40
+ "@appsemble/types": "0.30.3",
41
41
  "axios": "^1.0.0",
42
42
  "cron-parser": "^4.0.0",
43
43
  "date-fns": "^2.0.0",
package/remap.js CHANGED
@@ -319,7 +319,10 @@ const mapperImplementations = {
319
319
  }
320
320
  }
321
321
  else if (typeof prop === 'number' || typeof prop === 'string') {
322
- result = result[prop];
322
+ result =
323
+ Array.isArray(result) && typeof prop === 'number' && prop < 0
324
+ ? result[result.length + prop]
325
+ : result[prop];
323
326
  }
324
327
  return result;
325
328
  },
package/remap.test.js CHANGED
@@ -1089,6 +1089,16 @@ describe('prop', () => {
1089
1089
  mappers: { prop: 'foo' },
1090
1090
  expected: null,
1091
1091
  },
1092
+ 'handle array input': {
1093
+ input: ['one', 'two', 'three', 'four'],
1094
+ mappers: { prop: 1 },
1095
+ expected: 'two',
1096
+ },
1097
+ 'handle array input and negative index': {
1098
+ input: ['one', 'two', 'three', 'four'],
1099
+ mappers: { prop: -3 },
1100
+ expected: 'two',
1101
+ },
1092
1102
  });
1093
1103
  });
1094
1104
  describe('random.choice', () => {
package/validation.js CHANGED
@@ -1150,6 +1150,7 @@ export async function validateAppDefinition(definition, getBlockVersions, contro
1150
1150
  result = validator.validate(definition, {});
1151
1151
  }
1152
1152
  if (!definition) {
1153
+ result.addError('App definition can not be null');
1153
1154
  return result;
1154
1155
  }
1155
1156
  const blocks = getAppBlocks(definition);
@@ -2001,20 +2001,26 @@ describe('validateAppDefinition', () => {
2001
2001
  new ValidationError('there is no-one in the app, who has permissions to use this action', 'resource.get', undefined, ['controller', 'actions', 'onWhatever', 'resource']),
2002
2002
  ]);
2003
2003
  });
2004
- it('should ignore if an app is null', async () => {
2004
+ it('should throw if an app is null', async () => {
2005
2005
  const result = await validateAppDefinition(null, () => []);
2006
- expect(result.valid).toBe(true);
2007
- expect(result.errors).toStrictEqual([]);
2008
- });
2009
- it('should if app pages are not an array', async () => {
2010
- const result = await validateAppDefinition(null, () => []);
2011
- expect(result.valid).toBe(true);
2012
- expect(result.errors).toStrictEqual([]);
2006
+ expect(result.valid).toBe(false);
2007
+ expect(result.errors).toStrictEqual([
2008
+ expect.objectContaining({
2009
+ message: 'App definition can not be null',
2010
+ instance: null,
2011
+ schema: {},
2012
+ }),
2013
+ ]);
2013
2014
  });
2014
- it('should report an error if app validation fails for an unexpected reason', async () => {
2015
- const result = await validateAppDefinition(null, () => []);
2016
- expect(result.valid).toBe(true);
2017
- expect(result.errors).toStrictEqual([]);
2015
+ it('should report an error if the defaultPage does not exist', async () => {
2016
+ const result = await validateAppDefinition({ name: 'Test App', pages: [], defaultPage: 'Test Page' }, () => []);
2017
+ expect(result.valid).toBe(false);
2018
+ expect(result.errors).toStrictEqual([
2019
+ expect.objectContaining({
2020
+ instance: 'Test Page',
2021
+ message: 'does not refer to an existing page',
2022
+ }),
2023
+ ]);
2018
2024
  });
2019
2025
  it('should handle if an unexpected error occurs', async () => {
2020
2026
  const result = await validateAppDefinition({