@company-semantics/contracts 1.1.0 → 1.2.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/package.json +1 -1
- package/src/resource-keys.ts +29 -0
package/package.json
CHANGED
package/src/resource-keys.ts
CHANGED
|
@@ -28,6 +28,13 @@ export type ResourceKey =
|
|
|
28
28
|
| { type: 'deletionEligibility'; orgId: string }
|
|
29
29
|
| { type: 'transferOwnership'; orgId: string }
|
|
30
30
|
| { type: 'companyMdDocs'; orgId: string }
|
|
31
|
+
// OrgUnit canonical model (ADR-BE-120) — Phase 2 Wave 4
|
|
32
|
+
| { type: 'orgTree'; orgId: string }
|
|
33
|
+
| { type: 'orgLevelConfig'; orgId: string }
|
|
34
|
+
| { type: 'orgUnit'; orgId: string; unitId: string }
|
|
35
|
+
| { type: 'orgUnitChildren'; orgId: string; unitId: string }
|
|
36
|
+
| { type: 'orgUnitAncestors'; orgId: string; unitId: string }
|
|
37
|
+
| { type: 'orgUnitMemberships'; orgId: string; unitId: string }
|
|
31
38
|
// User-scoped
|
|
32
39
|
| { type: 'dismissedBanners'; userId: string }
|
|
33
40
|
| { type: 'userOrgs'; userId: string }
|
|
@@ -54,6 +61,7 @@ const ORG_SCOPED_TYPES = [
|
|
|
54
61
|
'members', 'departments', 'chats', 'teams', 'integrations', 'invites',
|
|
55
62
|
'auditEvents', 'timeline', 'workspace', 'workspaceDomains', 'authSettings',
|
|
56
63
|
'billing', 'aiUsage', 'deletionEligibility', 'transferOwnership', 'companyMdDocs',
|
|
64
|
+
'orgTree', 'orgLevelConfig',
|
|
57
65
|
] as const;
|
|
58
66
|
|
|
59
67
|
const USER_SCOPED_TYPES = ['dismissedBanners', 'userOrgs', 'sessions', 'viewer'] as const;
|
|
@@ -82,6 +90,13 @@ export function toQueryKey(key: ResourceKey): readonly string[] {
|
|
|
82
90
|
case 'companyMdContextBank':
|
|
83
91
|
return [key.type, key.orgId, key.slug] as const;
|
|
84
92
|
|
|
93
|
+
// OrgUnit identity keys (ADR-BE-120)
|
|
94
|
+
case 'orgUnit':
|
|
95
|
+
case 'orgUnitChildren':
|
|
96
|
+
case 'orgUnitAncestors':
|
|
97
|
+
case 'orgUnitMemberships':
|
|
98
|
+
return [key.type, key.orgId, key.unitId] as const;
|
|
99
|
+
|
|
85
100
|
// User-scoped
|
|
86
101
|
case 'dismissedBanners':
|
|
87
102
|
case 'userOrgs':
|
|
@@ -106,6 +121,8 @@ export function toQueryKey(key: ResourceKey): readonly string[] {
|
|
|
106
121
|
case 'deletionEligibility':
|
|
107
122
|
case 'transferOwnership':
|
|
108
123
|
case 'companyMdDocs':
|
|
124
|
+
case 'orgTree':
|
|
125
|
+
case 'orgLevelConfig':
|
|
109
126
|
return [key.type, key.orgId] as const;
|
|
110
127
|
|
|
111
128
|
default: {
|
|
@@ -134,6 +151,10 @@ export function fromQueryKey(queryKey: readonly string[]): ResourceKey {
|
|
|
134
151
|
chat: 'chatId',
|
|
135
152
|
companyMdDoc: 'slug',
|
|
136
153
|
companyMdContextBank: 'slug',
|
|
154
|
+
orgUnit: 'unitId',
|
|
155
|
+
orgUnitChildren: 'unitId',
|
|
156
|
+
orgUnitAncestors: 'unitId',
|
|
157
|
+
orgUnitMemberships: 'unitId',
|
|
137
158
|
};
|
|
138
159
|
|
|
139
160
|
if (type in identityFields) {
|
|
@@ -172,6 +193,13 @@ export const resourceRelationships: Record<string, string[]> = {
|
|
|
172
193
|
team: ['teams'],
|
|
173
194
|
companyMdDocs: ['companyMdDoc'],
|
|
174
195
|
companyMdDoc: ['companyMdDocs'],
|
|
196
|
+
// OrgUnit: reparent/create/archive invalidates the tree view of the whole org;
|
|
197
|
+
// membership mutations invalidate the unit + its memberships list.
|
|
198
|
+
orgTree: ['orgUnit', 'orgUnitChildren', 'orgUnitAncestors'],
|
|
199
|
+
orgUnit: ['orgTree'],
|
|
200
|
+
orgUnitChildren: ['orgTree'],
|
|
201
|
+
orgUnitAncestors: ['orgTree'],
|
|
202
|
+
orgUnitMemberships: ['orgUnit'],
|
|
175
203
|
};
|
|
176
204
|
|
|
177
205
|
/**
|
|
@@ -200,6 +228,7 @@ export function matchesResourceKey(queryKey: readonly unknown[], targetKey: Reso
|
|
|
200
228
|
if ('departmentId' in parsed && 'departmentId' in targetKey && parsed.departmentId !== targetKey.departmentId) return false;
|
|
201
229
|
if ('chatId' in parsed && 'chatId' in targetKey && parsed.chatId !== targetKey.chatId) return false;
|
|
202
230
|
if ('slug' in parsed && 'slug' in targetKey && parsed.slug !== targetKey.slug) return false;
|
|
231
|
+
if ('unitId' in parsed && 'unitId' in targetKey && parsed.unitId !== targetKey.unitId) return false;
|
|
203
232
|
|
|
204
233
|
return true;
|
|
205
234
|
}
|