@appsemble/utils 0.20.30 → 0.20.32
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 +4 -4
- package/api/components/schemas/ObjectRemapperDefinition.js +4 -0
- package/api/components/schemas/SSLSecret.js +2 -2
- package/package.json +4 -4
- package/remap.d.ts +4 -1
- package/remap.js +8 -0
- package/remap.test.js +19 -0
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#  Appsemble Utilities
|
|
2
2
|
|
|
3
3
|
> Internal utility functions used across multiple Appsemble projects.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.20.32)
|
|
7
|
+
[](https://codecov.io/gl/appsemble/appsemble)
|
|
8
8
|
[](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.
|
|
24
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.20.32/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
|
|
8
|
+
description: 'The public SSL certificate chain in PEM format.',
|
|
9
9
|
},
|
|
10
10
|
key: {
|
|
11
11
|
type: 'string',
|
|
12
|
-
description: 'The
|
|
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.
|
|
3
|
+
"version": "0.20.32",
|
|
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.
|
|
35
|
-
"axios": "^0.
|
|
34
|
+
"@appsemble/types": "0.20.32",
|
|
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",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"openapi-types": "^12.0.0",
|
|
46
46
|
"parse-duration": "^1.0.0",
|
|
47
47
|
"postcss": "^8.0.0",
|
|
48
|
-
"type-fest": "^
|
|
48
|
+
"type-fest": "^3.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/langmap": "^0.0.1",
|
package/remap.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ export interface RemapperContext {
|
|
|
28
28
|
* @see MessageGetter
|
|
29
29
|
*/
|
|
30
30
|
getMessage: MessageGetter;
|
|
31
|
+
/**
|
|
32
|
+
* The history stack containing the states before an action was called.
|
|
33
|
+
*/
|
|
34
|
+
history?: unknown[];
|
|
31
35
|
/**
|
|
32
36
|
* The current locale of the app.
|
|
33
37
|
*/
|
|
@@ -47,7 +51,6 @@ export interface RemapperContext {
|
|
|
47
51
|
}
|
|
48
52
|
interface InternalContext extends RemapperContext {
|
|
49
53
|
root?: unknown;
|
|
50
|
-
history?: unknown[];
|
|
51
54
|
array?: {
|
|
52
55
|
index: number;
|
|
53
56
|
length: number;
|
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': {
|