@x12i/map-store-client 0.1.2 → 0.1.4

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.
Files changed (80) hide show
  1. package/README.md +147 -1
  2. package/dist/attackSurfaces.d.ts.map +1 -1
  3. package/dist/attackSurfaces.js +17 -3
  4. package/dist/attackSurfaces.js.map +1 -1
  5. package/dist/bagCatalog.js +3 -3
  6. package/dist/bagCatalog.js.map +1 -1
  7. package/dist/bootstrap.d.ts.map +1 -1
  8. package/dist/bootstrap.js +1 -15
  9. package/dist/bootstrap.js.map +1 -1
  10. package/dist/errors.d.ts.map +1 -1
  11. package/dist/errors.js +3 -0
  12. package/dist/errors.js.map +1 -1
  13. package/dist/estate/analytics.d.ts +41 -0
  14. package/dist/estate/analytics.d.ts.map +1 -0
  15. package/dist/estate/analytics.js +115 -0
  16. package/dist/estate/analytics.js.map +1 -0
  17. package/dist/estate/census.d.ts +115 -0
  18. package/dist/estate/census.d.ts.map +1 -0
  19. package/dist/estate/census.js +266 -0
  20. package/dist/estate/census.js.map +1 -0
  21. package/dist/estate/client.d.ts +66 -0
  22. package/dist/estate/client.d.ts.map +1 -0
  23. package/dist/estate/client.js +10 -0
  24. package/dist/estate/client.js.map +1 -0
  25. package/dist/estate/content.d.ts +77 -0
  26. package/dist/estate/content.d.ts.map +1 -0
  27. package/dist/estate/content.js +226 -0
  28. package/dist/estate/content.js.map +1 -0
  29. package/dist/estate/contract.d.ts +64 -0
  30. package/dist/estate/contract.d.ts.map +1 -0
  31. package/dist/estate/contract.js +258 -0
  32. package/dist/estate/contract.js.map +1 -0
  33. package/dist/estate/decisions.d.ts +32 -0
  34. package/dist/estate/decisions.d.ts.map +1 -0
  35. package/dist/estate/decisions.js +113 -0
  36. package/dist/estate/decisions.js.map +1 -0
  37. package/dist/estate/ids.d.ts +3 -0
  38. package/dist/estate/ids.d.ts.map +1 -0
  39. package/dist/estate/ids.js +6 -0
  40. package/dist/estate/ids.js.map +1 -0
  41. package/dist/estate/index.d.ts +26 -0
  42. package/dist/estate/index.d.ts.map +1 -0
  43. package/dist/estate/index.js +17 -0
  44. package/dist/estate/index.js.map +1 -0
  45. package/dist/estate/localStories.d.ts +28 -0
  46. package/dist/estate/localStories.d.ts.map +1 -0
  47. package/dist/estate/localStories.js +980 -0
  48. package/dist/estate/localStories.js.map +1 -0
  49. package/dist/estate/pack.d.ts +45 -0
  50. package/dist/estate/pack.d.ts.map +1 -0
  51. package/dist/estate/pack.js +83 -0
  52. package/dist/estate/pack.js.map +1 -0
  53. package/dist/estate/predictedAttack.d.ts +79 -0
  54. package/dist/estate/predictedAttack.d.ts.map +1 -0
  55. package/dist/estate/predictedAttack.js +321 -0
  56. package/dist/estate/predictedAttack.js.map +1 -0
  57. package/dist/estate/stories.d.ts +85 -0
  58. package/dist/estate/stories.d.ts.map +1 -0
  59. package/dist/estate/stories.js +215 -0
  60. package/dist/estate/stories.js.map +1 -0
  61. package/dist/fetch.d.ts +2 -0
  62. package/dist/fetch.d.ts.map +1 -1
  63. package/dist/fetch.js +35 -4
  64. package/dist/fetch.js.map +1 -1
  65. package/dist/index.d.ts +2 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -0
  68. package/dist/index.js.map +1 -1
  69. package/dist/queries.d.ts +98 -0
  70. package/dist/queries.d.ts.map +1 -0
  71. package/dist/queries.js +180 -0
  72. package/dist/queries.js.map +1 -0
  73. package/dist/types.d.ts +1 -1
  74. package/dist/types.d.ts.map +1 -1
  75. package/dist/types.js.map +1 -1
  76. package/dist/working.d.ts +11 -1
  77. package/dist/working.d.ts.map +1 -1
  78. package/dist/working.js +23 -15
  79. package/dist/working.js.map +1 -1
  80. package/package.json +14 -1
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Tier-0 census records. Three processes count published lander rows and each
3
+ * save one content record. They do not read AI products. They are not
4
+ * `estate-analytics` and they are not a bag total.
5
+ *
6
+ * One GET per board, after `working/bootstrap` has pinned the session:
7
+ * `security-map` / `tier0-analytics` / `working/{vulnerability,asset,estate}-census`.
8
+ * `data.kind` selects the record.
9
+ *
10
+ * `produced: true` and `value: 0` is a finished empty count.
11
+ * `produced: false` and `value: 0` means that source was not read.
12
+ * A missing field is the bucket `absent`. A missing KEV flag is `absent`, not `false`.
13
+ */
14
+ import type { EstateData } from './client';
15
+ export type Tier0Metric = {
16
+ value: number;
17
+ produced: boolean;
18
+ };
19
+ export type MetricMap = Record<string, Tier0Metric>;
20
+ export type VulnerabilityCensusRow = {
21
+ id: string;
22
+ cveId: string | null;
23
+ label: string | null;
24
+ affectedAssets: number | null;
25
+ findings: number | null;
26
+ };
27
+ export type AssetCensusRow = {
28
+ id: string;
29
+ label: string | null;
30
+ findings: number | null;
31
+ distinctCves: number | null;
32
+ };
33
+ export type VulnerabilityCensus = {
34
+ kind: 'vulnerability-census';
35
+ totals: {
36
+ findings: Tier0Metric;
37
+ vulnerabilities: Tier0Metric;
38
+ distinctCves: Tier0Metric;
39
+ };
40
+ rows: VulnerabilityCensusRow[];
41
+ groups: Record<string, MetricMap>;
42
+ };
43
+ export type AssetCensus = {
44
+ kind: 'asset-census';
45
+ totals: {
46
+ assets: Tier0Metric;
47
+ findings: Tier0Metric;
48
+ };
49
+ rows: AssetCensusRow[];
50
+ groups: Record<string, MetricMap>;
51
+ };
52
+ export type EstateCensus = {
53
+ kind: 'estate-census';
54
+ totals: {
55
+ subjects: {
56
+ endpointAssets: Tier0Metric;
57
+ findings: Tier0Metric;
58
+ alerts: Tier0Metric;
59
+ zones: Tier0Metric;
60
+ devices: Tier0Metric;
61
+ unresolvedSubjects: Tier0Metric;
62
+ };
63
+ bags: {
64
+ hypothesizedPaths: Tier0Metric;
65
+ reachabilityClaims: Tier0Metric;
66
+ };
67
+ };
68
+ rows: readonly [];
69
+ groups: Record<string, MetricMap>;
70
+ };
71
+ export type Tier0Census = VulnerabilityCensus | AssetCensus | EstateCensus;
72
+ export declare const EMPTY_VULNERABILITY_ROWS: VulnerabilityCensusRow[];
73
+ export declare const EMPTY_ASSET_ROWS: AssetCensusRow[];
74
+ export type Tier0BoardId = 'vulnerability' | 'asset' | 'estate';
75
+ export declare const TIER0_TARGETS: {
76
+ readonly vulnerability: {
77
+ readonly recordId: "working/vulnerability-census";
78
+ readonly kind: "vulnerability-census";
79
+ };
80
+ readonly asset: {
81
+ readonly recordId: "working/asset-census";
82
+ readonly kind: "asset-census";
83
+ };
84
+ readonly estate: {
85
+ readonly recordId: "working/estate-census";
86
+ readonly kind: "estate-census";
87
+ };
88
+ };
89
+ /** A figure the census has not produced is absent, not zero. */
90
+ export declare function tier0Value(metric: Tier0Metric | undefined): number | null;
91
+ export declare function publishedCount(value: number | null | undefined): string;
92
+ /**
93
+ * List figure. A loaded census uses its own number, including a finished `0`.
94
+ * A missing row on a loaded census is unavailable.
95
+ * Before that document exists, the lander figure keeps the column from going blank.
96
+ */
97
+ export declare function censusOrLander(censusReady: boolean, censusRow: object | null, censusValue: number | null | undefined, landerValue: number | null | undefined): number | null;
98
+ /** Parse one census body. A mismatched `data.kind` is not that board's record. */
99
+ export declare function parseTier0Census(page: unknown, kind: Tier0Census['kind']): Tier0Census | null;
100
+ /**
101
+ * One client-API read of `security-map` / `tier0-analytics`.
102
+ * A missing record or an unregistered content type yields null.
103
+ */
104
+ export declare function loadTier0Census(client: EstateData, board: Tier0BoardId, signal?: AbortSignal): Promise<Tier0Census | null>;
105
+ /** Dialog lookup. `rows[].id` is the lander record id. */
106
+ export declare function censusEntryById<T extends {
107
+ id: string;
108
+ }>(rows: readonly T[], id: string): T | null;
109
+ /**
110
+ * CVE dialog join. The panel's key is the CVE text. Use the lander id when that
111
+ * id is the CVE, otherwise the single census row that publishes this `cveId`.
112
+ * Several rows for one CVE stay unresolved here. Each dialog still matches by id.
113
+ */
114
+ export declare function vulnerabilityEntryForCve(rows: readonly VulnerabilityCensusRow[], cveId: string): VulnerabilityCensusRow | null;
115
+ //# sourceMappingURL=census.d.ts.map
@@ -0,0 +1 @@
1
+ {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W,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,MAAM,GAAG,IAAI,CAIf;AA2FD,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,WAAW,GAAG,IAAI,CAiD7F;AAWD;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,YAAY,EACnB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAiB7B;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAQlG;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,sBAAsB,EAAE,EACvC,KAAK,EAAE,MAAM,GACZ,sBAAsB,GAAG,IAAI,CAY/B"}
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Tier-0 census records. Three processes count published lander rows and each
3
+ * save one content record. They do not read AI products. They are not
4
+ * `estate-analytics` and they are not a bag total.
5
+ *
6
+ * One GET per board, after `working/bootstrap` has pinned the session:
7
+ * `security-map` / `tier0-analytics` / `working/{vulnerability,asset,estate}-census`.
8
+ * `data.kind` selects the record.
9
+ *
10
+ * `produced: true` and `value: 0` is a finished empty count.
11
+ * `produced: false` and `value: 0` means that source was not read.
12
+ * A missing field is the bucket `absent`. A missing KEV flag is `absent`, not `false`.
13
+ */
14
+ import { asRecord } from '../util';
15
+ import { contentData } from './content';
16
+ import { objectIdBody } from './ids';
17
+ export const EMPTY_VULNERABILITY_ROWS = [];
18
+ export const EMPTY_ASSET_ROWS = [];
19
+ export const TIER0_TARGETS = {
20
+ vulnerability: {
21
+ recordId: 'working/vulnerability-census',
22
+ kind: 'vulnerability-census',
23
+ },
24
+ asset: {
25
+ recordId: 'working/asset-census',
26
+ kind: 'asset-census',
27
+ },
28
+ estate: {
29
+ recordId: 'working/estate-census',
30
+ kind: 'estate-census',
31
+ },
32
+ };
33
+ const unproduced = () => ({ value: 0, produced: false });
34
+ /** A figure the census has not produced is absent, not zero. */
35
+ export function tier0Value(metric) {
36
+ if (!metric?.produced)
37
+ return null;
38
+ return metric.value;
39
+ }
40
+ export function publishedCount(value) {
41
+ return value == null ? '—' : value.toLocaleString();
42
+ }
43
+ /**
44
+ * List figure. A loaded census uses its own number, including a finished `0`.
45
+ * A missing row on a loaded census is unavailable.
46
+ * Before that document exists, the lander figure keeps the column from going blank.
47
+ */
48
+ export function censusOrLander(censusReady, censusRow, censusValue, landerValue) {
49
+ if (!censusReady)
50
+ return landerValue ?? null;
51
+ if (!censusRow)
52
+ return null;
53
+ return censusValue ?? null;
54
+ }
55
+ function metricOf(value) {
56
+ const rec = asRecord(value);
57
+ if (!rec ||
58
+ typeof rec.produced !== 'boolean' ||
59
+ typeof rec.value !== 'number' ||
60
+ !Number.isFinite(rec.value)) {
61
+ return unproduced();
62
+ }
63
+ return { value: rec.value, produced: rec.produced };
64
+ }
65
+ function readMetric(source, key) {
66
+ if (!source || !Object.prototype.hasOwnProperty.call(source, key))
67
+ return unproduced();
68
+ return metricOf(source[key]);
69
+ }
70
+ /** A row count. A wrapped metric counts only when that metric was produced. */
71
+ function countOf(value) {
72
+ if (typeof value === 'number' && Number.isFinite(value))
73
+ return value;
74
+ const rec = asRecord(value);
75
+ if (!rec || rec.produced !== true || typeof rec.value !== 'number' || !Number.isFinite(rec.value)) {
76
+ return null;
77
+ }
78
+ return rec.value;
79
+ }
80
+ function textOf(value) {
81
+ return typeof value === 'string' && value.trim() ? value.trim() : null;
82
+ }
83
+ function metricMap(value) {
84
+ const rec = asRecord(value);
85
+ if (!rec)
86
+ return null;
87
+ const out = {};
88
+ for (const [key, raw] of Object.entries(rec)) {
89
+ if (!key)
90
+ continue;
91
+ out[key] = metricOf(raw);
92
+ }
93
+ return out;
94
+ }
95
+ function groupsOf(value) {
96
+ const rec = asRecord(value);
97
+ if (!rec)
98
+ return {};
99
+ const out = {};
100
+ for (const [key, raw] of Object.entries(rec)) {
101
+ const buckets = metricMap(raw);
102
+ if (buckets)
103
+ out[key] = buckets;
104
+ }
105
+ return out;
106
+ }
107
+ function vulnerabilityRows(value) {
108
+ if (!Array.isArray(value))
109
+ return [];
110
+ const rows = [];
111
+ for (const item of value) {
112
+ const rec = asRecord(item);
113
+ const id = textOf(rec?.id);
114
+ if (!rec || !id)
115
+ continue;
116
+ rows.push({
117
+ id,
118
+ cveId: textOf(rec.cveId),
119
+ label: textOf(rec.label),
120
+ affectedAssets: countOf(rec.affectedAssets),
121
+ findings: countOf(rec.findings),
122
+ });
123
+ }
124
+ return rows;
125
+ }
126
+ function assetRows(value) {
127
+ if (!Array.isArray(value))
128
+ return [];
129
+ const rows = [];
130
+ for (const item of value) {
131
+ const rec = asRecord(item);
132
+ const id = textOf(rec?.id);
133
+ if (!rec || !id)
134
+ continue;
135
+ rows.push({
136
+ id,
137
+ label: textOf(rec.label),
138
+ findings: countOf(rec.findings),
139
+ distinctCves: countOf(rec.distinctCves),
140
+ });
141
+ }
142
+ return rows;
143
+ }
144
+ /** Parse one census body. A mismatched `data.kind` is not that board's record. */
145
+ export function parseTier0Census(page, kind) {
146
+ const data = contentData(page);
147
+ if (!data || data.kind !== kind)
148
+ return null;
149
+ const totals = asRecord(data.totals);
150
+ const groups = groupsOf(data.groups);
151
+ if (kind === 'vulnerability-census') {
152
+ return {
153
+ kind,
154
+ totals: {
155
+ findings: readMetric(totals, 'findings'),
156
+ vulnerabilities: readMetric(totals, 'vulnerabilities'),
157
+ distinctCves: readMetric(totals, 'distinctCves'),
158
+ },
159
+ rows: vulnerabilityRows(data.rows),
160
+ groups,
161
+ };
162
+ }
163
+ if (kind === 'asset-census') {
164
+ return {
165
+ kind,
166
+ totals: {
167
+ assets: readMetric(totals, 'assets'),
168
+ findings: readMetric(totals, 'findings'),
169
+ },
170
+ rows: assetRows(data.rows),
171
+ groups,
172
+ };
173
+ }
174
+ const subjects = asRecord(totals?.subjects);
175
+ const bags = asRecord(totals?.bags);
176
+ return {
177
+ kind,
178
+ totals: {
179
+ subjects: {
180
+ endpointAssets: readMetric(subjects, 'endpointAssets'),
181
+ findings: readMetric(subjects, 'findings'),
182
+ alerts: readMetric(subjects, 'alerts'),
183
+ zones: readMetric(subjects, 'zones'),
184
+ devices: readMetric(subjects, 'devices'),
185
+ unresolvedSubjects: readMetric(subjects, 'unresolvedSubjects'),
186
+ },
187
+ bags: {
188
+ hypothesizedPaths: readMetric(bags, 'hypothesizedPaths'),
189
+ reachabilityClaims: readMetric(bags, 'reachabilityClaims'),
190
+ },
191
+ },
192
+ rows: [],
193
+ groups,
194
+ };
195
+ }
196
+ /** A missing record (404) or a content type the pack does not register. Any client error with `.status` qualifies. */
197
+ function isAbsent(err) {
198
+ const status = err?.status;
199
+ if (typeof status !== 'number')
200
+ return false;
201
+ if (status === 404)
202
+ return true;
203
+ const error = asRecord(asRecord(err.body)?.error);
204
+ return status === 400 && error?.code === 'ROUTE_UNKNOWN_CONTENT_TYPE';
205
+ }
206
+ /**
207
+ * One client-API read of `security-map` / `tier0-analytics`.
208
+ * A missing record or an unregistered content type yields null.
209
+ */
210
+ export async function loadTier0Census(client, board, signal) {
211
+ const target = TIER0_TARGETS[board];
212
+ try {
213
+ if (signal?.aborted)
214
+ return null;
215
+ const page = await client.getContent({
216
+ objectType: 'security-map',
217
+ contentType: 'tier0-analytics',
218
+ recordId: target.recordId,
219
+ discriminatorValue: target.kind,
220
+ });
221
+ if (signal?.aborted)
222
+ return null;
223
+ return parseTier0Census(page, target.kind);
224
+ }
225
+ catch (err) {
226
+ if (isAbsent(err))
227
+ return null;
228
+ console.warn(`tier0-analytics ${target.recordId} unavailable`, err);
229
+ return null;
230
+ }
231
+ }
232
+ /** Dialog lookup. `rows[].id` is the lander record id. */
233
+ export function censusEntryById(rows, id) {
234
+ const want = id.trim();
235
+ if (!want)
236
+ return null;
237
+ const body = objectIdBody(want);
238
+ for (const row of rows) {
239
+ if (row.id === want || row.id === body || objectIdBody(row.id) === body)
240
+ return row;
241
+ }
242
+ return null;
243
+ }
244
+ /**
245
+ * CVE dialog join. The panel's key is the CVE text. Use the lander id when that
246
+ * id is the CVE, otherwise the single census row that publishes this `cveId`.
247
+ * Several rows for one CVE stay unresolved here. Each dialog still matches by id.
248
+ */
249
+ export function vulnerabilityEntryForCve(rows, cveId) {
250
+ const direct = censusEntryById(rows, cveId);
251
+ if (direct)
252
+ return direct;
253
+ const key = cveId.trim().toUpperCase();
254
+ if (!key)
255
+ return null;
256
+ let hit = null;
257
+ for (const row of rows) {
258
+ if ((row.cveId ?? '').toUpperCase() !== key)
259
+ continue;
260
+ if (hit)
261
+ return null;
262
+ hit = row;
263
+ }
264
+ return hit;
265
+ }
266
+ //# sourceMappingURL=census.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"census.js","sourceRoot":"","sources":["../../src/estate/census.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAgErC,MAAM,CAAC,MAAM,wBAAwB,GAA6B,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAqB,EAAE,CAAC;AAIrD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE;QACb,QAAQ,EAAE,8BAA8B;QACxC,IAAI,EAAE,sBAAsB;KAC7B;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,sBAAsB;QAChC,IAAI,EAAE,cAAc;KACrB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,eAAe;KACtB;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IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,IAAI;YAAE,OAAO,GAAG,CAAC;IACtF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAuC,EACvC,KAAa;IAEb,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,GAAG,GAAkC,IAAI,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG;YAAE,SAAS;QACtD,IAAI,GAAG;YAAE,OAAO,IAAI,CAAC;QACrB,GAAG,GAAG,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The slice of `@x12i/memorix-client-api-client` these reads use.
3
+ * Pass the client you already build with `createMemorixReadClient`. Any object with these
4
+ * methods works, so this package does not depend on the Memorix client.
5
+ *
6
+ * The browser reaches it through the app proxy (this repo proxies `/memorix-client`).
7
+ * These reads never call Memorix itself.
8
+ */
9
+ export type ContentFilter = {
10
+ field: string;
11
+ op: 'eq';
12
+ value: string | number | boolean;
13
+ } | {
14
+ field: string;
15
+ op: 'exists';
16
+ value: true;
17
+ };
18
+ /** Arguments of `data.listContent` and `data.getContent`. */
19
+ export type ContentRead = {
20
+ objectType: string;
21
+ contentType: string;
22
+ recordId?: string;
23
+ discriminatorValue?: string;
24
+ filter?: ContentFilter[];
25
+ limit?: number;
26
+ cursor?: string;
27
+ include?: {
28
+ markdown?: boolean;
29
+ };
30
+ };
31
+ /** `data` on the Memorix read client. */
32
+ export interface EstateData {
33
+ listContent(query: ContentRead): Promise<unknown>;
34
+ getContent(query: ContentRead): Promise<unknown>;
35
+ readStory(query: {
36
+ objectType: string;
37
+ recordId: string;
38
+ template: string;
39
+ }): Promise<unknown>;
40
+ }
41
+ /** One story function from `functions(objectType)`. */
42
+ export type ObjectTypeFunction = {
43
+ id: string;
44
+ template?: string | null;
45
+ question?: string | null;
46
+ pageStory?: boolean;
47
+ };
48
+ /** Catalog and record reads on the Memorix read client. */
49
+ export interface EstateCatalog {
50
+ functions(objectType: string): Promise<ObjectTypeFunction[]>;
51
+ getContentType(objectType: string, contentType: string): Promise<unknown>;
52
+ listContentTypes(objectType: string): Promise<unknown>;
53
+ listRecords(objectType: string, query: {
54
+ filter?: {
55
+ recordId: string;
56
+ };
57
+ limit?: number;
58
+ representation?: string;
59
+ }): Promise<unknown>;
60
+ listRecordContentTypes(recordId: string): Promise<unknown>;
61
+ }
62
+ /** `analytics` on the Memorix read client. */
63
+ export interface EstateAnalyticsApi {
64
+ sourceCensus(): Promise<unknown>;
65
+ }
66
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/estate/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,aAAa,GACrB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,GAC7D;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC;AAEjD,6DAA6D;AAC7D,MAAM,MAAM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CACT,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE;QAAE,MAAM,CAAC,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAChF,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5D;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The slice of `@x12i/memorix-client-api-client` these reads use.
3
+ * Pass the client you already build with `createMemorixReadClient`. Any object with these
4
+ * methods works, so this package does not depend on the Memorix client.
5
+ *
6
+ * The browser reaches it through the app proxy (this repo proxies `/memorix-client`).
7
+ * These reads never call Memorix itself.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/estate/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Memorix content reads behind the lists.
3
+ * Business fields live on `record.data`. Narrative text lives on `_markdown.content`.
4
+ * The scope reason lives on the envelope `_metadata`, so each row carries it out.
5
+ */
6
+ import type { ContentFilter, EstateCatalog, EstateData } from './client';
7
+ export type ContentData = Record<string, unknown>;
8
+ /** A Memorix document envelope. Its facts are `data`, never the envelope itself. */
9
+ export declare function isDocumentEnvelope(value: Record<string, unknown>): boolean;
10
+ /**
11
+ * Business fields. Prefer `record.data` or `page.data`.
12
+ * An envelope without `data` is not facts. A flat body that is not an envelope still is.
13
+ */
14
+ export declare function contentData(page: unknown): ContentData | null;
15
+ /** `_markdown.content` on a record or a `{ record }` page. Empty when the head has none. */
16
+ export declare function documentMarkdown(page: unknown): string | null;
17
+ /**
18
+ * Envelope `_metadata.scopeReason`, for example `OUTSIDE_SNAPSHOT`.
19
+ * It is not a field inside `data`, so list reads lose it unless it is copied out.
20
+ */
21
+ export declare function readScopeReason(envelope: unknown): string | null;
22
+ export type ContentRow = {
23
+ recordId: string;
24
+ data: ContentData;
25
+ markdown: string | null;
26
+ /** `_metadata.scopeReason` from the envelope. Null when the record carries none. */
27
+ scopeReason: string | null;
28
+ };
29
+ export type ListContentInput = {
30
+ objectType: string;
31
+ contentType: string;
32
+ filter?: ContentFilter[];
33
+ /** Ask for `_markdown`. The analysis pages do. Table lists do not. */
34
+ includeMarkdown?: boolean;
35
+ /** Pages of `pageSize` to follow. Defaults to 20. */
36
+ maxPages?: number;
37
+ /** Defaults to 200. */
38
+ pageSize?: number;
39
+ };
40
+ /**
41
+ * Every record of one content type on one object type, following `pageInfo.nextCursor`.
42
+ * A 404, or a content type the pack does not register, is an empty list.
43
+ * Anything else is thrown.
44
+ */
45
+ export declare function listContent(client: EstateData, input: ListContentInput): Promise<ContentRow[]>;
46
+ export type ReadContentInput = {
47
+ objectType: string;
48
+ contentType: string;
49
+ recordId: string;
50
+ includeMarkdown?: boolean;
51
+ };
52
+ /**
53
+ * One record. Names the discriminator instance when the pack marks it required.
54
+ * A miss is null, not evidence that processing has not run.
55
+ */
56
+ export declare function readContent(data: EstateData, catalog: EstateCatalog, input: ReadContentInput): Promise<ContentRow | null>;
57
+ export type RecordContentInput = ReadContentInput & {
58
+ /**
59
+ * Ask for one instance, for example `{ field: 'decisionType', value: 'asset-triage' }`.
60
+ * Without one, a required discriminator is matched with `exists` so every instance comes back.
61
+ */
62
+ discriminator?: {
63
+ field: string;
64
+ value: string;
65
+ };
66
+ };
67
+ /**
68
+ * Every sibling of one content type on one record.
69
+ * `getContent` answers 404 when several records share the id, so this lists with a filter instead.
70
+ */
71
+ export declare function listRecordContent(data: EstateData, catalog: EstateCatalog, input: RecordContentInput): Promise<ContentRow[]>;
72
+ /**
73
+ * `data.displayName` on the inventory row for this subject.
74
+ * One `listContent` of `inventory` filtered by record id. Null when the row has no name.
75
+ */
76
+ export declare function inventoryDisplayName(client: EstateData, objectType: string, recordId: string): Promise<string | null>;
77
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/estate/content.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAe,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAkBlD,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAE1E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAS7D;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAO7D;AASD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQhE;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,oFAAoF;IACpF,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AA0BF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,sEAAsE;IACtE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,C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