@appsemble/lang-sdk 0.36.10-test.3 → 0.36.10
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/schemas/actions/ResourceCountActionDefinition.js +4 -0
- package/schemas/actions/ResourceCreateActionDefinition.js +4 -0
- package/schemas/actions/ResourceDeleteActionDefinition.js +4 -0
- package/schemas/actions/ResourceDeleteAllActionDefinition.js +4 -0
- package/schemas/actions/ResourceDeleteBulkActionDefinition.js +4 -0
- package/schemas/actions/ResourceGetActionDefinition.js +4 -0
- package/schemas/actions/ResourceHistoryGetActionDefinition.js +4 -0
- package/schemas/actions/ResourcePatchActionDefinition.js +4 -0
- package/schemas/actions/ResourceQueryActionDefinition.js +4 -0
- package/schemas/actions/ResourceUpdateActionDefinition.js +4 -0
- package/schemas/actions/ResourceUpdateGroupActionDefinition.js +4 -0
- package/schemas/actions/ResourceUpdatePositionsActionDefinition.js +9 -0
- package/types/actionDefinition.d.ts +24 -5
- 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
|
});
|
|
@@ -13,6 +13,10 @@ export const ResourceCountActionDefinition = extendJSONSchema(RequestActionDefin
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to count.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
own: {
|
|
17
21
|
type: 'boolean',
|
|
18
22
|
description: 'If only the resources created by the authenticated app member should be included',
|
|
@@ -13,6 +13,10 @@ export const ResourceCreateActionDefinition = extendJSONSchema(RequestActionDefi
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to create.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
},
|
|
17
21
|
}, ['url', 'method']);
|
|
18
22
|
//# sourceMappingURL=ResourceCreateActionDefinition.js.map
|
|
@@ -13,6 +13,10 @@ export const ResourceDeleteActionDefinition = extendJSONSchema(RequestActionDefi
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to delete.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
},
|
|
17
21
|
}, ['url', 'method']);
|
|
18
22
|
//# sourceMappingURL=ResourceDeleteActionDefinition.js.map
|
|
@@ -16,6 +16,10 @@ export const ResourceDeleteAllActionDefinition = extendJSONSchema(RequestActionD
|
|
|
16
16
|
type: 'string',
|
|
17
17
|
description: 'The type of the resource to delete.',
|
|
18
18
|
},
|
|
19
|
+
selectedGroupId: {
|
|
20
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
21
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
22
|
+
},
|
|
19
23
|
},
|
|
20
24
|
}, ['url', 'method']);
|
|
21
25
|
//# sourceMappingURL=ResourceDeleteAllActionDefinition.js.map
|
|
@@ -13,6 +13,10 @@ export const ResourceDeleteBulkActionDefinition = extendJSONSchema(RequestAction
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to delete.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
},
|
|
17
21
|
}, ['url', 'method']);
|
|
18
22
|
//# sourceMappingURL=ResourceDeleteBulkActionDefinition.js.map
|
|
@@ -13,6 +13,10 @@ export const ResourceGetActionDefinition = extendJSONSchema(RequestActionDefinit
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to get.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
view: {
|
|
17
21
|
type: 'string',
|
|
18
22
|
description: 'The view to use for the resource.',
|
|
@@ -13,6 +13,10 @@ export const ResourceHistoryGetActionDefinition = extendJSONSchema(RequestAction
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to get.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
},
|
|
17
21
|
}, ['url']);
|
|
18
22
|
//# sourceMappingURL=ResourceHistoryGetActionDefinition.js.map
|
|
@@ -13,6 +13,10 @@ export const ResourcePatchActionDefinition = extendJSONSchema(RequestActionDefin
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to patch.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
id: {
|
|
17
21
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
22
|
},
|
|
@@ -13,6 +13,10 @@ export const ResourceQueryActionDefinition = extendJSONSchema(RequestActionDefin
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to query.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
view: {
|
|
17
21
|
type: 'string',
|
|
18
22
|
description: 'The view to use for the resource.',
|
|
@@ -13,6 +13,10 @@ export const ResourceUpdateActionDefinition = extendJSONSchema(RequestActionDefi
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to update.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
},
|
|
17
21
|
}, ['url', 'method']);
|
|
18
22
|
//# sourceMappingURL=ResourceUpdateActionDefinition.js.map
|
|
@@ -13,6 +13,10 @@ export const ResourceUpdateGroupActionDefinition = extendJSONSchema(RequestActio
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to move.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
id: {
|
|
17
21
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
22
|
description: 'The ID of the resource to move.',
|
|
@@ -13,9 +13,18 @@ export const ResourceUpdatePositionsActionDefinition = extendJSONSchema(RequestA
|
|
|
13
13
|
type: 'string',
|
|
14
14
|
description: 'The type of the resource to update.',
|
|
15
15
|
},
|
|
16
|
+
selectedGroupId: {
|
|
17
|
+
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
|
+
description: 'The ID of the group to scope the request to. Defaults to the currently selected group.',
|
|
19
|
+
},
|
|
16
20
|
id: {
|
|
17
21
|
$ref: '#/components/schemas/RemapperDefinition',
|
|
18
22
|
},
|
|
23
|
+
order: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
enum: ['asc', 'desc'],
|
|
26
|
+
default: 'asc',
|
|
27
|
+
},
|
|
19
28
|
},
|
|
20
29
|
}, ['url', 'method']);
|
|
21
30
|
//# sourceMappingURL=ResourceUpdatePositionsActionDefinition.js.map
|
|
@@ -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
|
/**
|
|
@@ -526,6 +532,13 @@ export interface ResourceActionDefinition<T extends ActionName> extends RequestL
|
|
|
526
532
|
* The name of the resource.
|
|
527
533
|
*/
|
|
528
534
|
resource: string;
|
|
535
|
+
/**
|
|
536
|
+
* The ID of the group to scope the request to.
|
|
537
|
+
*
|
|
538
|
+
* Defaults to the `selectedGroupId` input property, or the app member's currently selected
|
|
539
|
+
* group when the property is not present.
|
|
540
|
+
*/
|
|
541
|
+
selectedGroupId?: Remapper;
|
|
529
542
|
}
|
|
530
543
|
interface ViewResourceDefinition {
|
|
531
544
|
/**
|
|
@@ -545,6 +558,12 @@ interface ResourceActionWithIdDefinition {
|
|
|
545
558
|
*/
|
|
546
559
|
id?: Remapper;
|
|
547
560
|
}
|
|
561
|
+
interface ResourceOrderQueryDefinition {
|
|
562
|
+
/**
|
|
563
|
+
* Whether the resources loaded are in descending order.
|
|
564
|
+
*/
|
|
565
|
+
order?: 'asc' | 'desc';
|
|
566
|
+
}
|
|
548
567
|
export interface ControllerActionDefinition extends BaseActionDefinition<'controller'> {
|
|
549
568
|
handler: string;
|
|
550
569
|
}
|
|
@@ -561,7 +580,7 @@ export type ResourceUpdateActionDefinition = ResourceActionDefinition<'resource.
|
|
|
561
580
|
export type ResourceUpdateGroupActionDefinition = ResourceActionDefinition<'resource.update.group'> & ResourceActionWithIdDefinition & {
|
|
562
581
|
groupId?: Remapper;
|
|
563
582
|
};
|
|
564
|
-
export type ResourceUpdatePositionsActionDefinition = ResourceActionDefinition<'resource.update.positions'> & ResourceActionWithIdDefinition;
|
|
583
|
+
export type ResourceUpdatePositionsActionDefinition = ResourceActionDefinition<'resource.update.positions'> & ResourceActionWithIdDefinition & ResourceOrderQueryDefinition;
|
|
565
584
|
export type ResourcePatchActionDefinition = ResourceActionDefinition<'resource.patch'> & ResourceActionWithIdDefinition;
|
|
566
585
|
export type AppMemberLogoutAction = BaseActionDefinition<'app.member.logout'>;
|
|
567
586
|
export interface BaseResourceSubscribeActionDefinition<T extends ActionName> extends BaseActionDefinition<T> {
|
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;
|