-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsys-user-permission-set.object.ts
More file actions
91 lines (80 loc) · 2.61 KB
/
Copy pathsys-user-permission-set.object.ts
File metadata and controls
91 lines (80 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* sys_user_permission_set — User ↔ PermissionSet assignment.
*
* Salesforce-style additive permission grant: a user may be assigned any
* number of `sys_permission_set` rows, optionally scoped to a specific
* organization. The runtime resolver (`resolveExecutionContext` in
* `@objectstack/runtime`) reads this table when building the per-request
* `ExecutionContext.permissions[]`.
*
* Uniqueness is `(user_id, permission_set_id, organization_id)` so the
* same permission set can be granted independently in each org context
* the user belongs to.
*
* @namespace sys
*/
export const SysUserPermissionSet = ObjectSchema.create({
name: 'sys_user_permission_set',
label: 'User Permission Set',
pluralLabel: 'User Permission Sets',
icon: 'user-check',
isSystem: true,
managedBy: 'system',
description: 'Direct assignment of a permission set to a user (optionally scoped to an organization).',
titleFormat: '{user_id} → {permission_set_id}',
highlightFields: ['user_id', 'permission_set_id', 'organization_id'],
fields: {
id: Field.text({
label: 'Assignment ID',
required: true,
readonly: true,
description: 'UUID of the assignment.',
}),
user_id: Field.lookup('sys_user', {
label: 'User',
required: true,
description: 'Foreign key to sys_user.',
}),
permission_set_id: Field.lookup('sys_permission_set', {
label: 'Permission Set',
required: true,
description: 'Foreign key to sys_permission_set.',
}),
organization_id: Field.lookup('sys_organization', {
label: 'Organization',
required: false,
description: 'Optional organization scope. NULL = applies in every org context.',
}),
granted_by: Field.lookup('sys_user', {
label: 'Granted By',
required: false,
description: 'User who granted this permission set.',
}),
created_at: Field.datetime({
label: 'Created At',
defaultValue: 'NOW()',
readonly: true,
}),
updated_at: Field.datetime({
label: 'Updated At',
defaultValue: 'NOW()',
readonly: true,
}),
},
indexes: [
{ fields: ['user_id', 'permission_set_id', 'organization_id'], unique: true },
{ fields: ['user_id'] },
{ fields: ['organization_id'] },
{ fields: ['permission_set_id'] },
],
enable: {
trackHistory: true,
searchable: true,
apiEnabled: true,
apiMethods: ['get', 'list', 'create', 'update', 'delete'],
trash: true,
mru: false,
},
});