@appsemble/lang-sdk 0.35.20 → 0.36.1
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/examples.js +13 -0
- package/jsonschema.js +4 -4
- package/package.json +2 -2
- package/reference-schemas/remappers/data.js +14 -0
- package/remap.d.ts +5 -1
- package/remap.js +17 -16
- package/schemas/AppLayoutDefinition.js +1 -1
- package/types/core.d.ts +1 -1
- package/types/member.d.ts +18 -0
- package/types/remapper.d.ts +9 -0
- package/validation.js +3 -3
package/examples.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IntlMessageFormat } from 'intl-messageformat';
|
|
2
2
|
import { stringify } from 'yaml';
|
|
3
|
+
import { PredefinedAppRole } from './types/index.js';
|
|
3
4
|
export const examples = {
|
|
4
5
|
None: {
|
|
5
6
|
input: null,
|
|
@@ -33,6 +34,13 @@ export const examples = {
|
|
|
33
34
|
result: {},
|
|
34
35
|
skip: true,
|
|
35
36
|
},
|
|
37
|
+
group: {
|
|
38
|
+
input: null,
|
|
39
|
+
remapper: {
|
|
40
|
+
group: 'name',
|
|
41
|
+
},
|
|
42
|
+
result: 'test-group',
|
|
43
|
+
},
|
|
36
44
|
type: {
|
|
37
45
|
input: [1, 2, 3],
|
|
38
46
|
remapper: { type: null },
|
|
@@ -979,6 +987,11 @@ export function createExampleContext(url, lang, userInfo, history) {
|
|
|
979
987
|
$seed: false,
|
|
980
988
|
$ephemeral: false,
|
|
981
989
|
},
|
|
990
|
+
group: {
|
|
991
|
+
id: 0,
|
|
992
|
+
name: 'test-group',
|
|
993
|
+
role: PredefinedAppRole.Member,
|
|
994
|
+
},
|
|
982
995
|
};
|
|
983
996
|
}
|
|
984
997
|
//# sourceMappingURL=examples.js.map
|
package/jsonschema.js
CHANGED
|
@@ -68,28 +68,28 @@ export function combineSchemas(...schemas) {
|
|
|
68
68
|
}
|
|
69
69
|
if ('minimum' in schema) {
|
|
70
70
|
result.minimum =
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
72
72
|
// @ts-ignore 2345 argument of type is not assignable to parameter of type
|
|
73
73
|
// (strictNullChecks)
|
|
74
74
|
'minimum' in result ? Math.max(result.minimum, schema.minimum) : schema.minimum;
|
|
75
75
|
}
|
|
76
76
|
if ('minLength' in schema) {
|
|
77
77
|
result.minLength =
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
79
79
|
// @ts-ignore 2345 argument of type is not assignable to parameter of type
|
|
80
80
|
// (strictNullChecks)
|
|
81
81
|
'minLength' in result ? Math.max(result.minLength, schema.minLength) : schema.minLength;
|
|
82
82
|
}
|
|
83
83
|
if ('maximum' in schema) {
|
|
84
84
|
result.maximum =
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
86
|
// @ts-ignore 2345 argument of type is not assignable to parameter of type
|
|
87
87
|
// (strictNullChecks)
|
|
88
88
|
'maximum' in result ? Math.min(result.maximum, schema.maximum) : schema.maximum;
|
|
89
89
|
}
|
|
90
90
|
if ('maxLength' in schema) {
|
|
91
91
|
result.maxLength =
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
93
93
|
// @ts-ignore 2345 argument of type is not assignable to parameter of type
|
|
94
94
|
// (strictNullChecks)
|
|
95
95
|
'maxLength' in result ? Math.min(result.maxLength, schema.maxLength) : schema.maxLength;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/lang-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "Language SDK for Appsemble",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"date-fns": "^2.0.0",
|
|
45
45
|
"fast-deep-equal": "^3.0.0",
|
|
46
46
|
"ics": "^3.0.0",
|
|
47
|
-
"intl-messageformat": "^
|
|
47
|
+
"intl-messageformat": "^11.0.0",
|
|
48
48
|
"parse-duration": "^1.0.0",
|
|
49
49
|
"fast-xml-parser": "^5.0.8",
|
|
50
50
|
"vitest": "^2.0.0",
|
|
@@ -23,6 +23,20 @@ following information:
|
|
|
23
23
|
Example:
|
|
24
24
|
|
|
25
25
|
${schemaExample('app.url', { result: 'pretty', exclude: ['input'] })}
|
|
26
|
+
`,
|
|
27
|
+
},
|
|
28
|
+
group: {
|
|
29
|
+
enum: ['id', 'name', 'role'],
|
|
30
|
+
description: `Gives information about the currently selected group. Using this remapper you can
|
|
31
|
+
get access to the following information:
|
|
32
|
+
|
|
33
|
+
- \`id\`: ID of the group.
|
|
34
|
+
- \`name\`: Name of the group.
|
|
35
|
+
- \`role\`: Role of the current app member in the group.
|
|
36
|
+
|
|
37
|
+
Example:
|
|
38
|
+
|
|
39
|
+
${schemaExample('group', { result: 'pretty', exclude: ['input'] })}
|
|
26
40
|
`,
|
|
27
41
|
},
|
|
28
42
|
context: {
|
package/remap.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IntlMessageFormat } from 'intl-messageformat';
|
|
2
|
-
import { type AppMemberInfo, type Remapper } from './types/index.js';
|
|
2
|
+
import { type AppMemberGroup, type AppMemberInfo, type Remapper } from './types/index.js';
|
|
3
3
|
export interface IntlMessage {
|
|
4
4
|
id?: string;
|
|
5
5
|
defaultMessage?: string;
|
|
@@ -18,6 +18,10 @@ export interface RemapperContext {
|
|
|
18
18
|
* The id of the app whose context the remapper is run in.
|
|
19
19
|
*/
|
|
20
20
|
appId: number;
|
|
21
|
+
/**
|
|
22
|
+
* The metadata of the group selected by the app member.
|
|
23
|
+
*/
|
|
24
|
+
group: AppMemberGroup | undefined;
|
|
21
25
|
/**
|
|
22
26
|
* The current URL.
|
|
23
27
|
*/
|
package/remap.js
CHANGED
|
@@ -137,21 +137,21 @@ const mapperImplementations = {
|
|
|
137
137
|
return values.every(Boolean);
|
|
138
138
|
},
|
|
139
139
|
step(mapper, input, context) {
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
141
141
|
// @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
|
|
142
142
|
return context.stepRef.current[mapper];
|
|
143
143
|
},
|
|
144
144
|
'tab.name'(mapper, input, context) {
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
146
|
// @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
|
|
147
147
|
return context.tabRef.current.name;
|
|
148
148
|
},
|
|
149
149
|
gt: ([left, right], input, context) =>
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
151
151
|
// @ts-ignore Messed up - 2571 Object is of type 'unknown'.
|
|
152
152
|
remap(left, input, context) > remap(right, input, context),
|
|
153
153
|
lt: ([left, right], input, context) =>
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
155
155
|
// @ts-ignore Messed up - 2571 Object is of type 'unknown'.
|
|
156
156
|
remap(left, input, context) < remap(right, input, context),
|
|
157
157
|
ics(mappers, input, context) {
|
|
@@ -215,7 +215,7 @@ const mapperImplementations = {
|
|
|
215
215
|
...input,
|
|
216
216
|
...mapValues(mappers, (mapper) => remap(mapper, input, context)),
|
|
217
217
|
}),
|
|
218
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
219
219
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
220
220
|
'object.omit'(keys, input) {
|
|
221
221
|
const result = { ...input };
|
|
@@ -297,7 +297,7 @@ const mapperImplementations = {
|
|
|
297
297
|
}
|
|
298
298
|
return typeof input;
|
|
299
299
|
},
|
|
300
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
300
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
301
301
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
302
302
|
'array.map': (mapper, input, context) => input?.map((item, index) => remap(mapper, item, {
|
|
303
303
|
...context,
|
|
@@ -353,10 +353,10 @@ const mapperImplementations = {
|
|
|
353
353
|
return true;
|
|
354
354
|
});
|
|
355
355
|
},
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
356
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
357
357
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
358
358
|
array: (prop, input, context) => context.array?.[prop],
|
|
359
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
359
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
360
360
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
361
361
|
'array.filter'(mapper, input, context) {
|
|
362
362
|
if (!Array.isArray(input)) {
|
|
@@ -377,7 +377,7 @@ const mapperImplementations = {
|
|
|
377
377
|
return remapped;
|
|
378
378
|
});
|
|
379
379
|
},
|
|
380
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
380
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
381
381
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
382
382
|
'array.find'(mapper, input, context) {
|
|
383
383
|
if (!Array.isArray(input)) {
|
|
@@ -475,7 +475,7 @@ const mapperImplementations = {
|
|
|
475
475
|
}
|
|
476
476
|
return remapped;
|
|
477
477
|
},
|
|
478
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
478
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
479
479
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
480
480
|
'date.parse': (fmt, input) => (fmt ? parse(input, fmt, new Date()) : parseISO(input)),
|
|
481
481
|
'date.now': () => new Date(),
|
|
@@ -495,7 +495,7 @@ const mapperImplementations = {
|
|
|
495
495
|
return args ? format(date, args) : date.toJSON();
|
|
496
496
|
},
|
|
497
497
|
'null.strip': (args, input) => stripNullValues(input, args || {}),
|
|
498
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
498
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
499
499
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
500
500
|
'random.choice': (args, input) => Array.isArray(input) ? input[Math.floor(Math.random() * input.length)] : input,
|
|
501
501
|
'random.integer'(args) {
|
|
@@ -517,7 +517,7 @@ const mapperImplementations = {
|
|
|
517
517
|
return result.join('');
|
|
518
518
|
},
|
|
519
519
|
root: (args, input, context) => context.root,
|
|
520
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
520
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
521
521
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
522
522
|
len: (args, input) => input?.length,
|
|
523
523
|
history: (index, input, context) => context.history?.[index],
|
|
@@ -526,7 +526,7 @@ const mapperImplementations = {
|
|
|
526
526
|
...input,
|
|
527
527
|
...mapValues(props, (mapper) => remap(mapper, context.history?.[index], context)),
|
|
528
528
|
}),
|
|
529
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
529
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
530
530
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
531
531
|
'omit.history'({ index, keys }, input, context) {
|
|
532
532
|
const result = { ...context.history?.[index] };
|
|
@@ -563,7 +563,7 @@ const mapperImplementations = {
|
|
|
563
563
|
}
|
|
564
564
|
return input.includes(stringToCheck);
|
|
565
565
|
},
|
|
566
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
566
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
567
567
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
568
568
|
'string.startsWith'(substring, input) {
|
|
569
569
|
if (typeof substring === 'string') {
|
|
@@ -574,7 +574,7 @@ const mapperImplementations = {
|
|
|
574
574
|
}
|
|
575
575
|
return input.toLowerCase().startsWith(substring.substring.toLowerCase());
|
|
576
576
|
},
|
|
577
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
577
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
578
578
|
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
579
579
|
'string.endsWith'(substring, input) {
|
|
580
580
|
if (typeof substring === 'string') {
|
|
@@ -585,7 +585,7 @@ const mapperImplementations = {
|
|
|
585
585
|
}
|
|
586
586
|
return input.toLowerCase().endsWith(substring.substring.toLowerCase());
|
|
587
587
|
},
|
|
588
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
588
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
589
589
|
// @ts-ignore 2322 null is not assignable to type (strictNullChecks)
|
|
590
590
|
slice(sliceIndex, input) {
|
|
591
591
|
try {
|
|
@@ -624,6 +624,7 @@ const mapperImplementations = {
|
|
|
624
624
|
const message = context.getMessage({ id: remappedId });
|
|
625
625
|
return message.format() || `{${remappedId}}`;
|
|
626
626
|
},
|
|
627
|
+
group: (property, input, context) => context.group?.[property],
|
|
627
628
|
'app.member': (property, input, context) => context.appMemberInfo?.[property],
|
|
628
629
|
container(property, input, context) {
|
|
629
630
|
// This value is replaced when the request is made
|
|
@@ -28,7 +28,7 @@ If set to \`navigation\`, it will only be visible if \`login\` is also visible i
|
|
|
28
28
|
enabledSettings: {
|
|
29
29
|
type: 'array',
|
|
30
30
|
items: {
|
|
31
|
-
enum: ['name', 'phoneNumber', 'picture', 'languages'],
|
|
31
|
+
enum: ['email', 'name', 'phoneNumber', 'picture', 'languages', 'password'],
|
|
32
32
|
},
|
|
33
33
|
description: 'A list of the settings to display on the settings page.',
|
|
34
34
|
},
|
package/types/core.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type ResourceDefinition } from './resource.js';
|
|
|
9
9
|
import { type ViewRole } from './roles.js';
|
|
10
10
|
import { type Security } from './security.js';
|
|
11
11
|
import { type Theme } from './theme.js';
|
|
12
|
-
export type SettingName = 'languages' | 'name' | 'phoneNumber' | 'picture';
|
|
12
|
+
export type SettingName = 'email' | 'languages' | 'name' | 'password' | 'phoneNumber' | 'picture';
|
|
13
13
|
export interface AppDefinition {
|
|
14
14
|
/**
|
|
15
15
|
* The name of the app.
|
package/types/member.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { type AppRole } from './roles.js';
|
|
2
|
+
export interface AppMemberGroup {
|
|
3
|
+
/**
|
|
4
|
+
* The ID of the group.
|
|
5
|
+
*/
|
|
6
|
+
id: number;
|
|
7
|
+
/**
|
|
8
|
+
* The display name of the group.
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* The role of the app member inside the group.
|
|
13
|
+
*/
|
|
14
|
+
role: AppRole;
|
|
15
|
+
}
|
|
2
16
|
export interface AppMemberInfo {
|
|
3
17
|
/**
|
|
4
18
|
* The subject (end-user) identifier. This member is always present in a claims set.
|
|
@@ -52,4 +66,8 @@ export interface AppMemberInfo {
|
|
|
52
66
|
* Whether this app member is a copy of a seed app member.
|
|
53
67
|
*/
|
|
54
68
|
$ephemeral: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Unverified email of the user, this will replace the current email when verified.
|
|
71
|
+
*/
|
|
72
|
+
unverifiedEmail?: string;
|
|
55
73
|
}
|
package/types/remapper.d.ts
CHANGED
|
@@ -70,6 +70,15 @@ export interface Remappers {
|
|
|
70
70
|
* - `url`: Get the base URL of the app.
|
|
71
71
|
*/
|
|
72
72
|
app: 'id' | 'locale' | 'url';
|
|
73
|
+
/**
|
|
74
|
+
* Get group metadata.
|
|
75
|
+
* Supported properties:
|
|
76
|
+
*
|
|
77
|
+
* - `id`: Get the id of the selected group.
|
|
78
|
+
* - `role`: Role of the current app member in the group.
|
|
79
|
+
* - `name`: Get the name of the selected group.
|
|
80
|
+
*/
|
|
81
|
+
group: 'id' | 'name' | 'role';
|
|
73
82
|
/**
|
|
74
83
|
* Get property of the AppMember object.
|
|
75
84
|
*
|
package/validation.js
CHANGED
|
@@ -22,7 +22,7 @@ const resourceViewPermissionPattern = /^\$resource:[^:]+:(get|query):[^:]+$/;
|
|
|
22
22
|
* @returns Whether or not the given link represents a link related to the Appsemble core.
|
|
23
23
|
*/
|
|
24
24
|
export function isAppLink(link) {
|
|
25
|
-
return link === '/Login' || link === '/Settings';
|
|
25
|
+
return (link === '/Login' || link === '/Settings' || link === '/Register' || link === '/Reset-Password');
|
|
26
26
|
}
|
|
27
27
|
function validateJSONSchema(schema, prefix, report) {
|
|
28
28
|
if (schema.type !== 'object') {
|
|
@@ -738,7 +738,7 @@ function validateSecurity(definition, report) {
|
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
else {
|
|
741
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
741
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
742
742
|
// @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
|
|
743
743
|
checkRoleExists(security.default.role, ['security', 'default', 'role']);
|
|
744
744
|
}
|
|
@@ -1154,7 +1154,7 @@ function validateEvents(definition, blockVersions, report) {
|
|
|
1154
1154
|
listeners: new Map(),
|
|
1155
1155
|
};
|
|
1156
1156
|
if (indexMap.has('controller')) {
|
|
1157
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
1157
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1158
1158
|
// @ts-ignore 2322 null is not assignable to type (strictNullChecks)
|
|
1159
1159
|
controllerEvents = { ...indexMap.get('controller') };
|
|
1160
1160
|
}
|