@miadi/relational-git-repository-mapper 0.4.0 → 0.5.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/dist/index.js CHANGED
@@ -4,7 +4,8 @@
4
4
  // "Repository" here is always a git repository, never the DDD Repository or a
5
5
  // Data Mapper. Formerly @miadi/relational-repository-mapper (deprecated).
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.repositoryCapabilities = exports.readCapabilities = exports.repositoryLineage = exports.readLineage = exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = exports.scanRepository = exports.SHIPPED_CAPABILITIES_SOURCE = exports.SHIPPED_CAPABILITIES_SCANS = exports.SHIPPED_CAPABILITIES = exports.capabilitiesOf = exports.providesEdges = exports.mergeCapabilityRows = exports.capabilityRows = exports.skillFiles = exports.packageManifests = exports.workspaceGlobs = exports.parseSkillFrontMatter = exports.parsePackageJson = exports.kindOf = exports.capabilityId = exports.CAPABILITY_KINDS = exports.SHIPPED_LINEAGE_SOURCE = exports.SHIPPED_LINEAGE_JSONL = exports.lineageGraph = exports.lineageOf = exports.parseLineage = exports.LineageRowSchema = exports.listRepositories = exports.repositoryView = exports.sessionsByRepository = exports.repositoryKey = exports.sessionOf = exports.dispositionOf = exports.teamOf = exports.dayOf = void 0;
7
+ exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = exports.SHIPPED_HOSTS_SOURCE = exports.SHIPPED_HOSTS = exports.SHIPPED_PACKAGES = exports.checkWhere = exports.webUrlOf = exports.whereOf = exports.parseWhere = exports.RepositoryWhereSchema = exports.RepositoryHostSchema = exports.impactOf = exports.satisfies = exports.bumpVersion = exports.consumesEdges = exports.PackageReadingSchema = exports.scanRepository = exports.SHIPPED_CAPABILITIES_SOURCE = exports.SHIPPED_CAPABILITIES_SCANS = exports.SHIPPED_CAPABILITIES = exports.capabilitiesOf = exports.providesEdges = exports.mergeCapabilityRows = exports.capabilityRows = exports.skillFiles = exports.packageManifests = exports.workspaceGlobs = exports.parseSkillFrontMatter = exports.parsePackageJson = exports.kindOf = exports.capabilityId = exports.CAPABILITY_KINDS = exports.SHIPPED_LINEAGE_SOURCE = exports.SHIPPED_LINEAGE_JSONL = exports.lineageGraph = exports.lineageOf = exports.parseLineage = exports.LineageRowSchema = exports.listRepositories = exports.repositoryView = exports.sessionsByRepository = exports.repositoryKey = exports.sessionOf = exports.dispositionOf = exports.teamOf = exports.dayOf = void 0;
8
+ exports.repositoryImpact = exports.readPackages = exports.readWhere = exports.repositoryCapabilities = exports.readCapabilities = exports.repositoryLineage = exports.readLineage = void 0;
8
9
  var join_1 = require("./join");
9
10
  Object.defineProperty(exports, "dayOf", { enumerable: true, get: function () { return join_1.dayOf; } });
10
11
  Object.defineProperty(exports, "teamOf", { enumerable: true, get: function () { return join_1.teamOf; } });
@@ -41,6 +42,25 @@ Object.defineProperty(exports, "SHIPPED_CAPABILITIES_SCANS", { enumerable: true,
41
42
  Object.defineProperty(exports, "SHIPPED_CAPABILITIES_SOURCE", { enumerable: true, get: function () { return shipped_capabilities_1.SHIPPED_CAPABILITIES_SOURCE; } });
42
43
  var scan_1 = require("./scan");
43
44
  Object.defineProperty(exports, "scanRepository", { enumerable: true, get: function () { return scan_1.scanRepository; } });
45
+ var impact_1 = require("./impact");
46
+ Object.defineProperty(exports, "PackageReadingSchema", { enumerable: true, get: function () { return impact_1.PackageReadingSchema; } });
47
+ Object.defineProperty(exports, "consumesEdges", { enumerable: true, get: function () { return impact_1.consumesEdges; } });
48
+ Object.defineProperty(exports, "bumpVersion", { enumerable: true, get: function () { return impact_1.bumpVersion; } });
49
+ Object.defineProperty(exports, "satisfies", { enumerable: true, get: function () { return impact_1.satisfies; } });
50
+ Object.defineProperty(exports, "impactOf", { enumerable: true, get: function () { return impact_1.impactOf; } });
51
+ var hosts_1 = require("./hosts");
52
+ Object.defineProperty(exports, "RepositoryHostSchema", { enumerable: true, get: function () { return hosts_1.RepositoryHostSchema; } });
53
+ Object.defineProperty(exports, "RepositoryWhereSchema", { enumerable: true, get: function () { return hosts_1.RepositoryWhereSchema; } });
54
+ Object.defineProperty(exports, "parseWhere", { enumerable: true, get: function () { return hosts_1.parseWhere; } });
55
+ Object.defineProperty(exports, "whereOf", { enumerable: true, get: function () { return hosts_1.whereOf; } });
56
+ Object.defineProperty(exports, "webUrlOf", { enumerable: true, get: function () { return hosts_1.webUrlOf; } });
57
+ var where_1 = require("./where");
58
+ Object.defineProperty(exports, "checkWhere", { enumerable: true, get: function () { return where_1.checkWhere; } });
59
+ var shipped_capabilities_2 = require("./shipped-capabilities");
60
+ Object.defineProperty(exports, "SHIPPED_PACKAGES", { enumerable: true, get: function () { return shipped_capabilities_2.SHIPPED_PACKAGES; } });
61
+ var shipped_hosts_1 = require("./shipped-hosts");
62
+ Object.defineProperty(exports, "SHIPPED_HOSTS", { enumerable: true, get: function () { return shipped_hosts_1.SHIPPED_HOSTS; } });
63
+ Object.defineProperty(exports, "SHIPPED_HOSTS_SOURCE", { enumerable: true, get: function () { return shipped_hosts_1.SHIPPED_HOSTS_SOURCE; } });
44
64
  var read_1 = require("./read");
45
65
  Object.defineProperty(exports, "inventoryDir", { enumerable: true, get: function () { return read_1.inventoryDir; } });
46
66
  Object.defineProperty(exports, "hubPath", { enumerable: true, get: function () { return read_1.hubPath; } });
@@ -52,3 +72,6 @@ Object.defineProperty(exports, "readLineage", { enumerable: true, get: function
52
72
  Object.defineProperty(exports, "repositoryLineage", { enumerable: true, get: function () { return read_1.repositoryLineage; } });
53
73
  Object.defineProperty(exports, "readCapabilities", { enumerable: true, get: function () { return read_1.readCapabilities; } });
54
74
  Object.defineProperty(exports, "repositoryCapabilities", { enumerable: true, get: function () { return read_1.repositoryCapabilities; } });
75
+ Object.defineProperty(exports, "readWhere", { enumerable: true, get: function () { return read_1.readWhere; } });
76
+ Object.defineProperty(exports, "readPackages", { enumerable: true, get: function () { return read_1.readPackages; } });
77
+ Object.defineProperty(exports, "repositoryImpact", { enumerable: true, get: function () { return read_1.repositoryImpact; } });
package/dist/join.d.ts CHANGED
@@ -2,6 +2,7 @@ import { type RepositoryMapping } from "@medicine-wheel/developer-repository-map
2
2
  import type { InventorySnapshot } from "@miadi/hooks-interpreter";
3
3
  import type { CapabilityFacet } from "@medicine-wheel/capabilities";
4
4
  import { type LineageEdge } from "./lineage";
5
+ import { type RepositoryWhere } from "./hosts";
5
6
  import type { RepositorySession, RepositorySummary, RepositoryView } from "./types";
6
7
  /** A record's `date` as YYYY-MM-DD: older records write a full timestamp, newer ones the day. */
7
8
  export declare function dayOf(date: string | undefined): string | undefined;
@@ -24,6 +25,6 @@ export declare function sessionsByRepository(records: ReadonlyMap<string, Invent
24
25
  * One repository: its rows when a hub holds them, its sessions, and its
25
26
  * lineage. Undefined when no hub, no record and no lineage names it.
26
27
  */
27
- export declare function repositoryView(repository: string, mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, sources?: Record<string, string>, lineageEdges?: readonly LineageEdge[], capabilityRows?: readonly CapabilityFacet[]): RepositoryView | undefined;
28
+ export declare function repositoryView(repository: string, mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, sources?: Record<string, string>, lineageEdges?: readonly LineageEdge[], capabilityRows?: readonly CapabilityFacet[], whereReadings?: readonly RepositoryWhere[]): RepositoryView | undefined;
28
29
  /** Every repository a hub holds, a record names or a lineage names, most sessions first. */
29
- export declare function listRepositories(mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, lineageEdges?: readonly LineageEdge[], capabilityRows?: readonly CapabilityFacet[]): RepositorySummary[];
30
+ export declare function listRepositories(mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, lineageEdges?: readonly LineageEdge[], capabilityRows?: readonly CapabilityFacet[], whereReadings?: readonly RepositoryWhere[]): RepositorySummary[];
package/dist/join.js CHANGED
@@ -15,6 +15,7 @@ exports.listRepositories = listRepositories;
15
15
  const developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
16
16
  const capabilities_1 = require("./capabilities");
17
17
  const lineage_1 = require("./lineage");
18
+ const hosts_1 = require("./hosts");
18
19
  const text = (value) => (typeof value === "string" && value.trim() ? value : undefined);
19
20
  /** A record's `date` as YYYY-MM-DD: older records write a full timestamp, newer ones the day. */
20
21
  function dayOf(date) {
@@ -36,6 +37,10 @@ function sessionOf(sessionId, snapshot) {
36
37
  const team = teamOf(snapshot);
37
38
  const disposition = dispositionOf(snapshot);
38
39
  const date = dayOf(snapshot.date);
40
+ const ep = snapshot.episode;
41
+ const episode = ep && (ep.number !== undefined || ep.folder)
42
+ ? { ...(ep.number !== undefined ? { number: ep.number } : {}), ...(ep.title ? { title: ep.title } : {}), ...(ep.folder ? { folder: ep.folder } : {}) }
43
+ : undefined;
39
44
  return {
40
45
  session_id: sessionId,
41
46
  ...(snapshot.tmux_session_name ? { tmux_session_name: snapshot.tmux_session_name } : {}),
@@ -46,6 +51,7 @@ function sessionOf(sessionId, snapshot) {
46
51
  work_completed: (snapshot.work_completed ?? []).map((item) => item.title),
47
52
  ...(disposition ? { disposition } : {}),
48
53
  ...(snapshot.evidence?.length ? { evidence: snapshot.evidence } : {}),
54
+ ...(episode ? { episode } : {}),
49
55
  modified_at: snapshot.modified_at,
50
56
  };
51
57
  }
@@ -80,7 +86,7 @@ const keyOfNode = (nodeId) => nodeId.slice("repository:".length).toLowerCase();
80
86
  * One repository: its rows when a hub holds them, its sessions, and its
81
87
  * lineage. Undefined when no hub, no record and no lineage names it.
82
88
  */
83
- function repositoryView(repository, mapping, bySessions, sources = {}, lineageEdges = [], capabilityRows = []) {
89
+ function repositoryView(repository, mapping, bySessions, sources = {}, lineageEdges = [], capabilityRows = [], whereReadings = []) {
84
90
  const key = repositoryKey(repository);
85
91
  if (!key)
86
92
  return undefined;
@@ -93,11 +99,32 @@ function repositoryView(repository, mapping, bySessions, sources = {}, lineageEd
93
99
  return undefined;
94
100
  const nodeId = row?.nodeId ?? named ?? `repository:${bySessions.spelled.get(key) ?? key}`;
95
101
  const { owner, name } = (0, developer_repository_mapping_1.parseRepositoryNodeId)(nodeId);
102
+ const where = (0, hosts_1.whereOf)(nodeId, whereReadings);
103
+ const url = (0, hosts_1.webUrlOf)(where);
104
+ const episodes = new Map();
105
+ for (const s of sessions) {
106
+ if (!s.episode)
107
+ continue;
108
+ const key = s.episode.folder ?? String(s.episode.number);
109
+ const known = episodes.get(key);
110
+ if (known)
111
+ known.sessions += 1;
112
+ else
113
+ episodes.set(key, { ...s.episode, sessions: 1 });
114
+ }
96
115
  return {
97
116
  nodeId,
98
117
  owner,
99
118
  name,
100
- url: (0, developer_repository_mapping_1.repositoryUrl)(nodeId),
119
+ ...(url ? { url } : {}),
120
+ where: {
121
+ host: where.host,
122
+ ...("url" in where && where.url ? { url: where.url } : {}),
123
+ ...("note" in where && where.note ? { note: where.note } : {}),
124
+ ...("private" in where && where.private ? { private: true } : {}),
125
+ ...("archived" in where && where.archived ? { archived: true } : {}),
126
+ },
127
+ episodes: [...episodes.values()].sort((a, b) => b.sessions - a.sessions || (b.number ?? 0) - (a.number ?? 0)),
101
128
  mapped: Boolean(row),
102
129
  ...(row ? { repository: row, reading: (0, developer_repository_mapping_1.reconcileLifecycle)(row) } : {}),
103
130
  ...(row && sources[row.nodeId] ? { source: sources[row.nodeId] } : {}),
@@ -112,7 +139,7 @@ function repositoryView(repository, mapping, bySessions, sources = {}, lineageEd
112
139
  };
113
140
  }
114
141
  /** Every repository a hub holds, a record names or a lineage names, most sessions first. */
115
- function listRepositories(mapping, bySessions, lineageEdges = [], capabilityRows = []) {
142
+ function listRepositories(mapping, bySessions, lineageEdges = [], capabilityRows = [], whereReadings = []) {
116
143
  const keys = new Set([
117
144
  ...bySessions.sessions.keys(),
118
145
  ...(mapping?.repositories ?? []).map((r) => keyOfNode(r.nodeId)),
@@ -121,13 +148,15 @@ function listRepositories(mapping, bySessions, lineageEdges = [], capabilityRows
121
148
  ]);
122
149
  return [...keys]
123
150
  .map((key) => {
124
- const view = repositoryView(key, mapping, bySessions, {}, lineageEdges, capabilityRows);
151
+ const view = repositoryView(key, mapping, bySessions, {}, lineageEdges, capabilityRows, whereReadings);
125
152
  const teams = [...new Set(view.sessions.flatMap((s) => (s.team ? [s.team] : [])))].sort();
126
153
  return {
127
154
  nodeId: view.nodeId,
128
155
  owner: view.owner,
129
156
  name: view.name,
130
157
  mapped: view.mapped,
158
+ host: view.where.host,
159
+ ...(view.url ? { url: view.url } : {}),
131
160
  ...(view.repository ? { lifecycle: view.repository.lifecycle } : {}),
132
161
  ...(view.reading ? { drift: view.reading.drift } : {}),
133
162
  sessions: view.sessions.length,
package/dist/lineage.d.ts CHANGED
@@ -16,9 +16,9 @@ export declare const LineageRowSchema: z.ZodEffects<z.ZodObject<{
16
16
  description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
17
17
  }, "strict", z.ZodTypeAny, {
18
18
  revision: "pending" | "revised" | "affirmed";
19
+ type: "learned-from";
19
20
  from: string;
20
21
  to: string;
21
- type: "learned-from";
22
22
  statedBy: string;
23
23
  statedAt: string;
24
24
  grounding: string[];
@@ -27,9 +27,9 @@ export declare const LineageRowSchema: z.ZodEffects<z.ZodObject<{
27
27
  revisedAt?: string | undefined;
28
28
  }, {
29
29
  revision: "pending" | "revised" | "affirmed";
30
+ type: "learned-from";
30
31
  from: string;
31
32
  to: string;
32
- type: "learned-from";
33
33
  statedBy: string;
34
34
  statedAt: string;
35
35
  grounding: string[];
@@ -38,9 +38,9 @@ export declare const LineageRowSchema: z.ZodEffects<z.ZodObject<{
38
38
  revisedAt?: string | undefined;
39
39
  }>, {
40
40
  revision: "pending" | "revised" | "affirmed";
41
+ type: "learned-from";
41
42
  from: string;
42
43
  to: string;
43
- type: "learned-from";
44
44
  statedBy: string;
45
45
  statedAt: string;
46
46
  grounding: string[];
@@ -49,9 +49,9 @@ export declare const LineageRowSchema: z.ZodEffects<z.ZodObject<{
49
49
  revisedAt?: string | undefined;
50
50
  }, {
51
51
  revision: "pending" | "revised" | "affirmed";
52
+ type: "learned-from";
52
53
  from: string;
53
54
  to: string;
54
- type: "learned-from";
55
55
  statedBy: string;
56
56
  statedAt: string;
57
57
  grounding: string[];
package/dist/read.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { SHIPPED_CAPABILITIES_SCANS } from "./shipped-capabilities";
2
+ import { type BumpLevel, type ImpactAnswer, type PackageReading } from "./impact";
3
+ import { type RepositoryWhere } from "./hosts";
2
4
  import { type CapabilityFacet } from "@medicine-wheel/capabilities";
3
5
  import { type CapabilityKind, type ProvidesEdge } from "./capabilities";
4
6
  import { type MappingIssue, type MergedMapping } from "@medicine-wheel/developer-repository-mapping";
@@ -19,7 +21,29 @@ export interface ReadOptions {
19
21
  lineage?: string;
20
22
  /** a capability JSONL read before the shipped rows; default `MIADI_REPOSITORY_CAPABILITIES` */
21
23
  capabilities?: string;
24
+ /** a where JSONL (`miadi-repomap where --write`) read before the shipped readings; default `MIADI_REPOSITORY_HOSTS` */
25
+ hosts?: string;
22
26
  }
27
+ export interface WhereRead {
28
+ /** the sources read, in precedence order */
29
+ from: string[];
30
+ readings: RepositoryWhere[];
31
+ issues: MappingIssue[];
32
+ }
33
+ /** Where repositories live: a host's own readings first, then the readings this package ships. */
34
+ export declare function readWhere(path?: string | undefined): WhereRead;
35
+ /** The packages the shipped scan read, with their versions and first-party ranges. */
36
+ export declare function readPackages(): {
37
+ packages: PackageReading[];
38
+ issues: MappingIssue[];
39
+ };
40
+ export interface ImpactRead {
41
+ scans: typeof SHIPPED_CAPABILITIES_SCANS;
42
+ issues: MappingIssue[];
43
+ impact?: ImpactAnswer;
44
+ }
45
+ /** What bumping a package touches: what it consumes, who consumes it, which ranges stop reaching the new version. */
46
+ export declare function repositoryImpact(packageOrCapability: string, bump?: BumpLevel): ImpactRead;
23
47
  export interface CapabilitiesRead {
24
48
  /** the sources read, in precedence order */
25
49
  from: string[];
@@ -73,6 +97,7 @@ export interface MapperRead {
73
97
  sessions: SessionsByRepository;
74
98
  lineage: LineageRead;
75
99
  capabilities: CapabilitiesRead;
100
+ where: WhereRead;
76
101
  }
77
102
  export declare function readMapper(options?: ReadOptions): Promise<MapperRead>;
78
103
  export declare function repositoryListing(options?: ReadOptions): Promise<RepositoryListing>;
package/dist/read.js CHANGED
@@ -5,6 +5,9 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.inventoryDir = inventoryDir;
7
7
  exports.hubPath = hubPath;
8
+ exports.readWhere = readWhere;
9
+ exports.readPackages = readPackages;
10
+ exports.repositoryImpact = repositoryImpact;
8
11
  exports.readCapabilities = readCapabilities;
9
12
  exports.repositoryCapabilities = repositoryCapabilities;
10
13
  exports.readLineage = readLineage;
@@ -16,6 +19,9 @@ exports.repositoryLineage = repositoryLineage;
16
19
  const node_fs_1 = require("node:fs");
17
20
  const shipped_lineage_1 = require("./shipped-lineage");
18
21
  const shipped_capabilities_1 = require("./shipped-capabilities");
22
+ const shipped_hosts_1 = require("./shipped-hosts");
23
+ const impact_1 = require("./impact");
24
+ const hosts_1 = require("./hosts");
19
25
  const capabilities_1 = require("@medicine-wheel/capabilities");
20
26
  const capabilities_2 = require("./capabilities");
21
27
  const node_os_1 = require("node:os");
@@ -33,6 +39,41 @@ function inventoryDir(env = process.env) {
33
39
  function hubPath(env = process.env) {
34
40
  return env.MIADI_REPOSITORY_MAPPING_HUB?.trim() || undefined;
35
41
  }
42
+ /** Where repositories live: a host's own readings first, then the readings this package ships. */
43
+ function readWhere(path = process.env.MIADI_REPOSITORY_HOSTS?.trim() || undefined) {
44
+ const texts = [];
45
+ const unread = [];
46
+ if (path) {
47
+ try {
48
+ texts.push({ text: (0, node_fs_1.readFileSync)(path, "utf8"), source: path });
49
+ }
50
+ catch (error) {
51
+ unread.push({ severity: "error", file: path, message: `hosts not read: ${error.message}` });
52
+ }
53
+ }
54
+ texts.push({ text: shipped_hosts_1.SHIPPED_HOSTS.map((r) => JSON.stringify(r)).join("\n"), source: shipped_hosts_1.SHIPPED_HOSTS_SOURCE });
55
+ const parsed = (0, hosts_1.parseWhere)(texts);
56
+ return { from: texts.map((t) => t.source), readings: parsed.readings, issues: [...unread, ...parsed.issues] };
57
+ }
58
+ /** The packages the shipped scan read, with their versions and first-party ranges. */
59
+ function readPackages() {
60
+ const packages = [];
61
+ const issues = [];
62
+ shipped_capabilities_1.SHIPPED_PACKAGES.forEach((row, index) => {
63
+ const parsed = impact_1.PackageReadingSchema.safeParse(row);
64
+ if (parsed.success)
65
+ packages.push(parsed.data);
66
+ else
67
+ issues.push({ severity: "error", file: shipped_capabilities_1.SHIPPED_CAPABILITIES_SOURCE, line: index + 1, message: parsed.error.issues.map((i) => i.message).join("; ") });
68
+ });
69
+ return { packages, issues };
70
+ }
71
+ /** What bumping a package touches: what it consumes, who consumes it, which ranges stop reaching the new version. */
72
+ function repositoryImpact(packageOrCapability, bump) {
73
+ const read = readPackages();
74
+ const impact = (0, impact_1.impactOf)(packageOrCapability, read.packages, bump);
75
+ return { scans: shipped_capabilities_1.SHIPPED_CAPABILITIES_SCANS, issues: read.issues, ...(impact ? { impact } : {}) };
76
+ }
36
77
  /**
37
78
  * The capabilities: a host's own JSONL first (`--capabilities` or
38
79
  * `MIADI_REPOSITORY_CAPABILITIES`), then the rows this package ships, scanned
@@ -131,19 +172,22 @@ async function readMapper(options = {}) {
131
172
  sessions,
132
173
  lineage: readLineage(options.lineage),
133
174
  capabilities: readCapabilities(options.capabilities),
175
+ where: readWhere(options.hosts),
134
176
  };
135
177
  }
136
178
  async function repositoryListing(options = {}) {
137
179
  const read = await readMapper(options);
180
+ const all = (0, join_1.listRepositories)(read.mapping, read.sessions, read.lineage.edges, read.capabilities.capabilities, read.where.readings);
138
181
  return {
139
182
  hub: read.hub,
140
183
  inventory: read.inventory,
141
- repositories: (0, join_1.listRepositories)(read.mapping, read.sessions, read.lineage.edges, read.capabilities.capabilities),
184
+ repositories: all.filter((r) => r.host !== "missing"),
185
+ missing: all.filter((r) => r.host === "missing"),
142
186
  };
143
187
  }
144
188
  async function repositoryDetail(repository, options = {}) {
145
189
  const read = await readMapper(options);
146
- const view = (0, join_1.repositoryView)(repository, read.mapping, read.sessions, read.mapping?.sources, read.lineage.edges, read.capabilities.capabilities);
190
+ const view = (0, join_1.repositoryView)(repository, read.mapping, read.sessions, read.mapping?.sources, read.lineage.edges, read.capabilities.capabilities, read.where.readings);
147
191
  return { hub: read.hub, inventory: read.inventory, ...(view ? { repository: view } : {}) };
148
192
  }
149
193
  /** "What did this repository learn from?", or with no repository, every lineage. Reads no hub and no inventory. */
package/dist/scan.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { CapabilityFacet } from "@medicine-wheel/capabilities";
2
+ import type { PackageReading } from "./impact";
2
3
  export interface ScanOptions {
3
4
  /** the ref to read; default the remote's default branch (`origin/HEAD`), else HEAD */
4
5
  ref?: string;
@@ -12,5 +13,7 @@ export interface ScanResult {
12
13
  ref: string;
13
14
  commit: string;
14
15
  capabilities: CapabilityFacet[];
16
+ /** each package's version and the ranges it declares, all of them */
17
+ packages: PackageReading[];
15
18
  }
16
19
  export declare function scanRepository(clone: string, options: ScanOptions): Promise<ScanResult>;
package/dist/scan.js CHANGED
@@ -39,10 +39,20 @@ async function scanRepository(clone, options) {
39
39
  const show = (path) => git(clone, ["show", `${commit}:${path}`]);
40
40
  const globs = (0, capabilities_1.workspaceGlobs)(await show("package.json"), files.includes("pnpm-workspace.yaml") ? await show("pnpm-workspace.yaml") : undefined);
41
41
  const artefacts = [];
42
+ const packages = [];
42
43
  for (const manifest of (0, capabilities_1.packageManifests)(globs, files)) {
43
44
  const pkg = (0, capabilities_1.parsePackageJson)((await show(manifest)) ?? "");
44
45
  if (!pkg.name)
45
46
  continue;
47
+ packages.push({
48
+ capability: (0, capabilities_1.capabilityId)("package", pkg.name),
49
+ name: pkg.name,
50
+ ...(pkg.version ? { version: pkg.version } : {}),
51
+ repository,
52
+ path: manifest,
53
+ commit: commit.slice(0, 12),
54
+ dependsOn: pkg.dependsOn,
55
+ });
46
56
  artefacts.push({ kind: "package", name: pkg.name, ...(pkg.description ? { description: pkg.description } : {}), path: manifest });
47
57
  for (const bin of pkg.bins) {
48
58
  artefacts.push({ kind: "cli", name: bin, description: `The ${bin} command, shipped by ${pkg.name}.`, path: manifest });
@@ -61,5 +71,6 @@ async function scanRepository(clone, options) {
61
71
  ref,
62
72
  commit,
63
73
  capabilities: (0, capabilities_1.capabilityRows)(artefacts, { repository, commit, observedBy: options.observedBy, observedAt }),
74
+ packages,
64
75
  };
65
76
  }
@@ -5,3 +5,4 @@ export declare const SHIPPED_CAPABILITIES_SCANS: readonly {
5
5
  observedAt: string;
6
6
  }[];
7
7
  export declare const SHIPPED_CAPABILITIES: readonly unknown[];
8
+ export declare const SHIPPED_PACKAGES: readonly unknown[];