-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsharing-rules.ts
More file actions
65 lines (61 loc) · 2.26 KB
/
Copy pathsharing-rules.ts
File metadata and controls
65 lines (61 loc) · 2.26 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineSharingRule } from '@objectstack/spec/security';
/**
* Criteria-based sharing: share high-value opportunities (amount > 100000)
* with the Sales Manager role so managers always have read access to big deals.
*/
export const HighValueOpportunitySharingRule = defineSharingRule({
type: 'criteria',
name: 'share_high_value_opps_with_managers',
label: 'High-Value Deals → Sales Managers',
description: 'Automatically share opportunities over $100,000 with all Sales Managers.',
object: 'crm_opportunity',
condition: 'record.amount > 100000',
accessLevel: 'edit',
sharedWith: {
type: 'position',
value: 'sales_manager',
},
active: true,
});
/**
* Criteria-based sharing: in-flight leads (not yet converted or disqualified)
* are shared read-only with Sales Managers for coaching visibility.
*
* Replaces the retired owner-based `share_rep_leads_with_manager` rule:
* `type: 'owner'` (`ownedBy`) no longer parses — it depended on live position
* membership and was silently skipped at seed time (ADR-0078). The enforced
* criteria form scopes the same coaching set by pipeline state instead.
*/
export const RepLeadSharingRule = defineSharingRule({
type: 'criteria',
name: 'share_active_leads_with_manager',
label: 'Active Leads → Manager (read-only)',
description: 'Share in-flight (not converted/disqualified) leads with Sales Managers for coaching visibility.',
object: 'crm_lead',
condition: "record.status != 'converted' && record.status != 'disqualified'",
accessLevel: 'read',
sharedWith: {
type: 'position',
value: 'sales_manager',
},
active: true,
});
/**
* Criteria-based: share activities linked to won deals with the whole
* Sales team so everyone can learn from successful engagement patterns.
*/
export const WonDealActivitySharingRule = defineSharingRule({
type: 'criteria',
name: 'share_won_deal_activities',
label: 'Won-Deal Activities → All Sales',
description: 'Share activities attached to closed-won opportunities across the sales team.',
object: 'crm_activity',
condition: "record.status == 'completed'",
accessLevel: 'read',
sharedWith: {
type: 'position',
value: 'sales_rep',
},
active: true,
});