@cclabsnz/sf-core 0.7.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -12,6 +12,36 @@ CycloneDX SBOM for the build.
12
12
 
13
13
  Nothing yet.
14
14
 
15
+ ## [0.9.0] — 2026-10-12
16
+
17
+ ### Changed
18
+
19
+ - **The `integration` node kind is owned by sf-orgintel, not sf-orgviz.** An external system an
20
+ org calls is found where the call is made: Apex callouts, and Named Credential, Remote Site and
21
+ Integration Procedure hops. sf-orgintel's anatomy reads those; sf-orgviz extraction never
22
+ emitted an `integration` node. `mergeGraphs` now refuses an sf-orgviz fragment emitting one
23
+ (`GRAPH_MERGE_KIND_NOT_OWNED`) and accepts an sf-orgintel fragment that does. Both producers
24
+ must merge on sf-core 0.9.0 or later, since ownership is checked by the merging side.
25
+
26
+ ## [0.8.0] — 2026-10-11
27
+
28
+ ### Added
29
+
30
+ - **`classifyObject(name, facts, targets)`** decides an object's role (`entity`, `companion`,
31
+ `actor`, `qualifier`, `setup`, `configuration`, `event`, `external`, `reference` or
32
+ `unclassified`) from platform evidence: `describeGlobal`'s `associateParentEntity`, layout and
33
+ trigger capability, custom-setting status, the internal sharing model, the system fields'
34
+ targets, and whether production automation only reads it. It never recognises an object by name,
35
+ every decision carries its evidence, and an object whose facts were not read is `unclassified`
36
+ rather than defaulted. Exports `ObjectRole`, `ObjectFacts`, `PlatformTargets` and
37
+ `ObjectRoleDecision`. Specified in sf-orgintel `docs/OBJECT_ROLES_SPEC.md`.
38
+
39
+ ### Deprecated
40
+
41
+ - **`roleOf`** recognises objects by name and calls everything else business. Use
42
+ `classifyObject`. It stays for one minor version so the two tools that call it can migrate
43
+ together.
44
+
15
45
  ## [0.7.0] — 2026-09-22
16
46
 
17
47
  ### Added
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Object roles from platform evidence, not names. Specified in sf-orgintel
3
+ * `docs/OBJECT_ROLES_SPEC.md` section 2.2.
4
+ *
5
+ * `roleOf` recognised about 45 objects by name and called everything else business, so on a real
6
+ * Health Cloud org `User` and `RecordType` ranked among the most-coupled objects, `AccountShare`
7
+ * stood beside `Account` as a peer, and industry objects landed in whichever bucket their names
8
+ * happened to fit. This classifier asks the platform instead: what `describeGlobal` and
9
+ * `EntityDefinition` report about every object on every org, what the system fields point at, and
10
+ * how production automation uses the object. No rule here knows an object by name; the only names
11
+ * are the ones the caller read from the system fields' `referenceTo`.
12
+ *
13
+ * Every decision carries the evidence that made it, and an object whose facts were not read is
14
+ * `unclassified` rather than defaulted, the same rule as the rest of this codebase: a guess must
15
+ * not read as a measurement.
16
+ */
17
+ export type ObjectRole =
18
+ /** Business data: a record a process is about. */
19
+ 'entity'
20
+ /** A Share, History or Feed-style object that belongs to a parent, folded into it. */
21
+ | 'companion'
22
+ /** Who owns, creates or changes records: the targets of OwnerId, CreatedById, LastModifiedById. */
23
+ | 'actor'
24
+ /** Which variant of another object a record is: the target of RecordTypeId. */
25
+ | 'qualifier'
26
+ /** Platform setup: an object that can have neither a page layout nor an Apex trigger. */
27
+ | 'setup'
28
+ /** Custom metadata and custom settings: configuration read by behaviour. */
29
+ | 'configuration'
30
+ /** Platform events. */
31
+ | 'event'
32
+ /** External objects. */
33
+ | 'external'
34
+ /** Data production automation only ever reads, shared org-wide as read-only. */
35
+ | 'reference'
36
+ /** The facts that would decide it were not read. */
37
+ | 'unclassified';
38
+ /**
39
+ * What the platform reports about one object. Every field is optional because each comes from a
40
+ * read that can be refused; an absent field means "not read", never "false".
41
+ */
42
+ export interface ObjectFacts {
43
+ /** `describeGlobal` `associateParentEntity`: the object a Share, History, Feed and so on belongs to. */
44
+ associateParentEntity?: string | null;
45
+ /** `EntityDefinition.IsLayoutable` or `describe` `layoutable`. */
46
+ layoutable?: boolean | null;
47
+ /** `EntityDefinition.IsApexTriggerable` or `describe` `triggerable`. */
48
+ triggerable?: boolean | null;
49
+ /** `describe` `customSetting`. */
50
+ customSetting?: boolean | null;
51
+ /** `EntityDefinition.InternalSharingModel`, e.g. `Private`, `Read`, `ControlledByParent`. */
52
+ sharingModel?: string | null;
53
+ /** True when production automation touches the object and only ever reads it. */
54
+ readOnlyInAutomation?: boolean | null;
55
+ }
56
+ /** The objects the platform's system fields point at, read from `describe`'s `referenceTo`. */
57
+ export interface PlatformTargets {
58
+ /** Targets of `OwnerId`, `CreatedById` and `LastModifiedById`. */
59
+ actors: ReadonlySet<string>;
60
+ /** Targets of `RecordTypeId`. */
61
+ qualifiers: ReadonlySet<string>;
62
+ }
63
+ export interface ObjectRoleDecision {
64
+ role: ObjectRole;
65
+ /** The fact that decided the role, in words a reviewer can check. */
66
+ evidence: string;
67
+ /** For a companion, the object it folds into. */
68
+ parent?: string;
69
+ }
70
+ /** First matching rule wins, in the order OBJECT_ROLES_SPEC 2.2 lists them. */
71
+ export declare function classifyObject(name: string, facts: ObjectFacts | undefined, targets: PlatformTargets): ObjectRoleDecision;
72
+ //# sourceMappingURL=classifyObject.d.ts.map
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Object roles from platform evidence, not names. Specified in sf-orgintel
3
+ * `docs/OBJECT_ROLES_SPEC.md` section 2.2.
4
+ *
5
+ * `roleOf` recognised about 45 objects by name and called everything else business, so on a real
6
+ * Health Cloud org `User` and `RecordType` ranked among the most-coupled objects, `AccountShare`
7
+ * stood beside `Account` as a peer, and industry objects landed in whichever bucket their names
8
+ * happened to fit. This classifier asks the platform instead: what `describeGlobal` and
9
+ * `EntityDefinition` report about every object on every org, what the system fields point at, and
10
+ * how production automation uses the object. No rule here knows an object by name; the only names
11
+ * are the ones the caller read from the system fields' `referenceTo`.
12
+ *
13
+ * Every decision carries the evidence that made it, and an object whose facts were not read is
14
+ * `unclassified` rather than defaulted, the same rule as the rest of this codebase: a guess must
15
+ * not read as a measurement.
16
+ */
17
+ /** API-name suffixes the platform defines, so they count as evidence rather than convention. */
18
+ const SUFFIX_ROLES = [
19
+ ['__mdt', 'configuration', 'custom metadata type (__mdt)'],
20
+ ['__e', 'event', 'platform event (__e)'],
21
+ ['__x', 'external', 'external object (__x)'],
22
+ ];
23
+ /** First matching rule wins, in the order OBJECT_ROLES_SPEC 2.2 lists them. */
24
+ export function classifyObject(name, facts, targets) {
25
+ const f = facts ?? {};
26
+ const noLayoutNoTriggers = f.layoutable === false && f.triggerable === false;
27
+ // A parent alone is not enough: the platform also gives CaseComment a parent, and CaseComment
28
+ // is layout-able, triggerable business data.
29
+ if (f.associateParentEntity && noLayoutNoTriggers) {
30
+ return {
31
+ role: 'companion',
32
+ parent: f.associateParentEntity,
33
+ evidence: `the platform names ${f.associateParentEntity} as its parent, and it has no layout or triggers`,
34
+ };
35
+ }
36
+ for (const [suffix, role, what] of SUFFIX_ROLES) {
37
+ if (name.endsWith(suffix))
38
+ return { role, evidence: what };
39
+ }
40
+ if (f.customSetting)
41
+ return { role: 'configuration', evidence: 'custom setting' };
42
+ if (targets.actors.has(name)) {
43
+ return { role: 'actor', evidence: 'target of the OwnerId, CreatedById or LastModifiedById system fields' };
44
+ }
45
+ if (targets.qualifiers.has(name))
46
+ return { role: 'qualifier', evidence: 'target of the RecordTypeId system field' };
47
+ if (noLayoutNoTriggers)
48
+ return { role: 'setup', evidence: 'can have neither a page layout nor an Apex trigger' };
49
+ // Everything below needs the capability facts. Without them the object is not known to be
50
+ // business data, and saying so beats defaulting it there.
51
+ if (f.layoutable == null || f.triggerable == null) {
52
+ return { role: 'unclassified', evidence: 'its layout and trigger capability were not read' };
53
+ }
54
+ if (f.readOnlyInAutomation === true && f.sharingModel === 'Read') {
55
+ return { role: 'reference', evidence: 'production automation only reads it, and its org-wide default is Read' };
56
+ }
57
+ if (f.sharingModel === 'ControlledByParent') {
58
+ return { role: 'entity', evidence: 'business data; a detail of its parent (sharing ControlledByParent)' };
59
+ }
60
+ return { role: 'entity', evidence: 'business data: can have a page layout and Apex triggers' };
61
+ }
62
+ //# sourceMappingURL=classifyObject.js.map
@@ -5,5 +5,6 @@ export * from './schema.js';
5
5
  export * from './validate.js';
6
6
  export * from './coverage.js';
7
7
  export * from './roleOf.js';
8
+ export * from './classifyObject.js';
8
9
  export * from './merge.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -6,5 +6,6 @@ export * from './schema.js';
6
6
  export * from './validate.js';
7
7
  export * from './coverage.js';
8
8
  export * from './roleOf.js';
9
+ export * from './classifyObject.js';
9
10
  export * from './merge.js';
10
11
  //# sourceMappingURL=index.js.map
@@ -38,7 +38,7 @@ export declare const GRAPH_KIND_TABLE: {
38
38
  readonly integration: {
39
39
  readonly layer: "landscape";
40
40
  readonly level: 2;
41
- readonly owner: "orgviz";
41
+ readonly owner: "orgintel";
42
42
  };
43
43
  readonly site: {
44
44
  readonly layer: "landscape";
@@ -9,7 +9,10 @@ export const GRAPH_KIND_TABLE = {
9
9
  // Level 2 — concrete entities.
10
10
  connectedApp: { layer: 'landscape', level: 2, owner: 'orgviz' },
11
11
  namedCredential: { layer: 'landscape', level: 2, owner: 'orgviz' },
12
- integration: { layer: 'landscape', level: 2, owner: 'orgviz' },
12
+ // An external system the org calls. Owned by sf-orgintel since 0.9.0: its anatomy finds them,
13
+ // in Apex callouts and Named Credential, Remote Site and Integration Procedure hops. sf-orgviz
14
+ // extraction never emitted one.
15
+ integration: { layer: 'landscape', level: 2, owner: 'orgintel' },
13
16
  site: { layer: 'landscape', level: 2, owner: 'orgintel' },
14
17
  product: { layer: 'landscape', level: 2, owner: 'orgintel' },
15
18
  ssoConfig: { layer: 'landscape', level: 2, owner: 'orgintel' },
@@ -12,6 +12,12 @@
12
12
  */
13
13
  import type { ObjectLayer } from '../schemas/index.js';
14
14
  export declare const OBJECT_LAYER_DESCRIPTIONS: Readonly<Record<ObjectLayer, string>>;
15
- /** Which layer an object belongs to. Unrecognised objects are business, never hidden. */
15
+ /**
16
+ * Which layer an object belongs to. Unrecognised objects are business, never hidden.
17
+ *
18
+ * @deprecated Recognises objects by name and defaults everything else to business. Use
19
+ * `classifyObject`, which decides from platform evidence. Kept for one minor version so sf-orgviz
20
+ * and sf-orgintel do not disagree mid-migration.
21
+ */
16
22
  export declare function roleOf(object: string): ObjectLayer;
17
23
  //# sourceMappingURL=roleOf.d.ts.map
@@ -37,7 +37,13 @@ const SECURITY_OBJECTS = new Set([
37
37
  const CONTENT_OBJECTS = new Set([
38
38
  'Attachment', 'Document', 'EmailMessage', 'EmailTemplate', 'Note',
39
39
  ]);
40
- /** Which layer an object belongs to. Unrecognised objects are business, never hidden. */
40
+ /**
41
+ * Which layer an object belongs to. Unrecognised objects are business, never hidden.
42
+ *
43
+ * @deprecated Recognises objects by name and defaults everything else to business. Use
44
+ * `classifyObject`, which decides from platform evidence. Kept for one minor version so sf-orgviz
45
+ * and sf-orgintel do not disagree mid-migration.
46
+ */
41
47
  export function roleOf(object) {
42
48
  if (SECURITY_OBJECTS.has(object))
43
49
  return 'security';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-core",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Shared platform layer for CloudCounsel Salesforce sf plugins — API clients, org context, event log pull, report shell, and versioned IR schemas.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  ],
52
52
  "repository": {
53
53
  "type": "git",
54
- "url": "https://github.com/cclabsnz/sf-core.git"
54
+ "url": "git+https://github.com/cclabsnz/sf-core.git"
55
55
  },
56
56
  "homepage": "https://github.com/cclabsnz/sf-core#readme",
57
57
  "bugs": {
@@ -73,7 +73,7 @@
73
73
  "pnpm": {
74
74
  "overrides": {
75
75
  "form-data": "^4.0.6",
76
- "js-yaml@3": "^3.15.1",
76
+ "js-yaml@3": "^3.15.2",
77
77
  "handlebars": "^4.7.9",
78
78
  "brace-expansion": "^5.0.9",
79
79
  "fast-uri@3": "^3.1.6"