@nu-art/permissions-shared 0.401.9 → 0.500.0
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/_entity/permission-access-level/db-def.d.ts +5 -3
- package/_entity/permission-access-level/db-def.js +7 -1
- package/_entity/permission-access-level/types.d.ts +14 -11
- package/_entity/permission-access-level/types.js +1 -1
- package/_entity/permission-api/db-def.d.ts +3 -3
- package/_entity/permission-api/db-def.js +5 -2
- package/_entity/permission-api/types.d.ts +19 -14
- package/_entity/permission-api/types.js +1 -1
- package/_entity/permission-domain/db-def.d.ts +5 -3
- package/_entity/permission-domain/db-def.js +6 -1
- package/_entity/permission-domain/types.d.ts +13 -10
- package/_entity/permission-domain/types.js +1 -1
- package/_entity/permission-group/db-def.d.ts +5 -3
- package/_entity/permission-group/db-def.js +9 -3
- package/_entity/permission-group/types.d.ts +20 -16
- package/_entity/permission-group/types.js +1 -1
- package/_entity/permission-project/db-def.d.ts +5 -3
- package/_entity/permission-project/db-def.js +6 -1
- package/_entity/permission-project/types.d.ts +9 -6
- package/_entity/permission-project/types.js +1 -1
- package/_entity/permission-user/api-def.d.ts +10 -9
- package/_entity/permission-user/api-def.js +2 -4
- package/_entity/permission-user/db-def.d.ts +3 -3
- package/_entity/permission-user/db-def.js +6 -3
- package/_entity/permission-user/types.d.ts +14 -11
- package/_entity/permission-user/types.js +1 -1
- package/_entity.d.ts +13 -6
- package/_entity.js +13 -6
- package/apis.d.ts +19 -28
- package/apis.js +4 -19
- package/consts.d.ts +3 -2
- package/consts.js +7 -1
- package/index.d.ts +17 -6
- package/index.js +17 -6
- package/package.json +9 -8
- package/path-utils.d.ts +2 -0
- package/path-utils.js +7 -0
- package/permission-keys.d.ts +0 -1
- package/permission-keys.js +0 -1
- package/permission-scope.d.ts +20 -0
- package/permission-scope.js +25 -0
- package/project-setup.d.ts +10 -0
- package/project-setup.js +6 -0
- package/service-account-def.d.ts +11 -0
- package/service-account-def.js +6 -0
- package/types.d.ts +9 -6
- package/_entity/permission-access-level/api-def.d.ts +0 -5
- package/_entity/permission-access-level/api-def.js +0 -3
- package/_entity/permission-access-level/index.d.ts +0 -3
- package/_entity/permission-access-level/index.js +0 -4
- package/_entity/permission-api/api-def.d.ts +0 -5
- package/_entity/permission-api/api-def.js +0 -3
- package/_entity/permission-api/index.d.ts +0 -3
- package/_entity/permission-api/index.js +0 -4
- package/_entity/permission-domain/api-def.d.ts +0 -5
- package/_entity/permission-domain/api-def.js +0 -3
- package/_entity/permission-domain/index.d.ts +0 -3
- package/_entity/permission-domain/index.js +0 -4
- package/_entity/permission-group/api-def.d.ts +0 -5
- package/_entity/permission-group/api-def.js +0 -3
- package/_entity/permission-group/index.d.ts +0 -3
- package/_entity/permission-group/index.js +0 -4
- package/_entity/permission-project/api-def.d.ts +0 -5
- package/_entity/permission-project/api-def.js +0 -3
- package/_entity/permission-project/index.d.ts +0 -3
- package/_entity/permission-project/index.js +0 -4
- package/_entity/permission-user/index.d.ts +0 -3
- package/_entity/permission-user/index.js +0 -4
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DBDef_PermissionAccessLevel:
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionAccessLevel } from './types.js';
|
|
3
|
+
export declare const DBDef_PermissionAccessLevel: Database<DatabaseDef_PermissionAccessLevel>;
|
|
4
|
+
/** Brand a string as DatabaseDef_PermissionAccessLevel['id']. Use for literal ids (e.g. default levels). */
|
|
5
|
+
export declare const toPermissionAccessLevelId: (id: string) => import("@nu-art/db-api-shared").DB_UniqueId<"permissions--level">;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { stringToUniqueId } from '@nu-art/db-api-shared';
|
|
1
2
|
import { tsValidateIsInRange, tsValidateString, tsValidateStringWithDashes, tsValidateUniqueId } from '@nu-art/ts-common';
|
|
3
|
+
import { PermissionAccessLevel_DbKey } from './types.js';
|
|
2
4
|
import { PermissionDBGroup } from '../../consts.js';
|
|
3
5
|
const Validator_ModifiableProps = {
|
|
4
6
|
domainId: tsValidateUniqueId,
|
|
@@ -9,11 +11,13 @@ const Validator_ModifiableProps = {
|
|
|
9
11
|
const Validator_GeneratedProps = {
|
|
10
12
|
_auditorId: tsValidateString()
|
|
11
13
|
};
|
|
14
|
+
const GeneratedProps = ['_auditorId'];
|
|
12
15
|
export const DBDef_PermissionAccessLevel = {
|
|
13
16
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
14
17
|
generatedPropsValidator: Validator_GeneratedProps,
|
|
18
|
+
generatedProps: GeneratedProps,
|
|
15
19
|
versions: ['1.0.1', '1.0.0'],
|
|
16
|
-
dbKey:
|
|
20
|
+
dbKey: PermissionAccessLevel_DbKey,
|
|
17
21
|
entityName: 'PermissionAccessLevel',
|
|
18
22
|
frontend: {
|
|
19
23
|
group: PermissionDBGroup,
|
|
@@ -29,3 +33,5 @@ export const DBDef_PermissionAccessLevel = {
|
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
};
|
|
36
|
+
/** Brand a string as DatabaseDef_PermissionAccessLevel['id']. Use for literal ids (e.g. default levels). */
|
|
37
|
+
export const toPermissionAccessLevelId = (id) => stringToUniqueId(id);
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionDomain } from '../permission-domain/types.js';
|
|
3
|
+
export declare const PermissionAccessLevel_DbKey = "permissions--level";
|
|
4
|
+
type DBKey = typeof PermissionAccessLevel_DbKey;
|
|
3
5
|
type VersionTypes_PermissionAccessLevel = {
|
|
4
6
|
'1.0.0': DB_PermissionAccessLevel;
|
|
5
7
|
'1.0.1': DB_PermissionAccessLevel;
|
|
6
8
|
};
|
|
7
9
|
type Versions = VersionsDeclaration<['1.0.1', '1.0.0'], VersionTypes_PermissionAccessLevel>;
|
|
8
|
-
type Dependencies = {
|
|
9
|
-
domainId: DBProto_PermissionDomain;
|
|
10
|
-
};
|
|
11
10
|
type UniqueKeys = '_id';
|
|
12
11
|
type GeneratedProps = '_auditorId';
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
type Dependencies = {
|
|
13
|
+
domainId: DatabaseDef_PermissionDomain;
|
|
14
|
+
};
|
|
15
|
+
type Proto = DB_ProtoSeed<DB_PermissionAccessLevel, DBKey, GeneratedProps, Versions, UniqueKeys, Dependencies>;
|
|
16
|
+
export type DatabaseDef_PermissionAccessLevel = DB_Prototype<Proto>;
|
|
17
|
+
export type UI_PermissionAccessLevel = DatabaseDef_PermissionAccessLevel['uiType'];
|
|
16
18
|
export type Base_AccessLevel = {
|
|
17
|
-
domainId:
|
|
19
|
+
domainId: DatabaseDef_PermissionDomain['id'];
|
|
18
20
|
value: number;
|
|
19
21
|
};
|
|
20
|
-
export type DB_PermissionAccessLevel = DB_Object & Base_AccessLevel &
|
|
22
|
+
export type DB_PermissionAccessLevel = DB_Object<DBKey> & Base_AccessLevel & {
|
|
21
23
|
name: string;
|
|
22
24
|
uiLabel: string;
|
|
25
|
+
_auditorId?: string;
|
|
23
26
|
};
|
|
24
|
-
export type DB_PermissionAccessLevel_1_0_0 = DB_Object & Base_AccessLevel &
|
|
27
|
+
export type DB_PermissionAccessLevel_1_0_0 = DB_Object<DBKey> & Base_AccessLevel & {
|
|
25
28
|
name: string;
|
|
26
29
|
};
|
|
27
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PermissionAccessLevel_DbKey = 'permissions--level';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DBDef_PermissionAPI:
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionAPI } from './types.js';
|
|
3
|
+
export declare const DBDef_PermissionAPI: Database<DatabaseDef_PermissionAPI>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { tsValidateArray, tsValidateBoolean, tsValidateDynamicObject, tsValidateNumber, tsValidateString, tsValidateUniqueId } from '@nu-art/ts-common';
|
|
2
|
+
import { PermissionAPI_DbKey } from './types.js';
|
|
2
3
|
import { PermissionDBGroup } from '../../consts.js';
|
|
3
4
|
import { tsValidateStringWithDashesAndSlash, validateProjectId } from '../../validators.js';
|
|
5
|
+
import { tsValidator_AuditableV2 } from '@nu-art/user-account-shared';
|
|
4
6
|
const Validator_ModifiableProps = {
|
|
5
7
|
projectId: validateProjectId,
|
|
6
8
|
path: tsValidateStringWithDashesAndSlash,
|
|
@@ -9,14 +11,15 @@ const Validator_ModifiableProps = {
|
|
|
9
11
|
onlyForApplication: tsValidateBoolean(false),
|
|
10
12
|
};
|
|
11
13
|
const Validator_GeneratedProps = {
|
|
12
|
-
|
|
14
|
+
...tsValidator_AuditableV2,
|
|
13
15
|
_accessLevels: tsValidateDynamicObject(tsValidateNumber(), tsValidateString(), false),
|
|
14
16
|
};
|
|
15
17
|
export const DBDef_PermissionAPI = {
|
|
16
18
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
17
19
|
generatedPropsValidator: Validator_GeneratedProps,
|
|
20
|
+
generatedProps: ['_auditorId', '_accessLevels'],
|
|
18
21
|
versions: ['1.0.1', '1.0.0'],
|
|
19
|
-
dbKey:
|
|
22
|
+
dbKey: PermissionAPI_DbKey,
|
|
20
23
|
frontend: {
|
|
21
24
|
group: PermissionDBGroup,
|
|
22
25
|
name: 'api',
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionAccessLevel } from '../permission-access-level/types.js';
|
|
3
|
+
import { DatabaseDef_PermissionDomain } from '../permission-domain/types.js';
|
|
4
|
+
import { DatabaseDef_PermissionProject } from '../permission-project/types.js';
|
|
5
|
+
import { AuditableV2 } from '@nu-art/user-account-shared';
|
|
6
|
+
export declare const PermissionAPI_DbKey = "permissions--api";
|
|
7
|
+
type DBKey = typeof PermissionAPI_DbKey;
|
|
4
8
|
type VersionTypes_PermissionAPI = {
|
|
5
9
|
'1.0.0': DB_PermissionAPI;
|
|
6
10
|
'1.0.1': DB_PermissionAPI;
|
|
7
11
|
};
|
|
8
12
|
type Versions = VersionsDeclaration<['1.0.1', '1.0.0'], VersionTypes_PermissionAPI>;
|
|
9
|
-
type Dependencies = {
|
|
10
|
-
projectId: DBProto_PermissionProject;
|
|
11
|
-
accessLevelIds: DBProto_PermissionAccessLevel;
|
|
12
|
-
};
|
|
13
13
|
type UniqueKeys = 'projectId' | 'path';
|
|
14
14
|
type GeneratedProps = '_auditorId' | '_accessLevels';
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
type Dependencies = {
|
|
16
|
+
projectId: DatabaseDef_PermissionProject;
|
|
17
|
+
accessLevelIds: DatabaseDef_PermissionAccessLevel;
|
|
18
|
+
};
|
|
19
|
+
type Proto = DB_ProtoSeed<DB_PermissionAPI, DBKey, GeneratedProps, Versions, UniqueKeys, Dependencies>;
|
|
20
|
+
export type DatabaseDef_PermissionAPI = DB_Prototype<Proto>;
|
|
21
|
+
export type UI_PermissionAPI = DatabaseDef_PermissionAPI['uiType'];
|
|
22
|
+
/** @deprecated API collection deprecated; use function-based permissions and @RequirePermission. */
|
|
23
|
+
export type DB_PermissionAPI = DB_Object<DBKey> & AuditableV2 & {
|
|
24
|
+
projectId: DatabaseDef_PermissionProject['id'];
|
|
20
25
|
path: string;
|
|
21
|
-
accessLevelIds?:
|
|
26
|
+
accessLevelIds?: DatabaseDef_PermissionAccessLevel['id'][];
|
|
22
27
|
deprecated?: boolean;
|
|
23
28
|
onlyForApplication?: boolean;
|
|
24
29
|
_accessLevels?: DomainToLevelValueMap;
|
|
25
30
|
};
|
|
26
31
|
export type DomainToLevelValueMap = {
|
|
27
|
-
[domainId:
|
|
32
|
+
[domainId: DatabaseDef_PermissionDomain['id']]: number;
|
|
28
33
|
};
|
|
29
34
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PermissionAPI_DbKey = 'permissions--api';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DBDef_PermissionDomain:
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionDomain } from './types.js';
|
|
3
|
+
export declare const DBDef_PermissionDomain: Database<DatabaseDef_PermissionDomain>;
|
|
4
|
+
/** Brand a string as DatabaseDef_PermissionDomain['id']. Use for literal ids (e.g. default domains). */
|
|
5
|
+
export declare const toPermissionDomainId: (id: string) => import("@nu-art/db-api-shared").DB_UniqueId<"permissions--domain">;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { stringToUniqueId } from '@nu-art/db-api-shared';
|
|
1
2
|
import { tsValidateString } from '@nu-art/ts-common';
|
|
3
|
+
import { PermissionDomain_DbKey } from './types.js';
|
|
2
4
|
import { validateProjectId } from '../../validators.js';
|
|
3
5
|
import { PermissionDBGroup } from '../../consts.js';
|
|
4
6
|
const Validator_ModifiableProps = {
|
|
@@ -11,8 +13,9 @@ const Validator_GeneratedProps = {
|
|
|
11
13
|
export const DBDef_PermissionDomain = {
|
|
12
14
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
13
15
|
generatedPropsValidator: Validator_GeneratedProps,
|
|
16
|
+
generatedProps: ['_auditorId'],
|
|
14
17
|
versions: ['1.0.0'],
|
|
15
|
-
dbKey:
|
|
18
|
+
dbKey: PermissionDomain_DbKey,
|
|
16
19
|
frontend: {
|
|
17
20
|
group: PermissionDBGroup,
|
|
18
21
|
name: 'domain',
|
|
@@ -29,3 +32,5 @@ export const DBDef_PermissionDomain = {
|
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
};
|
|
35
|
+
/** Brand a string as DatabaseDef_PermissionDomain['id']. Use for literal ids (e.g. default domains). */
|
|
36
|
+
export const toPermissionDomainId = (id) => stringToUniqueId(id);
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionProject } from '../permission-project/types.js';
|
|
3
|
+
import { AuditableV2 } from '@nu-art/user-account-shared';
|
|
4
|
+
export declare const PermissionDomain_DbKey = "permissions--domain";
|
|
5
|
+
type DBKey = typeof PermissionDomain_DbKey;
|
|
3
6
|
type VersionTypes_PermissionDomain = {
|
|
4
7
|
'1.0.0': DB_PermissionDomain;
|
|
5
8
|
};
|
|
6
9
|
type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_PermissionDomain>;
|
|
7
|
-
type Dependencies = {
|
|
8
|
-
projectId: DBProto_PermissionProject;
|
|
9
|
-
};
|
|
10
10
|
type UniqueKeys = '_id';
|
|
11
11
|
type GeneratedProps = '_auditorId';
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
type Dependencies = {
|
|
13
|
+
projectId: DatabaseDef_PermissionProject;
|
|
14
|
+
};
|
|
15
|
+
type Proto = DB_ProtoSeed<DB_PermissionDomain, DBKey, GeneratedProps, Versions, UniqueKeys, Dependencies>;
|
|
16
|
+
export type DatabaseDef_PermissionDomain = DB_Prototype<Proto>;
|
|
17
|
+
export type UI_PermissionDomain = DatabaseDef_PermissionDomain['uiType'];
|
|
18
|
+
export type DB_PermissionDomain = DB_Object<DBKey> & AuditableV2 & {
|
|
19
|
+
projectId: DatabaseDef_PermissionProject['id'];
|
|
17
20
|
namespace: string;
|
|
18
21
|
};
|
|
19
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PermissionDomain_DbKey = 'permissions--domain';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DBDef_PermissionGroup:
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionGroup } from './types.js';
|
|
3
|
+
export declare const DBDef_PermissionGroup: Database<DatabaseDef_PermissionGroup>;
|
|
4
|
+
/** Brand a string as DatabaseDef_PermissionGroup['id']. Use for literal ids (e.g. default groups). */
|
|
5
|
+
export declare const toPermissionGroupId: (id: string) => import("@nu-art/db-api-shared").DB_UniqueId<"permissions--group">;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { tsValidateArray, tsValidateDynamicObject, tsValidateNumber, tsValidateOptionalId, tsValidateString, tsValidateUniqueId } from '@nu-art/ts-common';
|
|
1
|
+
import { tsValidateArray, tsValidateDynamicObject, tsValidateNumber, tsValidateOptionalId, tsValidateString, tsValidateUniqueId, } from '@nu-art/ts-common';
|
|
2
|
+
import { stringToUniqueId } from '@nu-art/db-api-shared';
|
|
3
|
+
import { PermissionGroup_DbKey } from './types.js';
|
|
2
4
|
import { PermissionDBGroup } from '../../consts.js';
|
|
3
5
|
import { validateGroupLabel } from '../../validators.js';
|
|
6
|
+
import { tsValidator_AuditableV2 } from '@nu-art/user-account-shared';
|
|
4
7
|
const Validator_ModifiableProps = {
|
|
5
8
|
label: validateGroupLabel,
|
|
6
9
|
uiLabel: tsValidateString(),
|
|
@@ -8,14 +11,15 @@ const Validator_ModifiableProps = {
|
|
|
8
11
|
accessLevelIds: tsValidateArray(tsValidateUniqueId, false),
|
|
9
12
|
};
|
|
10
13
|
const Validator_GeneratedProps = {
|
|
14
|
+
...tsValidator_AuditableV2,
|
|
11
15
|
_levelsMap: tsValidateDynamicObject(tsValidateNumber(), tsValidateString(), false),
|
|
12
|
-
_auditorId: tsValidateString(),
|
|
13
16
|
};
|
|
14
17
|
export const DBDef_PermissionGroup = {
|
|
15
18
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
16
19
|
generatedPropsValidator: Validator_GeneratedProps,
|
|
20
|
+
generatedProps: ['_levelsMap'],
|
|
17
21
|
versions: ['1.0.1', '1.0.0'],
|
|
18
|
-
dbKey:
|
|
22
|
+
dbKey: PermissionGroup_DbKey,
|
|
19
23
|
entityName: 'PermissionGroup',
|
|
20
24
|
frontend: {
|
|
21
25
|
group: PermissionDBGroup,
|
|
@@ -35,3 +39,5 @@ export const DBDef_PermissionGroup = {
|
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
};
|
|
42
|
+
/** Brand a string as DatabaseDef_PermissionGroup['id']. Use for literal ids (e.g. default groups). */
|
|
43
|
+
export const toPermissionGroupId = (id) => stringToUniqueId(id);
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { TypedMap } from '@nu-art/ts-common';
|
|
2
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
3
|
+
import { DatabaseDef_PermissionProject } from '../permission-project/types.js';
|
|
4
|
+
import { DatabaseDef_PermissionAccessLevel } from '../permission-access-level/types.js';
|
|
5
|
+
import { AuditableV2 } from '@nu-art/user-account-shared';
|
|
6
|
+
export declare const PermissionGroup_DbKey = "permissions--group";
|
|
7
|
+
type DBKey = typeof PermissionGroup_DbKey;
|
|
4
8
|
type VersionTypes_PermissionGroup = {
|
|
5
9
|
'1.0.0': DB_PermissionGroup;
|
|
6
10
|
'1.0.1': DB_PermissionGroup;
|
|
7
11
|
};
|
|
8
12
|
type Versions = VersionsDeclaration<['1.0.1', '1.0.0'], VersionTypes_PermissionGroup>;
|
|
13
|
+
type UniqueKeys = '_id';
|
|
14
|
+
type GeneratedProps = '_levelsMap' | keyof AuditableV2;
|
|
9
15
|
type Dependencies = {
|
|
10
|
-
projectId:
|
|
11
|
-
accessLevelIds:
|
|
16
|
+
projectId: DatabaseDef_PermissionProject;
|
|
17
|
+
accessLevelIds: DatabaseDef_PermissionAccessLevel;
|
|
12
18
|
};
|
|
13
|
-
type
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
export type DB_PermissionGroup = DB_Object & AuditableV2 & {
|
|
19
|
-
projectId?: string;
|
|
19
|
+
type Proto = DB_ProtoSeed<DB_PermissionGroup, DBKey, GeneratedProps, Versions, UniqueKeys, Dependencies>;
|
|
20
|
+
export type DatabaseDef_PermissionGroup = DB_Prototype<Proto>;
|
|
21
|
+
export type UI_PermissionGroup = DatabaseDef_PermissionGroup['uiType'];
|
|
22
|
+
export type DB_PermissionGroup = DB_Object<DBKey> & AuditableV2 & {
|
|
23
|
+
projectId?: DatabaseDef_PermissionProject['id'];
|
|
20
24
|
label: string;
|
|
21
25
|
uiLabel: string;
|
|
22
|
-
accessLevelIds:
|
|
26
|
+
accessLevelIds: DatabaseDef_PermissionAccessLevel['id'][];
|
|
23
27
|
_levelsMap?: TypedMap<number>;
|
|
24
28
|
};
|
|
25
|
-
export type DB_PermissionGroup_1_0_0 = DB_Object & AuditableV2 & {
|
|
26
|
-
projectId?:
|
|
29
|
+
export type DB_PermissionGroup_1_0_0 = DB_Object<DBKey> & AuditableV2 & {
|
|
30
|
+
projectId?: DatabaseDef_PermissionProject['id'];
|
|
27
31
|
label: string;
|
|
28
|
-
accessLevelIds:
|
|
32
|
+
accessLevelIds: DatabaseDef_PermissionAccessLevel['id'][];
|
|
29
33
|
_levelsMap?: TypedMap<number>;
|
|
30
34
|
};
|
|
31
35
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PermissionGroup_DbKey = 'permissions--group';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DBDef_PermissionProject:
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionProject } from './types.js';
|
|
3
|
+
export declare const DBDef_PermissionProject: Database<DatabaseDef_PermissionProject>;
|
|
4
|
+
/** Brand a string as DatabaseDef_PermissionProject['id']. Use for literal ids (e.g. default projects). */
|
|
5
|
+
export declare const toPermissionProjectId: (id: string) => import("@nu-art/db-api-shared").DB_UniqueId<"permissions--project">;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { stringToUniqueId } from '@nu-art/db-api-shared';
|
|
1
2
|
import { tsValidateString } from '@nu-art/ts-common';
|
|
3
|
+
import { PermissionProject_DbKey } from './types.js';
|
|
2
4
|
import { PermissionDBGroup } from '../../consts.js';
|
|
3
5
|
import { validateProjectName } from '../../validators.js';
|
|
4
6
|
const Validator_ModifiableProps = {
|
|
@@ -10,8 +12,9 @@ const Validator_GeneratedProps = {
|
|
|
10
12
|
export const DBDef_PermissionProject = {
|
|
11
13
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
12
14
|
generatedPropsValidator: Validator_GeneratedProps,
|
|
15
|
+
generatedProps: ['_auditorId'],
|
|
13
16
|
versions: ['1.0.0'],
|
|
14
|
-
dbKey:
|
|
17
|
+
dbKey: PermissionProject_DbKey,
|
|
15
18
|
entityName: 'PermissionsProject',
|
|
16
19
|
frontend: {
|
|
17
20
|
group: PermissionDBGroup,
|
|
@@ -21,3 +24,5 @@ export const DBDef_PermissionProject = {
|
|
|
21
24
|
name: 'permissions--project'
|
|
22
25
|
}
|
|
23
26
|
};
|
|
27
|
+
/** Brand a string as DatabaseDef_PermissionProject['id']. Use for literal ids (e.g. default projects). */
|
|
28
|
+
export const toPermissionProjectId = (id) => stringToUniqueId(id);
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
2
|
+
import { AuditableV2 } from '@nu-art/user-account-shared';
|
|
3
|
+
export declare const PermissionProject_DbKey = "permissions--project";
|
|
4
|
+
type DBKey = typeof PermissionProject_DbKey;
|
|
2
5
|
type VersionTypes_PermissionProject = {
|
|
3
6
|
'1.0.0': DB_PermissionProject;
|
|
4
7
|
};
|
|
5
8
|
type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_PermissionProject>;
|
|
6
|
-
type Dependencies = {};
|
|
7
9
|
type UniqueKeys = '_id';
|
|
8
10
|
type GeneratedProps = '_auditorId';
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
export type
|
|
11
|
+
type Dependencies = {};
|
|
12
|
+
type Proto = DB_ProtoSeed<DB_PermissionProject, DBKey, GeneratedProps, Versions, UniqueKeys, Dependencies>;
|
|
13
|
+
export type DatabaseDef_PermissionProject = DB_Prototype<Proto>;
|
|
14
|
+
export type UI_PermissionProject = DatabaseDef_PermissionProject['uiType'];
|
|
15
|
+
export type DB_PermissionProject = DB_Object<DBKey> & AuditableV2 & {
|
|
13
16
|
name: string;
|
|
14
17
|
};
|
|
15
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PermissionProject_DbKey = 'permissions--project';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ApiDefResolver, BodyApi } from '@nu-art/
|
|
1
|
+
import { ApiDefResolver, BodyApi } from '@nu-art/api-types';
|
|
2
|
+
import { DatabaseDef_Account } from '@nu-art/user-account-shared';
|
|
3
|
+
import { DatabaseDef_PermissionGroup } from '../permission-group/types.js';
|
|
4
|
+
import { DatabaseDef_PermissionProject } from '../permission-project/types.js';
|
|
2
5
|
export type Request_AssignPermissions = {
|
|
3
|
-
projectId?:
|
|
4
|
-
permissionGroupIds:
|
|
5
|
-
targetAccountIds:
|
|
6
|
+
projectId?: DatabaseDef_PermissionProject['id'];
|
|
7
|
+
permissionGroupIds: DatabaseDef_PermissionGroup['id'][];
|
|
8
|
+
targetAccountIds: DatabaseDef_Account['id'][];
|
|
6
9
|
};
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
assignPermissions: BodyApi<void, Request_AssignPermissions>;
|
|
10
|
-
};
|
|
10
|
+
export type API_PermissionUser = {
|
|
11
|
+
assignPermissions: BodyApi<void, Request_AssignPermissions>;
|
|
11
12
|
};
|
|
12
|
-
export declare const ApiDef_PermissionUser: ApiDefResolver<
|
|
13
|
+
export declare const ApiDef_PermissionUser: ApiDefResolver<API_PermissionUser>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { HttpMethod } from '@nu-art/
|
|
1
|
+
import { HttpMethod } from '@nu-art/api-types';
|
|
2
2
|
export const ApiDef_PermissionUser = {
|
|
3
|
-
|
|
4
|
-
assignPermissions: { method: HttpMethod.POST, path: '/pah/permissions/assign/app-permissions' }
|
|
5
|
-
}
|
|
3
|
+
assignPermissions: { method: HttpMethod.POST, path: '/pah/permissions/assign/app-permissions' }
|
|
6
4
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DBDef_PermissionUser:
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionUser } from './types.js';
|
|
3
|
+
export declare const DBDef_PermissionUser: Database<DatabaseDef_PermissionUser>;
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { tsValidateArray,
|
|
1
|
+
import { tsValidateArray, tsValidateStringAndNumbersWithDashes } from '@nu-art/ts-common';
|
|
2
|
+
import { PermissionUser_DbKey } from './types.js';
|
|
2
3
|
import { PermissionDBGroup } from '../../consts.js';
|
|
4
|
+
import { tsValidator_AuditableV2 } from '@nu-art/user-account-shared';
|
|
3
5
|
const Validator_ModifiableProps = {
|
|
4
6
|
groups: tsValidateArray({
|
|
5
7
|
groupId: tsValidateStringAndNumbersWithDashes,
|
|
6
8
|
}, false),
|
|
7
9
|
};
|
|
8
10
|
const Validator_GeneratedProps = {
|
|
11
|
+
...tsValidator_AuditableV2,
|
|
9
12
|
__groupIds: tsValidateArray(tsValidateStringAndNumbersWithDashes, false),
|
|
10
|
-
_auditorId: tsValidateString()
|
|
11
13
|
};
|
|
12
14
|
export const DBDef_PermissionUser = {
|
|
13
15
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
14
16
|
generatedPropsValidator: Validator_GeneratedProps,
|
|
17
|
+
generatedProps: ['__groupIds', '_auditorId'],
|
|
15
18
|
versions: ['1.0.0'],
|
|
16
|
-
dbKey:
|
|
19
|
+
dbKey: PermissionUser_DbKey,
|
|
17
20
|
entityName: 'PermissionUser',
|
|
18
21
|
frontend: {
|
|
19
22
|
group: PermissionDBGroup,
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_PermissionGroup } from '../permission-group/types.js';
|
|
3
|
+
import { AuditableV2 } from '@nu-art/user-account-shared';
|
|
4
|
+
export declare const PermissionUser_DbKey = "permissions--user";
|
|
5
|
+
type DBKey = typeof PermissionUser_DbKey;
|
|
3
6
|
type VersionTypes_PermissionUser = {
|
|
4
7
|
'1.0.0': DB_PermissionUser;
|
|
5
8
|
};
|
|
6
9
|
type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_PermissionUser>;
|
|
7
|
-
type Dependencies = {
|
|
8
|
-
'__groupIds': DBProto_PermissionGroup;
|
|
9
|
-
};
|
|
10
10
|
type UniqueKeys = '_id';
|
|
11
11
|
type GeneratedProps = '__groupIds' | '_auditorId';
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
type Dependencies = {
|
|
13
|
+
'__groupIds': DatabaseDef_PermissionGroup;
|
|
14
|
+
};
|
|
15
|
+
type Proto = DB_ProtoSeed<DB_PermissionUser, DBKey, GeneratedProps, Versions, UniqueKeys, Dependencies>;
|
|
16
|
+
export type DatabaseDef_PermissionUser = DB_Prototype<Proto>;
|
|
17
|
+
export type UI_PermissionUser = DatabaseDef_PermissionUser['uiType'];
|
|
15
18
|
export type User_Group = {
|
|
16
|
-
groupId:
|
|
19
|
+
groupId: DatabaseDef_PermissionGroup['id'];
|
|
17
20
|
};
|
|
18
|
-
export type DB_PermissionUser = DB_Object & AuditableV2 & {
|
|
21
|
+
export type DB_PermissionUser = DB_Object<DBKey> & AuditableV2 & {
|
|
19
22
|
groups: User_Group[];
|
|
20
|
-
__groupIds?:
|
|
23
|
+
__groupIds?: DatabaseDef_PermissionGroup['id'][];
|
|
21
24
|
};
|
|
22
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PermissionUser_DbKey = 'permissions--user';
|
package/_entity.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
export * from './_entity/permission-access-level/
|
|
2
|
-
export * from './_entity/permission-
|
|
3
|
-
export * from './_entity/permission-
|
|
4
|
-
export * from './_entity/permission-
|
|
5
|
-
export * from './_entity/permission-
|
|
6
|
-
export * from './_entity/permission-
|
|
1
|
+
export * from './_entity/permission-access-level/types.js';
|
|
2
|
+
export * from './_entity/permission-access-level/db-def.js';
|
|
3
|
+
export * from './_entity/permission-api/types.js';
|
|
4
|
+
export * from './_entity/permission-api/db-def.js';
|
|
5
|
+
export * from './_entity/permission-project/types.js';
|
|
6
|
+
export * from './_entity/permission-project/db-def.js';
|
|
7
|
+
export * from './_entity/permission-domain/types.js';
|
|
8
|
+
export * from './_entity/permission-domain/db-def.js';
|
|
9
|
+
export * from './_entity/permission-group/types.js';
|
|
10
|
+
export * from './_entity/permission-group/db-def.js';
|
|
11
|
+
export * from './_entity/permission-user/types.js';
|
|
12
|
+
export * from './_entity/permission-user/db-def.js';
|
|
13
|
+
export * from './_entity/permission-user/api-def.js';
|
package/_entity.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
export * from './_entity/permission-access-level/
|
|
2
|
-
export * from './_entity/permission-
|
|
3
|
-
export * from './_entity/permission-
|
|
4
|
-
export * from './_entity/permission-
|
|
5
|
-
export * from './_entity/permission-
|
|
6
|
-
export * from './_entity/permission-
|
|
1
|
+
export * from './_entity/permission-access-level/types.js';
|
|
2
|
+
export * from './_entity/permission-access-level/db-def.js';
|
|
3
|
+
export * from './_entity/permission-api/types.js';
|
|
4
|
+
export * from './_entity/permission-api/db-def.js';
|
|
5
|
+
export * from './_entity/permission-project/types.js';
|
|
6
|
+
export * from './_entity/permission-project/db-def.js';
|
|
7
|
+
export * from './_entity/permission-domain/types.js';
|
|
8
|
+
export * from './_entity/permission-domain/db-def.js';
|
|
9
|
+
export * from './_entity/permission-group/types.js';
|
|
10
|
+
export * from './_entity/permission-group/db-def.js';
|
|
11
|
+
export * from './_entity/permission-user/types.js';
|
|
12
|
+
export * from './_entity/permission-user/db-def.js';
|
|
13
|
+
export * from './_entity/permission-user/api-def.js';
|
package/apis.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { ApiDefResolver, BodyApi, QueryApi } from '@nu-art/
|
|
1
|
+
import { ApiDefResolver, BodyApi, QueryApi } from '@nu-art/api-types';
|
|
2
2
|
import { PreDB, StringMap } from '@nu-art/ts-common';
|
|
3
|
-
import {
|
|
3
|
+
import { DatabaseDef_Account } from '@nu-art/user-account-shared';
|
|
4
|
+
import { DatabaseDef_PermissionGroup, DatabaseDef_PermissionProject, DatabaseDef_PermissionUser, DB_PermissionProject } from './_entity.js';
|
|
4
5
|
export type UserUrlsPermissions = {
|
|
5
6
|
[url: string]: boolean;
|
|
6
7
|
};
|
|
7
8
|
export type Request_AssertApiForUser = {
|
|
8
|
-
projectId:
|
|
9
|
+
projectId: DatabaseDef_PermissionProject['id'];
|
|
9
10
|
path: string;
|
|
10
11
|
};
|
|
11
12
|
export type Request_UserUrlsPermissions = {
|
|
12
|
-
projectId:
|
|
13
|
+
projectId: DatabaseDef_PermissionProject['id'];
|
|
13
14
|
urls: UserUrlsPermissions;
|
|
14
15
|
};
|
|
15
16
|
export type Request_UserCFsByShareGroups = {
|
|
16
|
-
groupsIds:
|
|
17
|
+
groupsIds: DatabaseDef_PermissionGroup['id'][];
|
|
17
18
|
};
|
|
18
19
|
export type Request_UsersCFsByShareGroups = Request_UserCFsByShareGroups & {
|
|
19
20
|
usersEmails: string[];
|
|
@@ -22,7 +23,7 @@ export type Response_UsersCFsByShareGroups = {
|
|
|
22
23
|
[userEmail: string]: StringMap[];
|
|
23
24
|
};
|
|
24
25
|
export type Request_AssignAppPermissions<T extends StringMap = StringMap> = {
|
|
25
|
-
projectId:
|
|
26
|
+
projectId: DatabaseDef_PermissionProject['id'];
|
|
26
27
|
groupsToRemove: PredefinedGroup[];
|
|
27
28
|
group: PredefinedGroup;
|
|
28
29
|
customField: T;
|
|
@@ -32,17 +33,17 @@ export type Request_AssignAppPermissions<T extends StringMap = StringMap> = {
|
|
|
32
33
|
appAccountId?: string;
|
|
33
34
|
};
|
|
34
35
|
export type AssignAppPermissions = Request_AssignAppPermissions & {
|
|
35
|
-
granterUserId:
|
|
36
|
+
granterUserId: DatabaseDef_Account['id'];
|
|
36
37
|
};
|
|
37
38
|
export type PredefinedGroup = {
|
|
38
|
-
_id:
|
|
39
|
+
_id: DatabaseDef_PermissionGroup['id'];
|
|
39
40
|
key: string;
|
|
40
41
|
label: string;
|
|
41
42
|
customKeys?: string[];
|
|
42
43
|
};
|
|
43
44
|
export type PredefinedUser = {
|
|
44
|
-
accountId:
|
|
45
|
-
_id:
|
|
45
|
+
accountId: DatabaseDef_Account['id'];
|
|
46
|
+
_id: DatabaseDef_PermissionUser['id'];
|
|
46
47
|
groups: PredefinedGroup[];
|
|
47
48
|
};
|
|
48
49
|
export type Request_RegisterProject = {
|
|
@@ -52,24 +53,14 @@ export type Request_RegisterProject = {
|
|
|
52
53
|
predefinedUser?: PredefinedUser;
|
|
53
54
|
};
|
|
54
55
|
export type Response_User = {
|
|
55
|
-
userId:
|
|
56
|
+
userId: DatabaseDef_Account['id'];
|
|
56
57
|
};
|
|
57
|
-
export type
|
|
58
|
-
|
|
59
|
-
assignAppPermissions: BodyApi<void, Request_AssignAppPermissions>;
|
|
60
|
-
};
|
|
58
|
+
export type API_PermissionsAssert = {
|
|
59
|
+
assertUserPermissions: BodyApi<Response_User, Request_AssertApiForUser>;
|
|
61
60
|
};
|
|
62
|
-
export declare const
|
|
63
|
-
export type
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
61
|
+
export declare const ApiDef_PermissionsAssert: ApiDefResolver<API_PermissionsAssert>;
|
|
62
|
+
export type API_Permissions = {
|
|
63
|
+
toggleStrictMode: QueryApi<void>;
|
|
64
|
+
createProject: QueryApi<void>;
|
|
67
65
|
};
|
|
68
|
-
export declare const
|
|
69
|
-
export type ApiStruct_Permissions = {
|
|
70
|
-
v1: {
|
|
71
|
-
toggleStrictMode: QueryApi<void>;
|
|
72
|
-
createProject: QueryApi<void>;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
export declare const ApiDef_Permissions: ApiDefResolver<ApiStruct_Permissions>;
|
|
66
|
+
export declare const ApiDef_Permissions: ApiDefResolver<API_Permissions>;
|
package/apis.js
CHANGED
|
@@ -16,27 +16,12 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { HttpMethod } from '@nu-art/
|
|
19
|
+
import { HttpMethod } from '@nu-art/api-types';
|
|
20
20
|
import { Minute } from '@nu-art/ts-common';
|
|
21
|
-
export const _ApiDef_PermissionUser = {
|
|
22
|
-
pah: {
|
|
23
|
-
assignAppPermissions: { method: HttpMethod.POST, path: '/v1/permissions/assign/app-permissions' }
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
21
|
export const ApiDef_PermissionsAssert = {
|
|
27
|
-
|
|
28
|
-
assertUserPermissions: { method: HttpMethod.POST, path: 'v1/permissions/assert-user-access' }
|
|
29
|
-
}
|
|
22
|
+
assertUserPermissions: { method: HttpMethod.POST, path: 'v1/permissions/assert-user-access' }
|
|
30
23
|
};
|
|
31
24
|
export const ApiDef_Permissions = {
|
|
32
|
-
v1:
|
|
33
|
-
|
|
34
|
-
// getUserCFsByShareGroups: {method: HttpMethod.POST, path: 'v1/user-custom-fields/user-cf-by-share-groups'},
|
|
35
|
-
// getUsersCFsByShareGroups: {method: HttpMethod.POST, path: 'v1/user-custom-fields/users-cf-by-share-groups'},
|
|
36
|
-
// registerExternalProject: {method: HttpMethod.POST, path: 'v1/register/register-external-project'},
|
|
37
|
-
// registerProject: {method: HttpMethod.GET, path: 'v1/register/register-project'},
|
|
38
|
-
toggleStrictMode: { method: HttpMethod.GET, path: 'v1/permissions/toggle-strict-mode', timeout: Minute },
|
|
39
|
-
createProject: { method: HttpMethod.GET, path: 'v1/permissions/create-first-project', timeout: Minute },
|
|
40
|
-
// connectDomainToRoutes: {method: HttpMethod.POST, path: 'v1/permissions/connect-domain-to-routes'},
|
|
41
|
-
}
|
|
25
|
+
toggleStrictMode: { method: HttpMethod.GET, path: 'v1/permissions/toggle-strict-mode', timeout: Minute },
|
|
26
|
+
createProject: { method: HttpMethod.GET, path: 'v1/permissions/create-first-project', timeout: Minute },
|
|
42
27
|
};
|
package/consts.d.ts
CHANGED
|
@@ -62,19 +62,20 @@ export declare const defaultAccessLevels: (Readonly<{
|
|
|
62
62
|
value: 1000;
|
|
63
63
|
}>)[];
|
|
64
64
|
export declare const DuplicateDefaultAccessLevels: (seed: string) => {
|
|
65
|
-
_id:
|
|
65
|
+
_id: import("@nu-art/db-api-shared").DB_UniqueId<"permissions--level">;
|
|
66
66
|
uiLabel: string;
|
|
67
67
|
name: string;
|
|
68
68
|
value: number;
|
|
69
69
|
}[];
|
|
70
70
|
export declare const CreateDefaultAccessLevels: (seed: string, accessLevels: PreDBAccessLevel[]) => {
|
|
71
|
-
_id:
|
|
71
|
+
_id: import("@nu-art/db-api-shared").DB_UniqueId<"permissions--level">;
|
|
72
72
|
uiLabel: string;
|
|
73
73
|
name: string;
|
|
74
74
|
value: number;
|
|
75
75
|
}[];
|
|
76
76
|
export declare const generateKeyNamesByAccessLevel: <AccessLevel extends PreDBAccessLevel>(namespace: string, accessLevels: AccessLevel[]) => { [key in AccessLevel["name"]]: string; };
|
|
77
77
|
export declare const defaultPermissionKeySuffix = "permission-key";
|
|
78
|
+
/** @deprecated Path-based API permission; use function-based permissions and @RequirePermission. API collection deprecated. */
|
|
78
79
|
export declare const defaultLevelsRouteLookupWords: {
|
|
79
80
|
[k: string]: string;
|
|
80
81
|
};
|
package/consts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { md5 } from '@nu-art/ts-common';
|
|
2
|
+
import { asBrandedId } from '@nu-art/db-api-shared';
|
|
2
3
|
export const PermissionDBGroup = 'permission';
|
|
3
4
|
export const Prefix_PermissionKey = 'permission-key--';
|
|
4
5
|
export const DomainNamespace_PermissionAssignment = 'Permissions Assignment';
|
|
@@ -37,7 +38,11 @@ const generateDefaultKeyName = (namespace, accessLevelName) => {
|
|
|
37
38
|
return `${defaultPermissionKeySuffix}--${namespace}--${accessLevelName}`;
|
|
38
39
|
};
|
|
39
40
|
export const CreateDefaultAccessLevels = (seed, accessLevels) => {
|
|
40
|
-
return accessLevels.map(level => ({
|
|
41
|
+
return accessLevels.map(level => ({
|
|
42
|
+
...level,
|
|
43
|
+
_id: asBrandedId(md5(`${seed}${level.name}`)),
|
|
44
|
+
uiLabel: level.name
|
|
45
|
+
}));
|
|
41
46
|
};
|
|
42
47
|
export const generateKeyNamesByAccessLevel = (namespace, accessLevels) => {
|
|
43
48
|
return accessLevels.reduce((keyMapper, currentAccessLevel) => {
|
|
@@ -47,6 +52,7 @@ export const generateKeyNamesByAccessLevel = (namespace, accessLevels) => {
|
|
|
47
52
|
}, {});
|
|
48
53
|
};
|
|
49
54
|
export const defaultPermissionKeySuffix = 'permission-key';
|
|
55
|
+
/** @deprecated Path-based API permission; use function-based permissions and @RequirePermission. API collection deprecated. */
|
|
50
56
|
export const defaultLevelsRouteLookupWords = {
|
|
51
57
|
'query': 'Read',
|
|
52
58
|
'query-unique': 'Read',
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
export * from './_entity/permission-access-level/
|
|
2
|
-
export * from './_entity/permission-
|
|
3
|
-
export * from './_entity/permission-
|
|
4
|
-
export * from './_entity/permission-
|
|
5
|
-
export * from './_entity/permission-
|
|
6
|
-
export * from './_entity/permission-
|
|
1
|
+
export * from './_entity/permission-access-level/types.js';
|
|
2
|
+
export * from './_entity/permission-access-level/db-def.js';
|
|
3
|
+
export * from './_entity/permission-api/types.js';
|
|
4
|
+
export * from './_entity/permission-api/db-def.js';
|
|
5
|
+
export * from './_entity/permission-domain/types.js';
|
|
6
|
+
export * from './_entity/permission-domain/db-def.js';
|
|
7
|
+
export * from './_entity/permission-group/types.js';
|
|
8
|
+
export * from './_entity/permission-group/db-def.js';
|
|
9
|
+
export * from './_entity/permission-project/types.js';
|
|
10
|
+
export * from './_entity/permission-project/db-def.js';
|
|
11
|
+
export * from './_entity/permission-user/types.js';
|
|
12
|
+
export * from './_entity/permission-user/db-def.js';
|
|
13
|
+
export * from './_entity/permission-user/api-def.js';
|
|
7
14
|
export * from './apis.js';
|
|
8
15
|
export * from './consts.js';
|
|
9
16
|
export * from './types.js';
|
|
10
17
|
export * from './permission-keys.js';
|
|
18
|
+
export * from './permission-scope.js';
|
|
19
|
+
export * from './path-utils.js';
|
|
20
|
+
export * from './project-setup.js';
|
|
21
|
+
export * from './service-account-def.js';
|
package/index.js
CHANGED
|
@@ -16,13 +16,24 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
export * from './_entity/permission-access-level/
|
|
20
|
-
export * from './_entity/permission-
|
|
21
|
-
export * from './_entity/permission-
|
|
22
|
-
export * from './_entity/permission-
|
|
23
|
-
export * from './_entity/permission-
|
|
24
|
-
export * from './_entity/permission-
|
|
19
|
+
export * from './_entity/permission-access-level/types.js';
|
|
20
|
+
export * from './_entity/permission-access-level/db-def.js';
|
|
21
|
+
export * from './_entity/permission-api/types.js';
|
|
22
|
+
export * from './_entity/permission-api/db-def.js';
|
|
23
|
+
export * from './_entity/permission-domain/types.js';
|
|
24
|
+
export * from './_entity/permission-domain/db-def.js';
|
|
25
|
+
export * from './_entity/permission-group/types.js';
|
|
26
|
+
export * from './_entity/permission-group/db-def.js';
|
|
27
|
+
export * from './_entity/permission-project/types.js';
|
|
28
|
+
export * from './_entity/permission-project/db-def.js';
|
|
29
|
+
export * from './_entity/permission-user/types.js';
|
|
30
|
+
export * from './_entity/permission-user/db-def.js';
|
|
31
|
+
export * from './_entity/permission-user/api-def.js';
|
|
25
32
|
export * from './apis.js';
|
|
26
33
|
export * from './consts.js';
|
|
27
34
|
export * from './types.js';
|
|
28
35
|
export * from './permission-keys.js';
|
|
36
|
+
export * from './permission-scope.js';
|
|
37
|
+
export * from './path-utils.js';
|
|
38
|
+
export * from './project-setup.js';
|
|
39
|
+
export * from './service-account-def.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/permissions-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.500.0",
|
|
4
4
|
"description": "Permissions Shared",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"nu-art",
|
|
12
12
|
"permissions",
|
|
13
13
|
"saml",
|
|
14
|
-
"thunderstorm",
|
|
15
14
|
"typescript",
|
|
16
15
|
"user-account"
|
|
17
16
|
],
|
|
@@ -35,11 +34,10 @@
|
|
|
35
34
|
"test": "ts-mocha -w -p src/test/tsconfig.json --timeout 0 --inspect=8107 --watch-files '**/*.ts' src/test/__all-tests.ts"
|
|
36
35
|
},
|
|
37
36
|
"dependencies": {
|
|
38
|
-
"@nu-art/ts-common": "0.
|
|
39
|
-
"@nu-art/firebase-shared": "0.
|
|
40
|
-
"@nu-art/
|
|
41
|
-
"@nu-art/
|
|
42
|
-
"@nu-art/ts-styles": "0.401.9",
|
|
37
|
+
"@nu-art/ts-common": "0.500.0",
|
|
38
|
+
"@nu-art/firebase-shared": "0.500.0",
|
|
39
|
+
"@nu-art/user-account-shared": "0.500.0",
|
|
40
|
+
"@nu-art/ts-styles": "0.500.0",
|
|
43
41
|
"firebase": "^11.9.0",
|
|
44
42
|
"firebase-admin": "13.4.0",
|
|
45
43
|
"firebase-functions": "6.3.2",
|
|
@@ -48,7 +46,9 @@
|
|
|
48
46
|
"react-router-dom": "^6.9.0",
|
|
49
47
|
"moment": "^2.29.4",
|
|
50
48
|
"saml2-js": "^4.0.1",
|
|
51
|
-
"express": "^4.18.2"
|
|
49
|
+
"express": "^4.18.2",
|
|
50
|
+
"@nu-art/api-types": "{{THUNDERSTORM_VERSION}}",
|
|
51
|
+
"@nu-art/db-api-shared": "0.500.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^18.0.0",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/chai": "^4.3.4",
|
|
60
60
|
"@types/mocha": "^10.0.1",
|
|
61
61
|
"@types/history": "^4.7.2",
|
|
62
|
+
"@types/request": "^2.48.1",
|
|
62
63
|
"@types/saml2-js": "^1.6.8"
|
|
63
64
|
},
|
|
64
65
|
"unitConfig": {
|
package/path-utils.d.ts
ADDED
package/path-utils.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system
|
|
3
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
4
|
+
* Licensed under the Apache License, Version 2.0
|
|
5
|
+
*/
|
|
6
|
+
/** Removes a leading '/' from path if present. Used for normalizing API paths. */
|
|
7
|
+
export const trimStartingForwardSlash = (path) => path.startsWith('/') ? path.substring(1) : path;
|
package/permission-keys.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const PermissionKey_DeveloperViewer = "permission-key--developer-viewer";
|
|
2
2
|
export declare const PermissionKey_DeveloperWriter = "permission-key--developer-editor";
|
|
3
3
|
export declare const PermissionKey_DeveloperAdmin = "permission-key--developer-admin";
|
|
4
|
-
export declare const PermissionKey_AccountManagementAdmin = "permission-key--account-management-admin";
|
package/permission-keys.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export const PermissionKey_DeveloperViewer = 'permission-key--developer-viewer';
|
|
2
2
|
export const PermissionKey_DeveloperWriter = 'permission-key--developer-editor';
|
|
3
3
|
export const PermissionKey_DeveloperAdmin = 'permission-key--developer-admin';
|
|
4
|
-
export const PermissionKey_AccountManagementAdmin = 'permission-key--account-management-admin';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Type-only brand for PermissionScope; use definePermissionScope() to create valid instances. */
|
|
2
|
+
declare const PermissionScopeBrand: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Branded permission scope for function-based permissions.
|
|
5
|
+
* Only instances created via definePermissionScope() are valid.
|
|
6
|
+
*/
|
|
7
|
+
export type PermissionScope = {
|
|
8
|
+
readonly key: string;
|
|
9
|
+
readonly values: readonly string[];
|
|
10
|
+
readonly [PermissionScopeBrand]: true;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a frozen, branded permission scope. Use this to define scopes
|
|
14
|
+
* for the @RequirePermission decorator (e.g. pathway: read, write, delete, admin).
|
|
15
|
+
*/
|
|
16
|
+
export declare function definePermissionScope<K extends string, V extends readonly string[]>(key: K, values: V): PermissionScope & {
|
|
17
|
+
key: K;
|
|
18
|
+
values: V;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system, define access level for each of
|
|
3
|
+
* your server apis, and restrict users by giving them access levels
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Creates a frozen, branded permission scope. Use this to define scopes
|
|
21
|
+
* for the @RequirePermission decorator (e.g. pathway: read, write, delete, admin).
|
|
22
|
+
*/
|
|
23
|
+
export function definePermissionScope(key, values) {
|
|
24
|
+
return Object.freeze({ key, values });
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for modules that participate in project setup (e.g. create default projects, domains, keys).
|
|
3
|
+
* The app wires implementations to its action-processor or calls __performProjectSetup() when needed.
|
|
4
|
+
*/
|
|
5
|
+
export interface PerformProjectSetup {
|
|
6
|
+
__performProjectSetup(): {
|
|
7
|
+
priority: number;
|
|
8
|
+
processor: () => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
}
|
package/project-setup.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Definition for a service account to be created during project setup.
|
|
3
|
+
* The app provides a list via setServiceAccountsProvider; permissions uses it to create permission users and wire tokens.
|
|
4
|
+
*/
|
|
5
|
+
export type ServiceAccountDef = {
|
|
6
|
+
email: string;
|
|
7
|
+
description: string;
|
|
8
|
+
groupIds?: string[];
|
|
9
|
+
moduleName: string;
|
|
10
|
+
ttl?: number;
|
|
11
|
+
};
|
package/types.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { TypedKeyValue, TypedMap
|
|
2
|
-
import {
|
|
1
|
+
import { TypedKeyValue, TypedMap } from '@nu-art/ts-common';
|
|
2
|
+
import { DatabaseDef_PermissionAccessLevel } from './_entity/permission-access-level/types.js';
|
|
3
|
+
import { DatabaseDef_PermissionDomain } from './_entity/permission-domain/types.js';
|
|
4
|
+
import { DatabaseDef_PermissionGroup } from './_entity/permission-group/types.js';
|
|
5
|
+
import { DomainToLevelValueMap } from './_entity/permission-api/types.js';
|
|
3
6
|
export type PermissionKey = string;
|
|
4
7
|
export declare const Const_PermissionKeyType = "permission-key";
|
|
5
8
|
export type PermissionKeyType = typeof Const_PermissionKeyType;
|
|
6
9
|
export type DefaultDef_Api = {
|
|
7
10
|
path: string;
|
|
8
11
|
accessLevel: string;
|
|
9
|
-
domainId?:
|
|
12
|
+
domainId?: DatabaseDef_PermissionDomain['id'];
|
|
10
13
|
};
|
|
11
14
|
export type DefaultDef_GeneratedApi = {
|
|
12
15
|
domain: string;
|
|
@@ -14,7 +17,7 @@ export type DefaultDef_GeneratedApi = {
|
|
|
14
17
|
};
|
|
15
18
|
export type DB_PermissionKeyData = {
|
|
16
19
|
type: PermissionKeyType;
|
|
17
|
-
accessLevelIds:
|
|
20
|
+
accessLevelIds: DatabaseDef_PermissionAccessLevel['id'][];
|
|
18
21
|
_accessLevels: DomainToLevelValueMap;
|
|
19
22
|
};
|
|
20
23
|
export type PreDBAccessLevel = {
|
|
@@ -22,13 +25,13 @@ export type PreDBAccessLevel = {
|
|
|
22
25
|
value: number;
|
|
23
26
|
};
|
|
24
27
|
export type DefaultDef_AccessLevel = {
|
|
25
|
-
_id:
|
|
28
|
+
_id: DatabaseDef_PermissionAccessLevel['id'];
|
|
26
29
|
name: string;
|
|
27
30
|
uiLabel: string;
|
|
28
31
|
value: number;
|
|
29
32
|
};
|
|
30
33
|
export type DefaultDef_Group = {
|
|
31
|
-
_id:
|
|
34
|
+
_id: DatabaseDef_PermissionGroup['id'];
|
|
32
35
|
name: string;
|
|
33
36
|
uiLabel: string;
|
|
34
37
|
accessLevels: {
|