Skip to content

Commit 4c502a1

Browse files
committed
refactor(plugin-sharing): one spelling of the platform-object test
effectiveSharingModel's isSystem-or-sys_ test becomes isPlatformObjectSchema, which the shareable-objects order reads too, so the object-schema isSystem read stays where the system-context census already classifies it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2f62c1GYk6XzbdtCa4
1 parent 092b2cc commit 4c502a1

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎packages/plugins/plugin-sharing/src/shareable-objects.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
* ## Order
2222
*
2323
* Business objects first, then platform (system) objects; inside each group
24-
* by label, then by machine name. A platform object is one the registry marks
25-
* `isSystem`, or one named with the platform's `sys_` prefix (AGENTS.md Prime
26-
* Directive 6: a module prefix is part of the name).
24+
* by label, then by machine name. A platform object is the one test
25+
* `effectiveSharingModel` already asks (`isPlatformObjectSchema`): the registry
26+
* marks it `isSystem`, or its name carries the platform's `sys_` prefix.
2727
*/
2828

29+
import { isPlatformObjectSchema } from './sharing-service.js';
30+
2931
/** One object a sharing rule can take effect on. */
3032
export interface ShareableObject {
3133
/** The object's machine name — the value `sys_sharing_rule.object_name` stores. */
@@ -69,15 +71,14 @@ export class SharingRulesNotRunningError extends Error {
6971
interface ObjectConfigShape {
7072
name?: unknown;
7173
label?: unknown;
72-
isSystem?: unknown;
7374
}
7475

7576
function labelOf(name: string, config: ObjectConfigShape): string {
7677
return typeof config.label === 'string' && config.label.trim().length > 0 ? config.label : name;
7778
}
7879

7980
function isPlatformObject(name: string, config: ObjectConfigShape): boolean {
80-
return config.isSystem === true || name.startsWith('sys_');
81+
return isPlatformObjectSchema(config) || name.startsWith('sys_');
8182
}
8283

8384
function byGroupThenLabel(a: ShareableObject, b: ShareableObject): number {

‎packages/plugins/plugin-sharing/src/sharing-service.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,20 @@ export function effectiveSharingModel(schema: any): 'private' | 'read' | 'public
220220
if (m === 'private') return 'private';
221221
if (m === 'public_read') return 'read';
222222
if (m === 'public_read_write' || m === 'controlled_by_parent') return 'public';
223-
if (m == null) {
224-
const isSystem = schema?.isSystem === true || String(schema?.name ?? '').startsWith('sys_');
225-
return isSystem ? 'public' : 'private';
226-
}
223+
if (m == null) return isPlatformObjectSchema(schema) ? 'public' : 'private';
227224
return 'private';
228225
}
229226

227+
/**
228+
* A platform (system) object: one the registry marks `isSystem`, or one named
229+
* with the platform's `sys_` prefix. The one spelling of that test, read by
230+
* {@link effectiveSharingModel}'s default and by the sharing-rule object
231+
* picker's ordering (`shareable-objects.ts`).
232+
*/
233+
export function isPlatformObjectSchema(schema: any): boolean {
234+
return schema?.isSystem === true || String(schema?.name ?? '').startsWith('sys_');
235+
}
236+
230237
/**
231238
* [Ruling of record 6355206139, letter B] The org-wide default THIS principal
232239
* meets on `object`: {@link effectiveSharingModel}, floored to owner_only for

0 commit comments

Comments
 (0)