@miadi/relational-git-repository-mapper 0.3.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/hosts.js ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ // Where a git repository lives, pure. A record or a scan names
3
+ // `repository:<owner>/<name>`, and that name does not say where the repository
4
+ // is: GitHub, a host's own git server (gaia's /srv/git holds jgwill/episodes,
5
+ // the chronicle vessel), or nowhere, when a record named a repository that
6
+ // does not exist. A reading says which, who checked and when; a repository no
7
+ // reading names is `unchecked`. Only a GitHub repository gets a GitHub link.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RepositoryWhereSchema = exports.RepositoryHostSchema = void 0;
10
+ exports.parseWhere = parseWhere;
11
+ exports.whereOf = whereOf;
12
+ exports.webUrlOf = webUrlOf;
13
+ const zod_1 = require("zod");
14
+ const capabilities_1 = require("@medicine-wheel/capabilities");
15
+ const developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
16
+ exports.RepositoryHostSchema = zod_1.z.enum(["github", "host-git", "missing", "unchecked"]);
17
+ exports.RepositoryWhereSchema = zod_1.z
18
+ .object({
19
+ repository: developer_repository_mapping_1.RepositoryNodeIdSchema,
20
+ host: exports.RepositoryHostSchema,
21
+ /** github: the web page; host-git: `<host>:<path>` of the bare repository */
22
+ url: zod_1.z.string().min(1).optional(),
23
+ private: zod_1.z.boolean().optional(),
24
+ archived: zod_1.z.boolean().optional(),
25
+ /** why, in a few words: "404 from GitHub with a token, no /srv/git/jgwill/x.git" */
26
+ note: zod_1.z.string().min(1).optional(),
27
+ checkedBy: zod_1.z.string().min(1),
28
+ checkedAt: capabilities_1.TimestampSchema,
29
+ })
30
+ .strict();
31
+ const fold = (id) => id.toLowerCase();
32
+ /**
33
+ * Readings from several JSONL texts, in precedence order: the first to name a
34
+ * repository speaks for it. Never throws.
35
+ */
36
+ function parseWhere(texts) {
37
+ const readings = [];
38
+ const issues = [];
39
+ const seen = new Set();
40
+ for (const { text, source } of texts) {
41
+ const parsed = (0, developer_repository_mapping_1.parseJsonl)(text, exports.RepositoryWhereSchema, source);
42
+ issues.push(...parsed.issues);
43
+ for (const row of parsed.rows) {
44
+ if (seen.has(fold(row.repository)))
45
+ continue;
46
+ seen.add(fold(row.repository));
47
+ readings.push(row);
48
+ }
49
+ }
50
+ return { readings, issues };
51
+ }
52
+ /** Where a repository lives, or `unchecked` when no reading names it. Matched case-folded. */
53
+ function whereOf(repository, readings) {
54
+ const id = repository.startsWith("repository:") ? repository : `repository:${repository}`;
55
+ return readings.find((r) => fold(r.repository) === fold(id)) ?? { repository: id, host: "unchecked" };
56
+ }
57
+ /** The web page of a repository: only GitHub repositories have one here. */
58
+ function webUrlOf(where) {
59
+ return where.host === "github" ? where.url : undefined;
60
+ }
@@ -0,0 +1,89 @@
1
+ import { z } from "zod";
2
+ export declare const PackageReadingSchema: z.ZodObject<{
3
+ /** `capability:package-…` */
4
+ capability: z.ZodString;
5
+ name: z.ZodString;
6
+ version: z.ZodOptional<z.ZodString>;
7
+ repository: z.ZodString;
8
+ path: z.ZodString;
9
+ commit: z.ZodString;
10
+ /** runtime dependencies as declared (dependencies, peer, optional): name → range */
11
+ dependsOn: z.ZodRecord<z.ZodString, z.ZodString>;
12
+ }, "strict", z.ZodTypeAny, {
13
+ name: string;
14
+ capability: string;
15
+ repository: string;
16
+ path: string;
17
+ commit: string;
18
+ dependsOn: Record<string, string>;
19
+ version?: string | undefined;
20
+ }, {
21
+ name: string;
22
+ capability: string;
23
+ repository: string;
24
+ path: string;
25
+ commit: string;
26
+ dependsOn: Record<string, string>;
27
+ version?: string | undefined;
28
+ }>;
29
+ export type PackageReading = z.infer<typeof PackageReadingSchema>;
30
+ export interface ConsumesEdge {
31
+ /** the consuming package's capability */
32
+ from: string;
33
+ /** the consumed package's capability */
34
+ to: string;
35
+ type: "consumes";
36
+ fromName: string;
37
+ toName: string;
38
+ /** the range `from` declares on `to` */
39
+ range: string;
40
+ }
41
+ /** `consumes` edges between the packages read, first-party only. */
42
+ export declare function consumesEdges(packages: readonly PackageReading[]): ConsumesEdge[];
43
+ export type BumpLevel = "major" | "minor" | "patch";
44
+ export declare function bumpVersion(version: string, level: BumpLevel): string | undefined;
45
+ /**
46
+ * Whether `version` satisfies `range`, for the forms first-party manifests
47
+ * use: exact, `^`, `~`, `>=`, `*`/`latest`/empty, and pnpm's `workspace:`
48
+ * forms, read as pnpm publishes them against `published` (the consumed
49
+ * package's version when the consumer was released). Undefined for anything
50
+ * else (`||`, `<`, `file:`, git URLs): read it by hand.
51
+ */
52
+ export declare function satisfies(version: string, range: string, published?: string): boolean | undefined;
53
+ export interface ImpactLink {
54
+ name: string;
55
+ capability: string;
56
+ repository: string;
57
+ version?: string;
58
+ /** the range the consumer declares (downstream) or this package declares (upstream) */
59
+ range: string;
60
+ }
61
+ export interface ImpactConsumer extends ImpactLink {
62
+ /** 1 for a direct consumer, 2 for a consumer of a consumer, … */
63
+ depth: number;
64
+ /** the consumer it is reached through, from depth 2 */
65
+ via?: string;
66
+ /** with a bump, depth 1: whether its range reaches the new version */
67
+ accepts?: boolean;
68
+ /** with a bump: what the consumer needs */
69
+ action?: string;
70
+ }
71
+ export interface ImpactAnswer {
72
+ package: {
73
+ name: string;
74
+ capability: string;
75
+ version?: string;
76
+ repository: string;
77
+ };
78
+ bump?: {
79
+ level: BumpLevel;
80
+ from: string;
81
+ to: string;
82
+ };
83
+ /** upstream: the first-party packages it consumes */
84
+ consumes: ImpactLink[];
85
+ /** downstream: who consumes it, directly or through others */
86
+ consumers: ImpactConsumer[];
87
+ }
88
+ /** The impact of a package, found by name (`@miadi/x`) or capability id; undefined when no reading names it. */
89
+ export declare function impactOf(packageOrCapability: string, packages: readonly PackageReading[], bump?: BumpLevel): ImpactAnswer | undefined;
package/dist/impact.js ADDED
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ // What a version bump touches, pure. The scan reads each package's version
3
+ // and the ranges it declares on other packages it maps; a `consumes` edge
4
+ // joins a package to each first-party package it depends on, across
5
+ // repositories. `impactOf` answers, for one package: what it consumes
6
+ // (upstream), who consumes it, directly and through others (downstream), and
7
+ // with a bump, which direct consumers' ranges stop reaching the new version.
8
+ // A range published with `workspace:*` pins the exact version, so its
9
+ // consumer is released again after any bump: the drift
10
+ // verify-published-deps reported when hooks-interpreter moved to 0.7.
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PackageReadingSchema = void 0;
13
+ exports.consumesEdges = consumesEdges;
14
+ exports.bumpVersion = bumpVersion;
15
+ exports.satisfies = satisfies;
16
+ exports.impactOf = impactOf;
17
+ const zod_1 = require("zod");
18
+ exports.PackageReadingSchema = zod_1.z
19
+ .object({
20
+ /** `capability:package-…` */
21
+ capability: zod_1.z.string().min(1),
22
+ name: zod_1.z.string().min(1),
23
+ version: zod_1.z.string().min(1).optional(),
24
+ repository: zod_1.z.string().min(1),
25
+ path: zod_1.z.string().min(1),
26
+ commit: zod_1.z.string().min(1),
27
+ /** runtime dependencies as declared (dependencies, peer, optional): name → range */
28
+ dependsOn: zod_1.z.record(zod_1.z.string()),
29
+ })
30
+ .strict();
31
+ /** `consumes` edges between the packages read, first-party only. */
32
+ function consumesEdges(packages) {
33
+ const byName = new Map(packages.map((p) => [p.name, p]));
34
+ return packages.flatMap((p) => Object.entries(p.dependsOn).flatMap(([name, range]) => {
35
+ const to = byName.get(name);
36
+ return to && to.name !== p.name ? [{ from: p.capability, to: to.capability, type: "consumes", fromName: p.name, toName: to.name, range }] : [];
37
+ }));
38
+ }
39
+ function parseVersion(v) {
40
+ const m = v ? /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(v.trim()) : null;
41
+ return m ? [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)] : undefined;
42
+ }
43
+ const cmp = (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
44
+ function bumpVersion(version, level) {
45
+ const v = parseVersion(version);
46
+ if (!v)
47
+ return undefined;
48
+ if (level === "major")
49
+ return `${v[0] + 1}.0.0`;
50
+ if (level === "minor")
51
+ return `${v[0]}.${v[1] + 1}.0`;
52
+ return `${v[0]}.${v[1]}.${v[2] + 1}`;
53
+ }
54
+ /**
55
+ * Whether `version` satisfies `range`, for the forms first-party manifests
56
+ * use: exact, `^`, `~`, `>=`, `*`/`latest`/empty, and pnpm's `workspace:`
57
+ * forms, read as pnpm publishes them against `published` (the consumed
58
+ * package's version when the consumer was released). Undefined for anything
59
+ * else (`||`, `<`, `file:`, git URLs): read it by hand.
60
+ */
61
+ function satisfies(version, range, published) {
62
+ const r = range.trim();
63
+ if (r.startsWith("workspace:")) {
64
+ const form = r.slice("workspace:".length);
65
+ if (!published)
66
+ return undefined;
67
+ if (form === "*" || form === "")
68
+ return satisfies(version, published);
69
+ if (form === "^" || form === "~")
70
+ return satisfies(version, `${form}${published}`);
71
+ return satisfies(version, form);
72
+ }
73
+ if (r === "*" || r === "" || r === "latest" || r === "x")
74
+ return true;
75
+ const v = parseVersion(version);
76
+ if (!v)
77
+ return undefined;
78
+ if (/^\^/.test(r)) {
79
+ const base = parseVersion(r.slice(1));
80
+ if (!base)
81
+ return undefined;
82
+ if (cmp(v, base) < 0)
83
+ return false;
84
+ if (base[0] > 0)
85
+ return v[0] === base[0];
86
+ if (base[1] > 0)
87
+ return v[0] === 0 && v[1] === base[1];
88
+ return v[0] === 0 && v[1] === 0 && v[2] === base[2];
89
+ }
90
+ if (/^~/.test(r)) {
91
+ const base = parseVersion(r.slice(1));
92
+ return base ? cmp(v, base) >= 0 && v[0] === base[0] && v[1] === base[1] : undefined;
93
+ }
94
+ if (/^>=/.test(r)) {
95
+ const base = parseVersion(r.slice(2));
96
+ return base ? cmp(v, base) >= 0 : undefined;
97
+ }
98
+ if (/^\d/.test(r) && !/[\s|<>]/.test(r)) {
99
+ const base = parseVersion(r);
100
+ return base ? cmp(v, base) === 0 : undefined;
101
+ }
102
+ return undefined;
103
+ }
104
+ /** The impact of a package, found by name (`@miadi/x`) or capability id; undefined when no reading names it. */
105
+ function impactOf(packageOrCapability, packages, bump) {
106
+ const target = packages.find((p) => p.name === packageOrCapability || p.capability === packageOrCapability);
107
+ if (!target)
108
+ return undefined;
109
+ const edges = consumesEdges(packages);
110
+ const byCapability = new Map(packages.map((p) => [p.capability, p]));
111
+ const to = bump && target.version ? bumpVersion(target.version, bump) : undefined;
112
+ const consumes = edges
113
+ .filter((e) => e.from === target.capability)
114
+ .map((e) => {
115
+ const p = byCapability.get(e.to);
116
+ return { name: p.name, capability: p.capability, repository: p.repository, ...(p.version ? { version: p.version } : {}), range: e.range };
117
+ });
118
+ const consumers = [];
119
+ const seen = new Set([target.capability]);
120
+ let frontier = [{ capability: target.capability }];
121
+ for (let depth = 1; frontier.length; depth++) {
122
+ const next = [];
123
+ for (const { capability } of frontier) {
124
+ for (const e of edges.filter((x) => x.to === capability)) {
125
+ if (seen.has(e.from))
126
+ continue;
127
+ seen.add(e.from);
128
+ const p = byCapability.get(e.from);
129
+ const link = {
130
+ name: p.name,
131
+ capability: p.capability,
132
+ repository: p.repository,
133
+ ...(p.version ? { version: p.version } : {}),
134
+ range: e.range,
135
+ depth,
136
+ ...(depth > 1 ? { via: byCapability.get(capability).name } : {}),
137
+ };
138
+ if (to && target.version) {
139
+ if (depth === 1) {
140
+ const accepts = satisfies(to, e.range, target.version);
141
+ if (accepts !== undefined)
142
+ link.accepts = accepts;
143
+ link.action =
144
+ accepts === true
145
+ ? `${e.range} already reaches ${to}`
146
+ : e.range.startsWith("workspace:")
147
+ ? `release ${p.name} again: ${e.range} is published as ${e.range === "workspace:*" ? target.version : `${e.range.slice(10)}${target.version}`}, which does not reach ${to}`
148
+ : accepts === false
149
+ ? `widen ${e.range} to reach ${to}, then release ${p.name}`
150
+ : `read ${e.range} by hand`;
151
+ }
152
+ else {
153
+ link.action = `downstream through ${link.via}`;
154
+ }
155
+ }
156
+ consumers.push(link);
157
+ next.push({ capability: e.from });
158
+ }
159
+ }
160
+ frontier = next;
161
+ }
162
+ consumers.sort((a, b) => a.depth - b.depth || a.name.localeCompare(b.name));
163
+ return {
164
+ package: { name: target.name, capability: target.capability, ...(target.version ? { version: target.version } : {}), repository: target.repository },
165
+ ...(to && bump && target.version ? { bump: { level: bump, from: target.version, to } } : {}),
166
+ consumes,
167
+ consumers,
168
+ };
169
+ }
package/dist/index.d.ts CHANGED
@@ -2,4 +2,12 @@ export type { RepositorySession, MappingState, HubState, RepositoryView, Reposit
2
2
  export { dayOf, teamOf, dispositionOf, sessionOf, repositoryKey, sessionsByRepository, repositoryView, listRepositories, type SessionsByRepository, } from "./join";
3
3
  export { LineageRowSchema, parseLineage, lineageOf, lineageGraph, type LineageRow, type LineageEdge, type LineageLink, type RepositoryLineage, type LineageGraph, } from "./lineage";
4
4
  export { SHIPPED_LINEAGE_JSONL, SHIPPED_LINEAGE_SOURCE } from "./shipped-lineage";
5
- export { inventoryDir, hubPath, readHubState, readMapper, repositoryListing, repositoryDetail, readLineage, repositoryLineage, type ReadOptions, type MapperRead, type LineageRead, type LineageAnswer, } from "./read";
5
+ export { CAPABILITY_KINDS, capabilityId, kindOf, parsePackageJson, parseSkillFrontMatter, workspaceGlobs, packageManifests, skillFiles, capabilityRows, mergeCapabilityRows, providesEdges, capabilitiesOf, type CapabilityKind, type Artefact, type CapabilityRowContext, type ProvidesEdge, } from "./capabilities";
6
+ export { SHIPPED_CAPABILITIES, SHIPPED_CAPABILITIES_SCANS, SHIPPED_CAPABILITIES_SOURCE } from "./shipped-capabilities";
7
+ export { scanRepository, type ScanOptions, type ScanResult } from "./scan";
8
+ export { PackageReadingSchema, consumesEdges, bumpVersion, satisfies, impactOf, type PackageReading, type ConsumesEdge, type BumpLevel, type ImpactLink, type ImpactConsumer, type ImpactAnswer, } from "./impact";
9
+ export { RepositoryHostSchema, RepositoryWhereSchema, parseWhere, whereOf, webUrlOf, type RepositoryHost, type RepositoryWhere, } from "./hosts";
10
+ export { checkWhere, type CheckWhereOptions } from "./where";
11
+ export { SHIPPED_PACKAGES } from "./shipped-capabilities";
12
+ export { SHIPPED_HOSTS, SHIPPED_HOSTS_SOURCE } from "./shipped-hosts";
13
+ export { inventoryDir, hubPath, readHubState, readMapper, repositoryListing, repositoryDetail, readLineage, repositoryLineage, readCapabilities, repositoryCapabilities, readWhere, readPackages, repositoryImpact, type ReadOptions, type MapperRead, type LineageRead, type LineageAnswer, type CapabilitiesRead, type CapabilitiesAnswer, type WhereRead, type ImpactRead, } from "./read";
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.repositoryLineage = exports.readLineage = exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = 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; } });
@@ -22,6 +23,44 @@ Object.defineProperty(exports, "lineageGraph", { enumerable: true, get: function
22
23
  var shipped_lineage_1 = require("./shipped-lineage");
23
24
  Object.defineProperty(exports, "SHIPPED_LINEAGE_JSONL", { enumerable: true, get: function () { return shipped_lineage_1.SHIPPED_LINEAGE_JSONL; } });
24
25
  Object.defineProperty(exports, "SHIPPED_LINEAGE_SOURCE", { enumerable: true, get: function () { return shipped_lineage_1.SHIPPED_LINEAGE_SOURCE; } });
26
+ var capabilities_1 = require("./capabilities");
27
+ Object.defineProperty(exports, "CAPABILITY_KINDS", { enumerable: true, get: function () { return capabilities_1.CAPABILITY_KINDS; } });
28
+ Object.defineProperty(exports, "capabilityId", { enumerable: true, get: function () { return capabilities_1.capabilityId; } });
29
+ Object.defineProperty(exports, "kindOf", { enumerable: true, get: function () { return capabilities_1.kindOf; } });
30
+ Object.defineProperty(exports, "parsePackageJson", { enumerable: true, get: function () { return capabilities_1.parsePackageJson; } });
31
+ Object.defineProperty(exports, "parseSkillFrontMatter", { enumerable: true, get: function () { return capabilities_1.parseSkillFrontMatter; } });
32
+ Object.defineProperty(exports, "workspaceGlobs", { enumerable: true, get: function () { return capabilities_1.workspaceGlobs; } });
33
+ Object.defineProperty(exports, "packageManifests", { enumerable: true, get: function () { return capabilities_1.packageManifests; } });
34
+ Object.defineProperty(exports, "skillFiles", { enumerable: true, get: function () { return capabilities_1.skillFiles; } });
35
+ Object.defineProperty(exports, "capabilityRows", { enumerable: true, get: function () { return capabilities_1.capabilityRows; } });
36
+ Object.defineProperty(exports, "mergeCapabilityRows", { enumerable: true, get: function () { return capabilities_1.mergeCapabilityRows; } });
37
+ Object.defineProperty(exports, "providesEdges", { enumerable: true, get: function () { return capabilities_1.providesEdges; } });
38
+ Object.defineProperty(exports, "capabilitiesOf", { enumerable: true, get: function () { return capabilities_1.capabilitiesOf; } });
39
+ var shipped_capabilities_1 = require("./shipped-capabilities");
40
+ Object.defineProperty(exports, "SHIPPED_CAPABILITIES", { enumerable: true, get: function () { return shipped_capabilities_1.SHIPPED_CAPABILITIES; } });
41
+ Object.defineProperty(exports, "SHIPPED_CAPABILITIES_SCANS", { enumerable: true, get: function () { return shipped_capabilities_1.SHIPPED_CAPABILITIES_SCANS; } });
42
+ Object.defineProperty(exports, "SHIPPED_CAPABILITIES_SOURCE", { enumerable: true, get: function () { return shipped_capabilities_1.SHIPPED_CAPABILITIES_SOURCE; } });
43
+ var scan_1 = require("./scan");
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; } });
25
64
  var read_1 = require("./read");
26
65
  Object.defineProperty(exports, "inventoryDir", { enumerable: true, get: function () { return read_1.inventoryDir; } });
27
66
  Object.defineProperty(exports, "hubPath", { enumerable: true, get: function () { return read_1.hubPath; } });
@@ -31,3 +70,8 @@ Object.defineProperty(exports, "repositoryListing", { enumerable: true, get: fun
31
70
  Object.defineProperty(exports, "repositoryDetail", { enumerable: true, get: function () { return read_1.repositoryDetail; } });
32
71
  Object.defineProperty(exports, "readLineage", { enumerable: true, get: function () { return read_1.readLineage; } });
33
72
  Object.defineProperty(exports, "repositoryLineage", { enumerable: true, get: function () { return read_1.repositoryLineage; } });
73
+ Object.defineProperty(exports, "readCapabilities", { enumerable: true, get: function () { return read_1.readCapabilities; } });
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
@@ -1,6 +1,8 @@
1
1
  import { type RepositoryMapping } from "@medicine-wheel/developer-repository-mapping";
2
2
  import type { InventorySnapshot } from "@miadi/hooks-interpreter";
3
+ import type { CapabilityFacet } from "@medicine-wheel/capabilities";
3
4
  import { type LineageEdge } from "./lineage";
5
+ import { type RepositoryWhere } from "./hosts";
4
6
  import type { RepositorySession, RepositorySummary, RepositoryView } from "./types";
5
7
  /** A record's `date` as YYYY-MM-DD: older records write a full timestamp, newer ones the day. */
6
8
  export declare function dayOf(date: string | undefined): string | undefined;
@@ -23,6 +25,6 @@ export declare function sessionsByRepository(records: ReadonlyMap<string, Invent
23
25
  * One repository: its rows when a hub holds them, its sessions, and its
24
26
  * lineage. Undefined when no hub, no record and no lineage names it.
25
27
  */
26
- export declare function repositoryView(repository: string, mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, sources?: Record<string, string>, lineageEdges?: readonly LineageEdge[]): 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;
27
29
  /** Every repository a hub holds, a record names or a lineage names, most sessions first. */
28
- export declare function listRepositories(mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, lineageEdges?: readonly LineageEdge[]): 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
@@ -13,7 +13,9 @@ exports.sessionsByRepository = sessionsByRepository;
13
13
  exports.repositoryView = repositoryView;
14
14
  exports.listRepositories = listRepositories;
15
15
  const developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
16
+ const capabilities_1 = require("./capabilities");
16
17
  const lineage_1 = require("./lineage");
18
+ const hosts_1 = require("./hosts");
17
19
  const text = (value) => (typeof value === "string" && value.trim() ? value : undefined);
18
20
  /** A record's `date` as YYYY-MM-DD: older records write a full timestamp, newer ones the day. */
19
21
  function dayOf(date) {
@@ -35,6 +37,10 @@ function sessionOf(sessionId, snapshot) {
35
37
  const team = teamOf(snapshot);
36
38
  const disposition = dispositionOf(snapshot);
37
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;
38
44
  return {
39
45
  session_id: sessionId,
40
46
  ...(snapshot.tmux_session_name ? { tmux_session_name: snapshot.tmux_session_name } : {}),
@@ -45,6 +51,7 @@ function sessionOf(sessionId, snapshot) {
45
51
  work_completed: (snapshot.work_completed ?? []).map((item) => item.title),
46
52
  ...(disposition ? { disposition } : {}),
47
53
  ...(snapshot.evidence?.length ? { evidence: snapshot.evidence } : {}),
54
+ ...(episode ? { episode } : {}),
48
55
  modified_at: snapshot.modified_at,
49
56
  };
50
57
  }
@@ -79,23 +86,45 @@ const keyOfNode = (nodeId) => nodeId.slice("repository:".length).toLowerCase();
79
86
  * One repository: its rows when a hub holds them, its sessions, and its
80
87
  * lineage. Undefined when no hub, no record and no lineage names it.
81
88
  */
82
- function repositoryView(repository, mapping, bySessions, sources = {}, lineageEdges = []) {
89
+ function repositoryView(repository, mapping, bySessions, sources = {}, lineageEdges = [], capabilityRows = [], whereReadings = []) {
83
90
  const key = repositoryKey(repository);
84
91
  if (!key)
85
92
  return undefined;
86
93
  const row = mapping?.repositories.find((r) => keyOfNode(r.nodeId) === key);
87
94
  const sessions = bySessions.sessions.get(key) ?? [];
88
95
  const lineage = (0, lineage_1.lineageOf)(key, lineageEdges);
89
- const named = lineageEdges.flatMap((e) => [e.from, e.to]).find((id) => keyOfNode(id) === key);
96
+ const named = lineageEdges.flatMap((e) => [e.from, e.to]).find((id) => keyOfNode(id) === key) ??
97
+ capabilityRows.flatMap((c) => c.providedBy).find((id) => id.startsWith("repository:") && keyOfNode(id) === key);
90
98
  if (!row && !sessions.length && !named)
91
99
  return undefined;
92
100
  const nodeId = row?.nodeId ?? named ?? `repository:${bySessions.spelled.get(key) ?? key}`;
93
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
+ }
94
115
  return {
95
116
  nodeId,
96
117
  owner,
97
118
  name,
98
- 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)),
99
128
  mapped: Boolean(row),
100
129
  ...(row ? { repository: row, reading: (0, developer_repository_mapping_1.reconcileLifecycle)(row) } : {}),
101
130
  ...(row && sources[row.nodeId] ? { source: sources[row.nodeId] } : {}),
@@ -103,27 +132,35 @@ function repositoryView(repository, mapping, bySessions, sources = {}, lineageEd
103
132
  relations: row ? mapping.relations.filter((r) => r.from === row.nodeId || r.to === row.nodeId) : [],
104
133
  sessions,
105
134
  lineage,
135
+ capabilities: (0, capabilities_1.capabilitiesOf)(nodeId, capabilityRows).map((c) => {
136
+ const kind = (0, capabilities_1.kindOf)(c.nodeId);
137
+ return kind ? { ...c, kind } : { ...c };
138
+ }),
106
139
  };
107
140
  }
108
141
  /** Every repository a hub holds, a record names or a lineage names, most sessions first. */
109
- function listRepositories(mapping, bySessions, lineageEdges = []) {
142
+ function listRepositories(mapping, bySessions, lineageEdges = [], capabilityRows = [], whereReadings = []) {
110
143
  const keys = new Set([
111
144
  ...bySessions.sessions.keys(),
112
145
  ...(mapping?.repositories ?? []).map((r) => keyOfNode(r.nodeId)),
113
146
  ...lineageEdges.flatMap((e) => [keyOfNode(e.from), keyOfNode(e.to)]),
147
+ ...capabilityRows.flatMap((c) => c.providedBy.filter((p) => p.startsWith("repository:")).map(keyOfNode)),
114
148
  ]);
115
149
  return [...keys]
116
150
  .map((key) => {
117
- const view = repositoryView(key, mapping, bySessions, {}, lineageEdges);
151
+ const view = repositoryView(key, mapping, bySessions, {}, lineageEdges, capabilityRows, whereReadings);
118
152
  const teams = [...new Set(view.sessions.flatMap((s) => (s.team ? [s.team] : [])))].sort();
119
153
  return {
120
154
  nodeId: view.nodeId,
121
155
  owner: view.owner,
122
156
  name: view.name,
123
157
  mapped: view.mapped,
158
+ host: view.where.host,
159
+ ...(view.url ? { url: view.url } : {}),
124
160
  ...(view.repository ? { lifecycle: view.repository.lifecycle } : {}),
125
161
  ...(view.reading ? { drift: view.reading.drift } : {}),
126
162
  sessions: view.sessions.length,
163
+ capabilities: view.capabilities.length,
127
164
  ...(view.sessions[0]?.date ? { last_session: view.sessions[0].date } : {}),
128
165
  teams,
129
166
  };
package/dist/lineage.d.ts CHANGED
@@ -15,46 +15,46 @@ export declare const LineageRowSchema: z.ZodEffects<z.ZodObject<{
15
15
  /** what was learned, at most 55 words */
16
16
  description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
17
17
  }, "strict", z.ZodTypeAny, {
18
+ revision: "pending" | "revised" | "affirmed";
19
+ type: "learned-from";
18
20
  from: string;
19
21
  to: string;
20
- type: "learned-from";
21
22
  statedBy: string;
22
23
  statedAt: string;
23
24
  grounding: string[];
24
- revision: "pending" | "revised" | "affirmed";
25
25
  description?: string | undefined;
26
26
  revisedBy?: string | undefined;
27
27
  revisedAt?: string | undefined;
28
28
  }, {
29
+ revision: "pending" | "revised" | "affirmed";
30
+ type: "learned-from";
29
31
  from: string;
30
32
  to: string;
31
- type: "learned-from";
32
33
  statedBy: string;
33
34
  statedAt: string;
34
35
  grounding: string[];
35
- revision: "pending" | "revised" | "affirmed";
36
36
  description?: string | undefined;
37
37
  revisedBy?: string | undefined;
38
38
  revisedAt?: string | undefined;
39
39
  }>, {
40
+ revision: "pending" | "revised" | "affirmed";
41
+ type: "learned-from";
40
42
  from: string;
41
43
  to: string;
42
- type: "learned-from";
43
44
  statedBy: string;
44
45
  statedAt: string;
45
46
  grounding: string[];
46
- revision: "pending" | "revised" | "affirmed";
47
47
  description?: string | undefined;
48
48
  revisedBy?: string | undefined;
49
49
  revisedAt?: string | undefined;
50
50
  }, {
51
+ revision: "pending" | "revised" | "affirmed";
52
+ type: "learned-from";
51
53
  from: string;
52
54
  to: string;
53
- type: "learned-from";
54
55
  statedBy: string;
55
56
  statedAt: string;
56
57
  grounding: string[];
57
- revision: "pending" | "revised" | "affirmed";
58
58
  description?: string | undefined;
59
59
  revisedBy?: string | undefined;
60
60
  revisedAt?: string | undefined;