@appsemble/lang-sdk 0.36.10-test.2 → 0.36.10-test.4
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/authorization.d.ts +1 -1
- package/authorization.js +8 -2
- package/examples.js +1 -1
- package/package.json +1 -1
- package/reference-schemas/remappers/data.js +3 -1
- package/remap.js +1 -1
- package/schemas/actions/AppMemberInviteActionDefinition.js +4 -4
- package/schemas/actions/AppMemberRoleUpdateActionDefinition.js +8 -3
- package/types/actionDefinition.d.ts +10 -4
- package/types/member.d.ts +7 -1
- package/types/remapper.d.ts +3 -2
package/authorization.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare function getAppRoles(appSecurityDefinition?: Security): AppRole[]
|
|
|
7
7
|
export declare function getAppPossibleGuestPermissions(appDefinition: AppDefinition): CustomAppGuestPermission[];
|
|
8
8
|
export declare function getAppPossiblePermissions(appDefinition: AppDefinition): CustomAppPermission[];
|
|
9
9
|
export declare function getAppRolesByPermissions(appSecurityDefinition: Security, requiredPermissions: CustomAppPermission[]): (AppRole | 'Guest')[];
|
|
10
|
-
export declare function checkAppRoleAppPermissions(appSecurityDefinition: Security,
|
|
10
|
+
export declare function checkAppRoleAppPermissions(appSecurityDefinition: Security, appRoles: AppRole | AppRole[] | null | undefined, requiredPermissions: CustomAppPermission[]): boolean;
|
package/authorization.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { AppPermission, predefinedAppRolePermissions, } from './types/index.js';
|
|
2
|
+
function normalizeAppRoles(appRoles) {
|
|
3
|
+
if (!appRoles) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
return Array.isArray(appRoles) ? appRoles : [appRoles];
|
|
7
|
+
}
|
|
2
8
|
function checkAppPermissions(acquiredPermissions, requiredPermissions) {
|
|
3
9
|
const customAppResourcePermissionPattern = /^\$resource:[^:]+:(get|history:get|query|create|delete|patch|update)$/;
|
|
4
10
|
const customAppOwnResourcePermissionPattern = /^\$resource:[^:]+:own:(get|query|delete|patch|update)$/;
|
|
@@ -150,8 +156,8 @@ export function getAppRolesByPermissions(appSecurityDefinition, requiredPermissi
|
|
|
150
156
|
}
|
|
151
157
|
return compliantRoles;
|
|
152
158
|
}
|
|
153
|
-
export function checkAppRoleAppPermissions(appSecurityDefinition,
|
|
154
|
-
const appRolePermissions = getAppRolePermissions(appSecurityDefinition,
|
|
159
|
+
export function checkAppRoleAppPermissions(appSecurityDefinition, appRoles, requiredPermissions) {
|
|
160
|
+
const appRolePermissions = getAppRolePermissions(appSecurityDefinition, normalizeAppRoles(appRoles));
|
|
155
161
|
return checkAppPermissions(appRolePermissions, requiredPermissions);
|
|
156
162
|
}
|
|
157
163
|
//# sourceMappingURL=authorization.js.map
|
package/examples.js
CHANGED
|
@@ -1241,7 +1241,7 @@ export function createExampleContext(url, lang, userInfo, history) {
|
|
|
1241
1241
|
email_verified: true,
|
|
1242
1242
|
name: 'default-example-name',
|
|
1243
1243
|
demo: false,
|
|
1244
|
-
|
|
1244
|
+
roles: ['Member'],
|
|
1245
1245
|
zoneinfo: 'Europe/Amsterdam',
|
|
1246
1246
|
properties: {
|
|
1247
1247
|
completedExamples: [],
|
package/package.json
CHANGED
|
@@ -337,6 +337,7 @@ parameters:
|
|
|
337
337
|
'locale',
|
|
338
338
|
'zoneinfo',
|
|
339
339
|
'role',
|
|
340
|
+
'roles',
|
|
340
341
|
'properties',
|
|
341
342
|
'phoneNumber',
|
|
342
343
|
'demo',
|
|
@@ -355,7 +356,8 @@ Provides some fields of app member information taken from the OpenID user info.
|
|
|
355
356
|
- \`locale\`: The app member’s default language [\`BCP47\`](https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
356
357
|
language tag (ex. \`en\`) (Broken)
|
|
357
358
|
- \`zoneinfo\`: The app member’s timezone
|
|
358
|
-
- \`role\`: The
|
|
359
|
+
- \`role\`: The app member’s first direct role in the app
|
|
360
|
+
- \`roles\`: The direct roles of the app member in the app (\`string[]\`)
|
|
359
361
|
- \`properties\`: Custom properties defined on the app member
|
|
360
362
|
- \`phoneNumber\`: Phone number of the app member if enabled in app definition.
|
|
361
363
|
- \`demo\`: Whether the app member is used for demo purposes.
|
package/remap.js
CHANGED
|
@@ -844,7 +844,7 @@ const mapperImplementations = {
|
|
|
844
844
|
return message.format() || `{${remappedId}}`;
|
|
845
845
|
},
|
|
846
846
|
group: (property, input, context) => context.group?.[property],
|
|
847
|
-
'app.member': (property, input, context) => context.appMemberInfo?.[property],
|
|
847
|
+
'app.member': (property, input, context) => property === 'role' ? context.appMemberInfo?.roles?.[0] : context.appMemberInfo?.[property],
|
|
848
848
|
container(property, input, context) {
|
|
849
849
|
// This value is replaced when the request is made
|
|
850
850
|
// By using the value of the release name
|
|
@@ -3,11 +3,11 @@ import { extendJSONSchema } from '../utils/extendJSONSchema.js';
|
|
|
3
3
|
export const AppMemberInviteActionDefinition = extendJSONSchema(BaseActionDefinition, {
|
|
4
4
|
type: 'object',
|
|
5
5
|
additionalProperties: false,
|
|
6
|
-
required: ['type', 'email', '
|
|
6
|
+
required: ['type', 'email', 'roles'],
|
|
7
7
|
properties: {
|
|
8
8
|
type: {
|
|
9
9
|
enum: ['app.member.invite'],
|
|
10
|
-
description: `Allows the app member to invite another app member using an email address and
|
|
10
|
+
description: `Allows the app member to invite another app member using an email address and one or more roles.
|
|
11
11
|
|
|
12
12
|
Does nothing if the app member is not logged in.`,
|
|
13
13
|
},
|
|
@@ -15,9 +15,9 @@ Does nothing if the app member is not logged in.`,
|
|
|
15
15
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
16
16
|
description: 'The email to invite.',
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
roles: {
|
|
19
19
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
20
|
-
description: 'The
|
|
20
|
+
description: 'The roles of the invited app member.',
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
});
|
|
@@ -7,7 +7,7 @@ export const AppMemberRoleUpdateActionDefinition = extendJSONSchema(BaseActionDe
|
|
|
7
7
|
properties: {
|
|
8
8
|
type: {
|
|
9
9
|
enum: ['app.member.role.update'],
|
|
10
|
-
description: `Allows the app member to update the
|
|
10
|
+
description: `Allows the app member to update the roles of another app member account.
|
|
11
11
|
|
|
12
12
|
Does nothing if the app member isn’t logged in.`,
|
|
13
13
|
},
|
|
@@ -15,12 +15,17 @@ Does nothing if the app member isn’t logged in.`,
|
|
|
15
15
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
16
16
|
description: 'The id of the app member.',
|
|
17
17
|
},
|
|
18
|
+
roles: {
|
|
19
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
20
|
+
description: `The updated roles of the app member.
|
|
21
|
+
|
|
22
|
+
Every role must exist in the roles property of the app's security definition.`,
|
|
23
|
+
},
|
|
18
24
|
role: {
|
|
19
25
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
20
26
|
description: `The updated role of the app member.
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
\`Member\`, \`MembersManager\`, \`GroupMembersManager\`, \`GroupsManager\`, \`ResourcesManager\` and \`Owner\``,
|
|
28
|
+
Deprecated: use roles instead.`,
|
|
24
29
|
},
|
|
25
30
|
},
|
|
26
31
|
});
|
|
@@ -419,9 +419,9 @@ export interface AppMemberInviteAction extends BaseActionDefinition<'app.member.
|
|
|
419
419
|
*/
|
|
420
420
|
email: Remapper;
|
|
421
421
|
/**
|
|
422
|
-
* The
|
|
422
|
+
* The roles to invite the app member with.
|
|
423
423
|
*/
|
|
424
|
-
|
|
424
|
+
roles: Remapper;
|
|
425
425
|
}
|
|
426
426
|
export interface AppMemberQueryAction extends BaseActionDefinition<'app.member.query'> {
|
|
427
427
|
/**
|
|
@@ -440,9 +440,15 @@ export interface AppMemberRoleUpdateAction extends BaseActionDefinition<'app.mem
|
|
|
440
440
|
*/
|
|
441
441
|
sub: Remapper;
|
|
442
442
|
/**
|
|
443
|
-
* The
|
|
443
|
+
* The roles of the updated app member.
|
|
444
444
|
*/
|
|
445
|
-
|
|
445
|
+
roles?: Remapper;
|
|
446
|
+
/**
|
|
447
|
+
* The role of the updated app member.
|
|
448
|
+
*
|
|
449
|
+
* @deprecated Use `roles` instead.
|
|
450
|
+
*/
|
|
451
|
+
role?: Remapper;
|
|
446
452
|
}
|
|
447
453
|
export interface AppMemberPropertiesPatchAction extends BaseActionDefinition<'app.member.properties.patch'> {
|
|
448
454
|
/**
|
package/types/member.d.ts
CHANGED
|
@@ -48,8 +48,14 @@ export interface AppMemberInfo {
|
|
|
48
48
|
zoneinfo?: string;
|
|
49
49
|
/**
|
|
50
50
|
* The role of the app member.
|
|
51
|
+
*
|
|
52
|
+
* @deprecated Use roles instead.
|
|
51
53
|
*/
|
|
52
|
-
role
|
|
54
|
+
role?: AppRole;
|
|
55
|
+
/**
|
|
56
|
+
* The direct roles of the app member.
|
|
57
|
+
*/
|
|
58
|
+
roles: AppRole[];
|
|
53
59
|
/**
|
|
54
60
|
* The end-user's additional properties
|
|
55
61
|
*/
|
package/types/remapper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RequireExactlyOne } from 'type-fest';
|
|
2
|
-
type AppMemberInfoKey = 'demo' | 'email_verified' | 'email' | 'locale' | 'name' | 'phoneNumber' | 'picture' | 'properties' | 'role' | 'sub' | 'zoneinfo';
|
|
2
|
+
type AppMemberInfoKey = 'demo' | 'email_verified' | 'email' | 'locale' | 'name' | 'phoneNumber' | 'picture' | 'properties' | 'role' | 'roles' | 'sub' | 'zoneinfo';
|
|
3
3
|
interface BaseICSRemapper {
|
|
4
4
|
/**
|
|
5
5
|
* The start of the icalendar event.
|
|
@@ -91,7 +91,8 @@ export interface Remappers {
|
|
|
91
91
|
* - `picture`: Get the picture of the app member.
|
|
92
92
|
* - `locale`: Get the locale of the app member.
|
|
93
93
|
* - `zoneinfo`: Get the zoneinfo of the app member.
|
|
94
|
-
* - `role`: Get the role of the app member.
|
|
94
|
+
* - `role`: Get the first direct role of the app member.
|
|
95
|
+
* - `roles`: Get the direct roles of the app member.
|
|
95
96
|
* - `properties`: Get the custom properties of the app member.
|
|
96
97
|
*/
|
|
97
98
|
'app.member': AppMemberInfoKey;
|