@cclabsnz/sf-core 0.2.0 → 0.3.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.
@@ -12,18 +12,29 @@ export declare class EventBaselineStore {
12
12
  * verified case had two AuraRequest rows for the same hour.
13
13
  */
14
14
  pathFor(orgId: string, eventType: string, logDate: string, id: string, hour?: string): string;
15
- /** True when this EventLogFile is already on disk — the dedup / idempotency check. */
15
+ /**
16
+ * True when this EventLogFile is already captured — the dedup / idempotency check.
17
+ *
18
+ * Requires a non-empty file, not merely an existing one. A zero-byte file is what a run
19
+ * killed between create and write leaves behind, and treating that as captured would retire
20
+ * the row permanently: every later run skips it, and the gap never appears in any manifest.
21
+ */
16
22
  has(orgId: string, eventType: string, logDate: string, id: string, hour?: string): boolean;
17
23
  /** Write a CSV body verbatim; returns the saved path. Best-effort. */
18
24
  save(orgId: string, eventType: string, logDate: string, id: string, body: string, hour?: string): string;
19
25
  /** Absolute path the NDJSON for one Real-Time Event object-hour is (or would be) stored at. */
20
26
  realtimePathFor(orgId: string, objectName: string, logDate: string, hour: string): string;
21
- /** True when this object-hour already holds a non-empty NDJSON file. */
27
+ /** True when this object-hour already holds a complete NDJSON file. */
22
28
  hasRealtime(orgId: string, objectName: string, logDate: string, hour: string): boolean;
23
29
  /**
24
- * Write RTE rows as NDJSON — one JSON object per line, so a run killed mid-write still
25
- * leaves a parseable file up to the last complete line. Same failure-tolerance rationale as
26
- * streaming raw CSV bytes to disk before parsing them.
30
+ * Write RTE rows as NDJSON — one JSON object per line, so the file stays parseable line by
31
+ * line and a reader never has to hold the whole set in memory.
32
+ *
33
+ * Written to a temporary file and renamed into place. The earlier rationale — that a
34
+ * half-written NDJSON is still parseable up to the last complete line — is true but beside
35
+ * the point: `hasRealtime` cannot distinguish a truncated file from a complete one, so a
36
+ * partial write would be skipped by every later run and silently pass as full coverage.
37
+ * Rename is atomic within a filesystem, so the file is either absent or whole.
27
38
  */
28
39
  saveRealtime(orgId: string, objectName: string, logDate: string, hour: string, rows: readonly unknown[]): string;
29
40
  /**
@@ -27,7 +27,7 @@ export class EventBaselineStore {
27
27
  }
28
28
  /** The per-org base directory logs for this org are stored under. */
29
29
  orgDir(orgId) {
30
- return path.join(this.root, orgId);
30
+ return path.join(this.root, segment(orgId));
31
31
  }
32
32
  /**
33
33
  * Absolute path a given log file is (or would be) stored at. Pass `hour` ('00'–'23', UTC)
@@ -37,20 +37,26 @@ export class EventBaselineStore {
37
37
  * verified case had two AuraRequest rows for the same hour.
38
38
  */
39
39
  pathFor(orgId, eventType, logDate, id, hour) {
40
+ const [o, t, d, i] = [orgId, eventType, logDate, id].map(segment);
40
41
  return hour === undefined
41
- ? path.join(this.root, orgId, eventType, `${logDate}-${id}.csv`)
42
- : path.join(this.root, orgId, eventType, logDate, `${padHour(hour)}-${id}.csv`);
42
+ ? path.join(this.root, o, t, `${d}-${i}.csv`)
43
+ : path.join(this.root, o, t, d, `${padHour(hour)}-${i}.csv`);
43
44
  }
44
- /** True when this EventLogFile is already on disk — the dedup / idempotency check. */
45
+ /**
46
+ * True when this EventLogFile is already captured — the dedup / idempotency check.
47
+ *
48
+ * Requires a non-empty file, not merely an existing one. A zero-byte file is what a run
49
+ * killed between create and write leaves behind, and treating that as captured would retire
50
+ * the row permanently: every later run skips it, and the gap never appears in any manifest.
51
+ */
45
52
  has(orgId, eventType, logDate, id, hour) {
46
- return fs.existsSync(this.pathFor(orgId, eventType, logDate, id, hour));
53
+ return nonEmpty(this.pathFor(orgId, eventType, logDate, id, hour));
47
54
  }
48
55
  /** Write a CSV body verbatim; returns the saved path. Best-effort. */
49
56
  save(orgId, eventType, logDate, id, body, hour) {
50
57
  const filePath = this.pathFor(orgId, eventType, logDate, id, hour);
51
58
  try {
52
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
53
- fs.writeFileSync(filePath, body, 'utf-8');
59
+ writeAtomic(filePath, body);
54
60
  }
55
61
  catch (err) {
56
62
  process.stderr.write(`[sf-audit] Warning: could not save event log ${id}: ${String(err)}\n`);
@@ -59,28 +65,27 @@ export class EventBaselineStore {
59
65
  }
60
66
  /** Absolute path the NDJSON for one Real-Time Event object-hour is (or would be) stored at. */
61
67
  realtimePathFor(orgId, objectName, logDate, hour) {
62
- return path.join(this.root, orgId, '_realtime', objectName, logDate, `${padHour(hour)}.ndjson`);
68
+ const [o, n, d] = [orgId, objectName, logDate].map(segment);
69
+ return path.join(this.root, o, '_realtime', n, d, `${padHour(hour)}.ndjson`);
63
70
  }
64
- /** True when this object-hour already holds a non-empty NDJSON file. */
71
+ /** True when this object-hour already holds a complete NDJSON file. */
65
72
  hasRealtime(orgId, objectName, logDate, hour) {
66
- const filePath = this.realtimePathFor(orgId, objectName, logDate, hour);
67
- try {
68
- return fs.statSync(filePath).size > 0;
69
- }
70
- catch {
71
- return false;
72
- }
73
+ return nonEmpty(this.realtimePathFor(orgId, objectName, logDate, hour));
73
74
  }
74
75
  /**
75
- * Write RTE rows as NDJSON — one JSON object per line, so a run killed mid-write still
76
- * leaves a parseable file up to the last complete line. Same failure-tolerance rationale as
77
- * streaming raw CSV bytes to disk before parsing them.
76
+ * Write RTE rows as NDJSON — one JSON object per line, so the file stays parseable line by
77
+ * line and a reader never has to hold the whole set in memory.
78
+ *
79
+ * Written to a temporary file and renamed into place. The earlier rationale — that a
80
+ * half-written NDJSON is still parseable up to the last complete line — is true but beside
81
+ * the point: `hasRealtime` cannot distinguish a truncated file from a complete one, so a
82
+ * partial write would be skipped by every later run and silently pass as full coverage.
83
+ * Rename is atomic within a filesystem, so the file is either absent or whole.
78
84
  */
79
85
  saveRealtime(orgId, objectName, logDate, hour, rows) {
80
86
  const filePath = this.realtimePathFor(orgId, objectName, logDate, hour);
81
87
  try {
82
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
83
- fs.writeFileSync(filePath, rows.map((r) => JSON.stringify(r)).join('\n') + '\n', 'utf-8');
88
+ writeAtomic(filePath, rows.map((r) => JSON.stringify(r)).join('\n') + '\n');
84
89
  }
85
90
  catch (err) {
86
91
  process.stderr.write(`[sf-audit] Warning: could not save realtime events ${objectName} ${logDate} ${hour}: ${String(err)}\n`);
@@ -103,12 +108,13 @@ export class EventBaselineStore {
103
108
  return this.writeManifestAs(orgId, 'manifest', manifest);
104
109
  }
105
110
  writeManifestAs(orgId, prefix, manifest) {
106
- const dir = path.join(this.root, orgId, '_manifests');
111
+ const dir = path.join(this.root, segment(orgId), '_manifests');
107
112
  const suffix = Math.random().toString(36).slice(2, 8);
108
113
  const filePath = path.join(dir, `${prefix}-${Date.now()}-${suffix}.json`);
109
114
  try {
110
- fs.mkdirSync(dir, { recursive: true });
111
- fs.writeFileSync(filePath, JSON.stringify(manifest, null, 2), 'utf-8');
115
+ // Atomic for the same reason as the captures: a reader scanning _manifests must never
116
+ // parse a half-written coverage record and conclude the run captured less than it did.
117
+ writeAtomic(filePath, JSON.stringify(manifest, null, 2));
112
118
  }
113
119
  catch (err) {
114
120
  process.stderr.write(`[sf-audit] Warning: could not write event manifest: ${String(err)}\n`);
@@ -118,6 +124,47 @@ export class EventBaselineStore {
118
124
  }
119
125
  /** Hours are stored zero-padded so lexical order matches chronological order. */
120
126
  function padHour(hour) {
121
- return String(hour).padStart(2, '0');
127
+ return String(segment(String(hour))).padStart(2, '0');
128
+ }
129
+ /**
130
+ * Constrain one org-supplied value to a single safe path segment.
131
+ *
132
+ * EventType, RTE object names, org ids and file ids all arrive from query results and are
133
+ * joined straight into a filesystem path. They are Salesforce identifiers in practice, but
134
+ * "in practice" is not a boundary: a value of `../../..` would place captured evidence
135
+ * outside the store, and this package writes to a directory under the operator's home. So
136
+ * anything that is not an identifier character is folded to `_`, and a segment that reduces
137
+ * to nothing (or to dots) becomes `_` rather than silently resolving to a parent directory.
138
+ */
139
+ function segment(raw) {
140
+ const cleaned = String(raw).replace(/[^A-Za-z0-9._-]/g, '_');
141
+ return cleaned.length === 0 || /^\.+$/.test(cleaned) ? '_' : cleaned;
142
+ }
143
+ /** True when the path holds a file with at least one byte. */
144
+ function nonEmpty(filePath) {
145
+ try {
146
+ return fs.statSync(filePath).size > 0;
147
+ }
148
+ catch {
149
+ return false;
150
+ }
151
+ }
152
+ /**
153
+ * Write via a temporary file and rename into place, so a reader never observes a partial
154
+ * file. The temp name carries the pid so two concurrent pulls of the same org — a cron run
155
+ * overlapping a manual one — cannot corrupt each other's staging file.
156
+ */
157
+ function writeAtomic(filePath, body) {
158
+ const dir = path.dirname(filePath);
159
+ fs.mkdirSync(dir, { recursive: true });
160
+ const tmp = path.join(dir, `.${path.basename(filePath)}.${process.pid}.tmp`);
161
+ try {
162
+ fs.writeFileSync(tmp, body, 'utf-8');
163
+ fs.renameSync(tmp, filePath);
164
+ }
165
+ catch (err) {
166
+ fs.rmSync(tmp, { force: true });
167
+ throw err;
168
+ }
122
169
  }
123
170
  //# sourceMappingURL=EventBaselineStore.js.map
@@ -1,3 +1,10 @@
1
+ // src/events/pullEventLogs.ts
2
+ // Orchestrates a single `audit events pull` run: discover the org's EventLogFile rows for the
3
+ // requested interval and window, download the CSV body of any not already on disk, optionally
4
+ // capture Real-Time Event rows alongside them, and record a per-run coverage manifest.
5
+ // All org I/O is behind the injected SoqlClient/RestClient, so this is unit-testable with
6
+ // mocked clients — it never touches a real org.
7
+ import * as fs from 'node:fs';
1
8
  import { classifyEventLogAccessError } from './eventLogAccess.js';
2
9
  import { HOURLY_FORENSIC_CORE, buildEventLogQuery, toLogDate, toLogHour, } from './eventLogQuery.js';
3
10
  import { emptyCoverage } from './CaptureManifest.js';
@@ -158,7 +165,14 @@ async function captureRow(deps, opts, base, coverage, row, passInterval, maxFile
158
165
  }
159
166
  try {
160
167
  // Stream straight to disk — never buffer the body — so large logs don't blow the heap.
161
- const bytes = await rest.getRawToFile(`/sobjects/EventLogFile/${row.Id}/LogFile`, savedPath);
168
+ //
169
+ // Staged through a temp file and renamed, so the final path only ever exists complete.
170
+ // The client already removes a partial file when the stream errors, but that cannot help
171
+ // if the process itself dies mid-download: the truncated CSV would satisfy `has()` and be
172
+ // skipped by every later run, leaving a silently incomplete log presented as a whole one.
173
+ const tmpPath = `${savedPath}.${process.pid}.part`;
174
+ const bytes = await rest.getRawToFile(`/sobjects/EventLogFile/${row.Id}/LogFile`, tmpPath);
175
+ fs.renameSync(tmpPath, savedPath);
162
176
  base.downloaded += 1;
163
177
  base.totalBytes += bytes;
164
178
  record('downloaded', bytes);
@@ -172,6 +186,7 @@ async function captureRow(deps, opts, base, coverage, row, passInterval, maxFile
172
186
  });
173
187
  }
174
188
  catch (err) {
189
+ fs.rmSync(`${savedPath}.${process.pid}.part`, { force: true });
175
190
  base.failed += 1;
176
191
  record('failed', 0);
177
192
  coverage.elf.failed.push({
@@ -19,8 +19,21 @@ export interface RealtimePullOptions {
19
19
  catalog?: readonly RteType[];
20
20
  /** Re-capture object-hours already on disk. */
21
21
  force?: boolean;
22
+ /** Cap on rows accepted from one object. Defaults to MAX_RTE_ROWS. */
23
+ maxRows?: number;
22
24
  warn?: (msg: string) => void;
23
25
  }
26
+ /**
27
+ * Ceiling on rows taken from a single RTE object in one pull.
28
+ *
29
+ * RTE payloads are small for a sensible window — a busy hour ran to a few hundred ApiEvent
30
+ * rows — but the window is caller-supplied and `queryAll` follows every page, so a month-wide
31
+ * window on a chatty object would page the lot into memory before a single byte reached disk.
32
+ * Overflow is reported as `too-large` rather than truncated: a short NDJSON file is
33
+ * indistinguishable from a quiet hour once written, and quietly answering "nothing else
34
+ * happened" is the one failure this package exists to prevent.
35
+ */
36
+ export declare const MAX_RTE_ROWS = 200000;
24
37
  export interface RealtimePullResult {
25
38
  captured: CapturedRteObject[];
26
39
  unavailable: UnavailableRteObject[];
@@ -39,7 +52,7 @@ export declare function describeFields(rest: RestClient, objectName: string, pre
39
52
  export declare function buildRealtimeQuery(objectName: string, fields: readonly string[], window: {
40
53
  from: string;
41
54
  to: string;
42
- }): string;
55
+ }, limit?: number): string;
43
56
  /**
44
57
  * Map an RTE failure to a manifest reason. The distinction that matters most is
45
58
  * "does not support query" — meaning the base object is streaming-only and the Store should be
@@ -1,4 +1,15 @@
1
1
  import { RTE_CATALOG } from './rteCatalog.js';
2
+ /**
3
+ * Ceiling on rows taken from a single RTE object in one pull.
4
+ *
5
+ * RTE payloads are small for a sensible window — a busy hour ran to a few hundred ApiEvent
6
+ * rows — but the window is caller-supplied and `queryAll` follows every page, so a month-wide
7
+ * window on a chatty object would page the lot into memory before a single byte reached disk.
8
+ * Overflow is reported as `too-large` rather than truncated: a short NDJSON file is
9
+ * indistinguishable from a quiet hour once written, and quietly answering "nothing else
10
+ * happened" is the one failure this package exists to prevent.
11
+ */
12
+ export const MAX_RTE_ROWS = 200_000;
2
13
  const SOQL_DATETIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/;
3
14
  export async function pullRealtimeEvents(deps, opts) {
4
15
  for (const bound of [opts.window.from, opts.window.to]) {
@@ -42,27 +53,36 @@ async function captureOne(deps, opts, entry) {
42
53
  details.push(`${attempt.name}: describe returned none of the preferred fields`);
43
54
  continue;
44
55
  }
56
+ const maxRows = opts.maxRows ?? MAX_RTE_ROWS;
45
57
  let rows;
46
58
  try {
47
- rows = await deps.soql.queryAll(buildRealtimeQuery(attempt.name, fields, opts.window));
59
+ // One over the cap, so an exactly-full result is told apart from an overflowing one.
60
+ rows = await deps.soql.queryAll(buildRealtimeQuery(attempt.name, fields, opts.window, maxRows + 1));
48
61
  }
49
62
  catch (err) {
50
63
  lastReason = classifyRteError(err);
51
64
  details.push(`${attempt.name}: ${message(err)}`);
52
65
  continue;
53
66
  }
67
+ if (rows.length > maxRows) {
68
+ opts.warn?.(`${attempt.name}: more than ${maxRows} rows in this window; narrow the window and re-run.`);
69
+ return {
70
+ object: entry.base,
71
+ reason: 'too-large',
72
+ detail: `${attempt.name} returned more than ${maxRows} rows for the requested window; nothing written`,
73
+ };
74
+ }
54
75
  if (rows.length === 0) {
55
- if (attempt.via === 'base') {
56
- // The live event channel answered and had nothing. That is a real finding — nothing
57
- // happened in this window — not a gap in capture, so it is recorded as a capture of
58
- // zero rows rather than as an unavailable object.
59
- return { object: entry.base, rows: 0, via: 'base', paths: [] };
60
- }
61
- // Only the retained-rows Store answered, and it is empty. Empty and never-retained are
62
- // indistinguishable from here, so this must not be reported as "nothing happened".
63
- lastReason = 'storage-disabled';
64
- details.push(`${attempt.name}: queryable but returned 0 rows`);
65
- continue;
76
+ // A query that succeeded and returned nothing is a finding: nothing happened in this
77
+ // window. Recorded as a capture of zero rows, not as an unavailable object.
78
+ //
79
+ // This used to distinguish base from Store, on the reasoning that an empty Store could
80
+ // not be told apart from one that never retained anything — reported as
81
+ // `storage-disabled`. A live run showed why that is wrong: the eight threat-detection
82
+ // Stores are queryable and empty in a normal hour, so every quiet hour produced eight
83
+ // "unavailable" entries claiming coverage was missing when the org had in fact been
84
+ // asked and had answered. Overstating a gap corrupts the record as surely as hiding one.
85
+ return { object: entry.base, rows: 0, via: attempt.via, paths: [] };
66
86
  }
67
87
  return writeBuckets(deps, opts, entry.base, attempt.via, rows);
68
88
  }
@@ -120,11 +140,12 @@ export async function describeFields(rest, objectName, preferred) {
120
140
  * `ORDER BY EventDate ASC` with "Unsupported order direction on filter column". Sorting is a
121
141
  * client-side concern here.
122
142
  */
123
- export function buildRealtimeQuery(objectName, fields, window) {
143
+ export function buildRealtimeQuery(objectName, fields, window, limit) {
124
144
  const safeObject = objectName.replace(/[^A-Za-z0-9_]/g, '');
125
145
  const safeFields = fields.map((f) => f.replace(/[^A-Za-z0-9_]/g, '')).filter((f) => f.length > 0);
146
+ const limitClause = limit === undefined ? '' : ` LIMIT ${Math.max(1, Math.trunc(limit))}`;
126
147
  return (`SELECT ${safeFields.join(', ')} FROM ${safeObject} ` +
127
- `WHERE EventDate >= ${window.from} AND EventDate <= ${window.to}`);
148
+ `WHERE EventDate >= ${window.from} AND EventDate <= ${window.to}${limitClause}`);
128
149
  }
129
150
  /**
130
151
  * Map an RTE failure to a manifest reason. The distinction that matters most is
@@ -7,8 +7,26 @@ export interface RteType {
7
7
  preferredFields: string[];
8
8
  }
9
9
  /**
10
- * The 20 known RTE types. `store` is declared wherever a `*Store` counterpart is known to
11
- * exist; its absence on ListViewEvent is deliberate, not an oversight.
10
+ * The 20 known RTE types, split by how the org actually serves them.
11
+ *
12
+ * Probed against a live sandbox on 2026-08-03, which replaced the naming convention this
13
+ * table was first built on. The convention was wrong in both directions, and the real rule
14
+ * turns out to be about what kind of event it is:
15
+ *
16
+ * - **Audit events** (someone did a thing) are queried directly and have NO `*Store`.
17
+ * `ApiEventStore`, `LoginEventStore`, `LogoutEventStore`, `ReportEventStore`,
18
+ * `UriEventStore`, `LightningUriEventStore` and `LoginAsEventStore` were all declared
19
+ * here and none of them exist — every one 404s on describe.
20
+ * - **Threat-detection events** (something looked wrong) are streaming-only: the base
21
+ * rejects a query outright and the retained rows live in a `*Store`.
22
+ *
23
+ * A `store` on a directly-queryable base is never reached, so the phantom entries were
24
+ * harmless — but a catalog that documents objects which do not exist is worse than no
25
+ * documentation, so they are gone.
26
+ *
27
+ * Re-probed across five orgs — two sandboxes and three production — on 2026-08-03. Every
28
+ * verdict was identical in all five, including the absences, so the negatives are no longer
29
+ * a single-org observation that a different licence might overturn.
12
30
  */
13
31
  export declare const RTE_CATALOG: readonly RteType[];
14
32
  //# sourceMappingURL=rteCatalog.d.ts.map
@@ -46,45 +46,68 @@ const CONTEXT_FIELDS = [
46
46
  ];
47
47
  const ALL_PREFERRED = [...COMMON_FIELDS, ...EXFIL_FIELDS, ...CONTEXT_FIELDS];
48
48
  /**
49
- * The 20 known RTE types. `store` is declared wherever a `*Store` counterpart is known to
50
- * exist; its absence on ListViewEvent is deliberate, not an oversight.
49
+ * The 20 known RTE types, split by how the org actually serves them.
50
+ *
51
+ * Probed against a live sandbox on 2026-08-03, which replaced the naming convention this
52
+ * table was first built on. The convention was wrong in both directions, and the real rule
53
+ * turns out to be about what kind of event it is:
54
+ *
55
+ * - **Audit events** (someone did a thing) are queried directly and have NO `*Store`.
56
+ * `ApiEventStore`, `LoginEventStore`, `LogoutEventStore`, `ReportEventStore`,
57
+ * `UriEventStore`, `LightningUriEventStore` and `LoginAsEventStore` were all declared
58
+ * here and none of them exist — every one 404s on describe.
59
+ * - **Threat-detection events** (something looked wrong) are streaming-only: the base
60
+ * rejects a query outright and the retained rows live in a `*Store`.
61
+ *
62
+ * A `store` on a directly-queryable base is never reached, so the phantom entries were
63
+ * harmless — but a catalog that documents objects which do not exist is worse than no
64
+ * documentation, so they are gone.
65
+ *
66
+ * Re-probed across five orgs — two sandboxes and three production — on 2026-08-03. Every
67
+ * verdict was identical in all five, including the absences, so the negatives are no longer
68
+ * a single-org observation that a different licence might overturn.
51
69
  */
52
70
  export const RTE_CATALOG = [
71
+ // Directly queryable; no Store counterpart exists. Verified queryable in the probe org.
53
72
  { base: 'ListViewEvent', preferredFields: ALL_PREFERRED },
54
- { base: 'ApiEvent', store: 'ApiEventStore', preferredFields: ALL_PREFERRED },
55
- { base: 'LoginEvent', store: 'LoginEventStore', preferredFields: ALL_PREFERRED },
56
- { base: 'LogoutEvent', store: 'LogoutEventStore', preferredFields: ALL_PREFERRED },
57
- { base: 'ReportEvent', store: 'ReportEventStore', preferredFields: ALL_PREFERRED },
58
- { base: 'UriEvent', store: 'UriEventStore', preferredFields: ALL_PREFERRED },
59
- { base: 'LightningUriEvent', store: 'LightningUriEventStore', preferredFields: ALL_PREFERRED },
60
- { base: 'ApexExecutionEvent', preferredFields: ALL_PREFERRED },
73
+ { base: 'ApiEvent', preferredFields: ALL_PREFERRED },
74
+ { base: 'LoginEvent', preferredFields: ALL_PREFERRED },
75
+ { base: 'LogoutEvent', preferredFields: ALL_PREFERRED },
76
+ { base: 'ReportEvent', preferredFields: ALL_PREFERRED },
77
+ { base: 'UriEvent', preferredFields: ALL_PREFERRED },
78
+ { base: 'LightningUriEvent', preferredFields: ALL_PREFERRED },
79
+ { base: 'LoginAsEvent', preferredFields: ALL_PREFERRED },
80
+ { base: 'IdentityProviderEventStore', preferredFields: ALL_PREFERRED },
81
+ // Streaming-only base, retained rows in the Store. All eight Stores verified queryable,
82
+ // and all eight bases verified to reject a query with "does not support query".
83
+ { base: 'ApiAnomalyEvent', store: 'ApiAnomalyEventStore', preferredFields: ALL_PREFERRED },
61
84
  { base: 'BulkApiResultEvent', store: 'BulkApiResultEventStore', preferredFields: ALL_PREFERRED },
85
+ {
86
+ base: 'CredentialStuffingEvent',
87
+ store: 'CredentialStuffingEventStore',
88
+ preferredFields: ALL_PREFERRED,
89
+ },
62
90
  { base: 'FileEvent', store: 'FileEventStore', preferredFields: ALL_PREFERRED },
63
- { base: 'ApiAnomalyEvent', store: 'ApiAnomalyEventStore', preferredFields: ALL_PREFERRED },
64
91
  {
65
92
  base: 'GuestUserAnomalyEvent',
66
93
  store: 'GuestUserAnomalyEventStore',
67
94
  preferredFields: ALL_PREFERRED,
68
95
  },
96
+ { base: 'PermissionSetEvent', store: 'PermissionSetEventStore', preferredFields: ALL_PREFERRED },
97
+ { base: 'ReportAnomalyEvent', store: 'ReportAnomalyEventStore', preferredFields: ALL_PREFERRED },
69
98
  {
70
99
  base: 'SessionHijackingEvent',
71
100
  store: 'SessionHijackingEventStore',
72
101
  preferredFields: ALL_PREFERRED,
73
102
  },
74
- {
75
- base: 'CredentialStuffingEvent',
76
- store: 'CredentialStuffingEventStore',
77
- preferredFields: ALL_PREFERRED,
78
- },
79
- { base: 'ReportAnomalyEvent', store: 'ReportAnomalyEventStore', preferredFields: ALL_PREFERRED },
80
- { base: 'PermissionSetEvent', store: 'PermissionSetEventStore', preferredFields: ALL_PREFERRED },
81
- {
82
- base: 'ConcurLongRunApexErrEvent',
83
- store: 'ConcurLongRunApexErrEventStore',
84
- preferredFields: ALL_PREFERRED,
85
- },
103
+ // Exist, but are streaming-only with no Store in any org probed — so they can never be
104
+ // captured retroactively. Kept deliberately: the manifest recording them as `not-queryable`
105
+ // is real coverage information. "This event type exists and cannot be read after the fact"
106
+ // is a different answer from "we did not look", and a forensic consumer needs to tell them
107
+ // apart before it reports an absence.
108
+ { base: 'ConcurLongRunApexErrEvent', preferredFields: ALL_PREFERRED },
86
109
  { base: 'OrgLifecycleNotification', preferredFields: ALL_PREFERRED },
87
- { base: 'LoginAsEvent', store: 'LoginAsEventStore', preferredFields: ALL_PREFERRED },
88
- { base: 'IdentityProviderEventStore', preferredFields: ALL_PREFERRED },
110
+ // `ApexExecutionEvent` was here and is gone: absent from describe in all five orgs, so the
111
+ // name appears not to exist rather than to be unlicensed. It cost a 404 per pull.
89
112
  ];
90
113
  //# sourceMappingURL=rteCatalog.js.map
package/lib/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export { classifyEventLogAccessError } from './events/eventLogAccess.js';
15
15
  export type { RteType } from './events/rteCatalog.js';
16
16
  export { RTE_CATALOG } from './events/rteCatalog.js';
17
17
  export type { RealtimePullDeps, RealtimePullOptions, RealtimePullResult, } from './events/pullRealtimeEvents.js';
18
- export { pullRealtimeEvents, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
18
+ export { pullRealtimeEvents, MAX_RTE_ROWS, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
19
19
  export type { SkipReason, CaptureCoverage, CapturedElfFile, SkippedElfFile, CapturedRteObject, UnavailableRteObject, } from './events/CaptureManifest.js';
20
20
  export { SKIP_REASONS, isSkipReason, emptyCoverage, readCoverageManifest, } from './events/CaptureManifest.js';
21
21
  export type { Branding, BrandingOverrides } from './report/branding.js';
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@ export { sanitizeTypes, toLogDate, toLogHour, buildEventLogQuery, HOURLY_FORENSI
9
9
  export { pullEventLogs, MAX_FILE_BYTES } from './events/pullEventLogs.js';
10
10
  export { classifyEventLogAccessError } from './events/eventLogAccess.js';
11
11
  export { RTE_CATALOG } from './events/rteCatalog.js';
12
- export { pullRealtimeEvents, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
12
+ export { pullRealtimeEvents, MAX_RTE_ROWS, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
13
13
  export { SKIP_REASONS, isSkipReason, emptyCoverage, readCoverageManifest, } from './events/CaptureManifest.js';
14
14
  export { DEFAULT_BRANDING, resolveBranding } from './report/branding.js';
15
15
  export { fontFaceCss, firaFontFaceCss } from './report/fonts.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-core",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",