@appsemble/utils 0.20.29 → 0.20.31

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,10 +1,10 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.20.29/config/assets/logo.svg) Appsemble Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.20.31/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.20.29/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.20.29)
7
- [![Code coverage](https://codecov.io/gl/appsemble/appsemble/branch/0.20.29/graph/badge.svg)](https://codecov.io/gl/appsemble/appsemble)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.20.31/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.20.31)
7
+ [![Code coverage](https://codecov.io/gl/appsemble/appsemble/branch/0.20.31/graph/badge.svg)](https://codecov.io/gl/appsemble/appsemble)
8
8
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
9
9
 
10
10
  ## Installation
@@ -21,5 +21,5 @@ not guaranteed.
21
21
 
22
22
  ## License
23
23
 
24
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.20.29/LICENSE.md) ©
24
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.20.31/LICENSE.md) ©
25
25
  [Appsemble](https://appsemble.com)
@@ -81,6 +81,10 @@ If the input is not an array an empty array is returned.`,
81
81
  type: 'string',
82
82
  description: 'Add the specified value to a given date.',
83
83
  },
84
+ 'date.format': {
85
+ enum: [null],
86
+ description: 'Format a date according to rfc3339.',
87
+ },
84
88
  'date.now': {
85
89
  enum: [null],
86
90
  description: 'Returns the current date.',
@@ -5,11 +5,11 @@ export const SSLSecret = {
5
5
  properties: {
6
6
  certificate: {
7
7
  type: 'string',
8
- description: 'The fully resolved SSL certificate in PEM format.',
8
+ description: 'The public SSL certificate chain in PEM format.',
9
9
  },
10
10
  key: {
11
11
  type: 'string',
12
- description: 'The fully SSL key in PEM format.',
12
+ description: 'The SSL private key in PEM format.',
13
13
  },
14
14
  },
15
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/utils",
3
- "version": "0.20.29",
3
+ "version": "0.20.31",
4
4
  "description": "Utility functions used in Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -31,8 +31,8 @@
31
31
  "test": "NODE_OPTIONS=--experimental-vm-modules jest"
32
32
  },
33
33
  "dependencies": {
34
- "@appsemble/types": "0.20.29",
35
- "axios": "^0.27.0",
34
+ "@appsemble/types": "0.20.31",
35
+ "axios": "^1.0.0",
36
36
  "cron-parser": "^4.0.0",
37
37
  "date-fns": "^2.0.0",
38
38
  "fast-deep-equal": "^3.0.0",
package/remap.js CHANGED
@@ -228,6 +228,14 @@ const mapperImplementations = {
228
228
  }
229
229
  return addMilliseconds(input, expireDuration);
230
230
  },
231
+ 'date.format'(args, input) {
232
+ const date = input instanceof Date
233
+ ? input
234
+ : typeof input === 'number'
235
+ ? new Date(input)
236
+ : parseISO(String(input));
237
+ return date.toJSON();
238
+ },
231
239
  'null.strip': (args, input) => stripNullValues(input, args || {}),
232
240
  'random.choice': (args, input) => Array.isArray(input) ? input[Math.floor(Math.random() * input.length)] : input,
233
241
  'random.integer'(args) {
package/remap.test.js CHANGED
@@ -157,6 +157,25 @@ describe('date.add', () => {
157
157
  },
158
158
  });
159
159
  });
160
+ describe('date.format', () => {
161
+ runTests({
162
+ 'format date objects': {
163
+ input: new Date('2020-01-02T03:04:05Z'),
164
+ mappers: { 'date.format': null },
165
+ expected: '2020-01-02T03:04:05.000Z',
166
+ },
167
+ 'format date strings': {
168
+ input: '2020-01-02T03:04:05Z',
169
+ mappers: { 'date.format': null },
170
+ expected: '2020-01-02T03:04:05.000Z',
171
+ },
172
+ 'format unix timestamps': {
173
+ input: 0,
174
+ mappers: { 'date.format': null },
175
+ expected: '1970-01-01T00:00:00.000Z',
176
+ },
177
+ });
178
+ });
160
179
  describe('le', () => {
161
180
  runTests({
162
181
  'return true if the left value is less than the right value': {