@phosphorco/bb-cross-references 0.1.1 → 0.4.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/CONTRACT.md +263 -0
- package/README.md +41 -0
- package/dist/bb.js +1159 -66
- package/dist/index.js +1053 -65
- package/dist/react.js +991 -82
- package/dist/testing.js +67 -2
- package/dist/types/bb.d.ts +3196 -1
- package/dist/types/evidence-v2.d.ts +1608 -0
- package/dist/types/index.d.ts +789 -0
- package/dist/types/lookup.d.ts +10 -0
- package/dist/types/producer.d.ts +2270 -0
- package/dist/types/recognition.d.ts +29 -0
- package/dist/types/testing.d.ts +27 -0
- package/package.json +4 -3
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/testing.ts
|
|
2
10
|
import { canonicalizeIdentity, normalizeProjectionCommand, resourceIdentityOf } from "./index.js";
|
|
3
|
-
import { createCrossReferencesClient } from "./bb.js";
|
|
11
|
+
import { createCrossReferencesClient, createCrossReferencesV2Client } from "./bb.js";
|
|
4
12
|
async function runCrossReferencesConformance(options) {
|
|
5
13
|
const command = normalizeProjectionCommand(options.command);
|
|
6
14
|
if (command.tombstone || command.targets.length === 0)
|
|
@@ -43,6 +51,63 @@ async function runCrossReferencesConformance(options) {
|
|
|
43
51
|
checks.push("backlinks-acceptance");
|
|
44
52
|
return { level: "source-conformance", pluginId: client.pluginId, checks };
|
|
45
53
|
}
|
|
54
|
+
async function runCrossReferencesV2Conformance(options) {
|
|
55
|
+
const client = createCrossReferencesV2Client(options.sdk, options.pluginId);
|
|
56
|
+
await client.describe();
|
|
57
|
+
const page = await client.listMentions(options.input);
|
|
58
|
+
if (page.status !== "page")
|
|
59
|
+
throw new Error("V2 fixture must yield a page.");
|
|
60
|
+
await options.assertPage(page);
|
|
61
|
+
const { cursor: _cursor, ifSnapshot: _conditional, ...base } = options.input;
|
|
62
|
+
const conditional = await client.listMentions({ ...base, ifSnapshot: page.snapshot });
|
|
63
|
+
if (conditional.status !== "not-modified" || !conditional.coverage.authoredUrlCoverage.watermark)
|
|
64
|
+
throw new Error("V2 conditional omitted current coverage.");
|
|
65
|
+
const lookup = await client.resolveLookup(options.lookup);
|
|
66
|
+
if (!["ready", "ambiguous", "incomplete"].includes(lookup.state) || lookup.options.length === 0)
|
|
67
|
+
throw new Error("V2 lookup fixture did not resolve.");
|
|
68
|
+
return { level: "source-conformance", pluginId: client.pluginId, checks: ["describe-v2", "actual-evidence-page", "conditional-current-coverage", "query-normalization"] };
|
|
69
|
+
}
|
|
70
|
+
async function runCrossReferencesProducerConformance(options) {
|
|
71
|
+
const { createCrossReferencesProducerClient } = await import("./bb.js");
|
|
72
|
+
const client = createCrossReferencesProducerClient(options.sdk, options.pluginId), checks = [];
|
|
73
|
+
await client.describe();
|
|
74
|
+
checks.push("producer-describe");
|
|
75
|
+
const accepted = await client.apply(options.command);
|
|
76
|
+
if (!["applied", "duplicate", "equal"].includes(accepted.outcome) || !["installed", "replayed"].includes(accepted.evidenceDisposition) || accepted.state.evidence?.state !== "bound" || accepted.state.evidence.evidenceDigest !== options.command.evidenceDigest)
|
|
77
|
+
throw new Error("Producer fixture was not atomically bound.");
|
|
78
|
+
checks.push("atomic-graph-evidence");
|
|
79
|
+
const replay = await client.apply(options.command);
|
|
80
|
+
if (replay.evidenceDisposition !== "replayed" || replay.state.evidence?.evidenceDigest !== options.command.evidenceDigest)
|
|
81
|
+
throw new Error("Producer evidence replay failed.");
|
|
82
|
+
checks.push("evidence-replay");
|
|
83
|
+
if (options.blocked.expectedRevision !== options.command.projection.revision || options.blocked.attemptRevision <= options.command.projection.revision)
|
|
84
|
+
throw new Error("Blocked fixture must allocate above the accepted graph.");
|
|
85
|
+
const blocked = await client.reportStatus(options.blocked);
|
|
86
|
+
if (!["recorded", "duplicate"].includes(blocked.outcome) || blocked.state.projection?.revision !== options.command.projection.revision || blocked.state.revisionHighWater !== options.blocked.attemptRevision)
|
|
87
|
+
throw new Error("Status changed graph or lost prospective revision.");
|
|
88
|
+
checks.push("status-retains-last-good");
|
|
89
|
+
const current = await client.getState({ version: 1, producerPluginId: "thread-brief", source: options.blocked.source });
|
|
90
|
+
if (current.status?.statusDigest !== options.blocked.statusDigest || current.evidence?.evidenceDigest !== options.command.evidenceDigest)
|
|
91
|
+
throw new Error("GetState lost committed evidence/status.");
|
|
92
|
+
await options.assertState?.(current);
|
|
93
|
+
checks.push("producer-readback");
|
|
94
|
+
const oldReplay = await client.apply(options.command);
|
|
95
|
+
if (oldReplay.evidenceDisposition !== "replayed" || oldReplay.state.status?.attemptRevision !== options.blocked.attemptRevision)
|
|
96
|
+
throw new Error("An exact replay cleared newer blocked intent.");
|
|
97
|
+
checks.push("replay-preserves-newer-status");
|
|
98
|
+
return { level: "source-conformance", pluginId: client.pluginId, checks };
|
|
99
|
+
}
|
|
100
|
+
async function runBriefNavigationConformance(options) {
|
|
101
|
+
const { createBriefNavigationClient } = await import("./bb.js");
|
|
102
|
+
const client = createBriefNavigationClient(options.sdk);
|
|
103
|
+
await client.describe();
|
|
104
|
+
const result = await client.resolve(options.input);
|
|
105
|
+
await options.assertResult(result);
|
|
106
|
+
return { level: "source-conformance", pluginId: "thread-brief", checks: ["navigation-describe", "fixed-file-same-revision-proof"] };
|
|
107
|
+
}
|
|
46
108
|
export {
|
|
47
|
-
|
|
109
|
+
runCrossReferencesV2Conformance,
|
|
110
|
+
runCrossReferencesProducerConformance,
|
|
111
|
+
runCrossReferencesConformance,
|
|
112
|
+
runBriefNavigationConformance
|
|
48
113
|
};
|