@ekanos/harness 0.18.0 → 0.20.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/api-types.d.ts +490 -0
- package/dist/api-types.js +6 -0
- package/dist/api.d.ts +33 -0
- package/dist/api.js +36 -1
- package/dist/app.js +6 -1
- package/dist/internal/components/approvals-tray.d.ts +17 -0
- package/dist/internal/components/approvals-tray.js +116 -0
- package/dist/internal/components/ask-assistant-bridge.js +1 -1
- package/dist/internal/components/connect-controls.d.ts +12 -0
- package/dist/internal/components/connect-controls.js +69 -0
- package/dist/internal/components/connect-dialog.d.ts +19 -0
- package/dist/internal/components/connect-dialog.js +61 -0
- package/dist/internal/components/connect-panel.d.ts +25 -0
- package/dist/internal/components/connect-panel.js +292 -0
- package/dist/internal/components/connection-chip.d.ts +14 -0
- package/dist/internal/components/connection-chip.js +75 -0
- package/dist/internal/components/dashboard-grid.js +38 -24
- package/dist/internal/components/dev-toolbar.js +176 -103
- package/dist/internal/components/events-panel.d.ts +10 -0
- package/dist/internal/components/events-panel.js +111 -0
- package/dist/internal/components/health-panel.d.ts +4 -0
- package/dist/internal/components/health-panel.js +56 -0
- package/dist/internal/components/integration-badge.d.ts +29 -0
- package/dist/internal/components/integration-badge.js +105 -0
- package/dist/internal/components/local-oauth-panel.js +21 -1
- package/dist/internal/components/operation-runner-panel.d.ts +12 -0
- package/dist/internal/components/operation-runner-panel.js +331 -0
- package/dist/internal/components/provenance-banner.d.ts +12 -0
- package/dist/internal/components/provenance-banner.js +107 -0
- package/dist/internal/components/repo-connection.d.ts +10 -0
- package/dist/internal/components/repo-connection.js +32 -0
- package/dist/internal/components/run-log.d.ts +9 -0
- package/dist/internal/components/run-log.js +228 -0
- package/dist/internal/components/runtime-strip.d.ts +12 -0
- package/dist/internal/components/runtime-strip.js +158 -0
- package/dist/internal/components/schema-form.d.ts +13 -0
- package/dist/internal/components/schema-form.js +382 -0
- package/dist/internal/components/scrollable-nav.d.ts +12 -0
- package/dist/internal/components/scrollable-nav.js +68 -0
- package/dist/internal/components/surface-nav.d.ts +31 -1
- package/dist/internal/components/surface-nav.js +244 -31
- package/dist/internal/components/workflow-runner.d.ts +14 -0
- package/dist/internal/components/workflow-runner.js +104 -0
- package/dist/internal/lib/bundled-secrets.d.ts +9 -0
- package/dist/internal/lib/bundled-secrets.js +24 -0
- package/dist/internal/lib/chrome-slot.d.ts +2 -0
- package/dist/internal/lib/chrome-slot.js +25 -0
- package/dist/internal/lib/connection-facts.d.ts +44 -0
- package/dist/internal/lib/connection-facts.js +116 -0
- package/dist/internal/lib/console-client.d.ts +55 -0
- package/dist/internal/lib/console-client.js +295 -0
- package/dist/internal/lib/console-context.d.ts +56 -0
- package/dist/internal/lib/console-context.js +67 -0
- package/dist/internal/lib/console-hooks.d.ts +33 -0
- package/dist/internal/lib/console-hooks.js +118 -0
- package/dist/internal/lib/console-types.d.ts +279 -0
- package/dist/internal/lib/console-types.js +0 -0
- package/dist/internal/lib/experience-runtime.d.ts +8 -0
- package/dist/internal/lib/experience-runtime.js +22 -0
- package/dist/internal/lib/preview-sections.d.ts +13 -0
- package/dist/internal/lib/preview-sections.js +32 -0
- package/dist/internal/lib/repo-context.d.ts +20 -0
- package/dist/internal/lib/repo-context.js +64 -0
- package/dist/internal/lib/run-log-view.d.ts +24 -0
- package/dist/internal/lib/run-log-view.js +57 -0
- package/dist/internal/lib/schema-form-model.d.ts +34 -0
- package/dist/internal/lib/schema-form-model.js +272 -0
- package/dist/internal/lib/toolbar-context.d.ts +9 -1
- package/dist/internal/lib/toolbar-context.js +13 -3
- package/dist/internal/lib/toolbar-visibility.d.ts +16 -0
- package/dist/internal/lib/toolbar-visibility.js +31 -0
- package/dist/internal/registry-context.d.ts +2 -0
- package/dist/internal/registry-context.js +11 -9
- package/dist/internal/routes/activation-page.js +44 -20
- package/dist/internal/routes/console-home-page.d.ts +5 -0
- package/dist/internal/routes/console-home-page.js +18 -0
- package/dist/internal/routes/experience-connect-page.d.ts +6 -0
- package/dist/internal/routes/experience-connect-page.js +127 -0
- package/dist/internal/routes/experience-layout-page.d.ts +8 -0
- package/dist/internal/routes/experience-layout-page.js +126 -0
- package/dist/internal/routes/experience-page-host.d.ts +7 -0
- package/dist/internal/routes/experience-page-host.js +79 -0
- package/dist/internal/routes/experience-review-queue-page.d.ts +2 -0
- package/dist/internal/routes/experience-review-queue-page.js +60 -0
- package/dist/internal/routes/experience-runs-page.d.ts +1 -0
- package/dist/internal/routes/experience-runs-page.js +13 -0
- package/dist/internal/routes/experience-summary-page.d.ts +1 -0
- package/dist/internal/routes/experience-summary-page.js +101 -0
- package/dist/internal/routes/experience-widget-page.d.ts +1 -0
- package/dist/internal/routes/experience-widget-page.js +26 -0
- package/dist/internal/routes/experience-widgets-page.d.ts +6 -0
- package/dist/internal/routes/experience-widgets-page.js +22 -0
- package/dist/internal/routes/experience-workflow-page.d.ts +1 -0
- package/dist/internal/routes/experience-workflow-page.js +24 -0
- package/dist/internal/routes/experience-workflows-page.d.ts +1 -0
- package/dist/internal/routes/experience-workflows-page.js +44 -0
- package/dist/internal/routes/index-page.d.ts +10 -9
- package/dist/internal/routes/index-page.js +3 -68
- package/dist/internal/routes/integration-layout.d.ts +12 -1
- package/dist/internal/routes/integration-layout.js +20 -6
- package/dist/internal/routes/integrations-connect-page.d.ts +1 -0
- package/dist/internal/routes/integrations-connect-page.js +19 -0
- package/dist/internal/routes/integrations-events-page.d.ts +1 -0
- package/dist/internal/routes/integrations-events-page.js +10 -0
- package/dist/internal/routes/integrations-health-page.d.ts +1 -0
- package/dist/internal/routes/integrations-health-page.js +10 -0
- package/dist/internal/routes/integrations-layout.d.ts +17 -0
- package/dist/internal/routes/integrations-layout.js +106 -0
- package/dist/internal/routes/integrations-list-page.d.ts +2 -0
- package/dist/internal/routes/integrations-list-page.js +94 -0
- package/dist/internal/routes/integrations-operation-page.d.ts +1 -0
- package/dist/internal/routes/integrations-operation-page.js +29 -0
- package/dist/internal/routes/integrations-operations-page.d.ts +1 -0
- package/dist/internal/routes/integrations-operations-page.js +61 -0
- package/dist/internal/routes/integrations-overview-page.d.ts +1 -0
- package/dist/internal/routes/integrations-overview-page.js +90 -0
- package/dist/internal/routes/integrations-runs-page.d.ts +1 -0
- package/dist/internal/routes/integrations-runs-page.js +14 -0
- package/dist/internal/routes/integrations-scope.d.ts +12 -0
- package/dist/internal/routes/integrations-scope.js +39 -0
- package/dist/internal/routes/legacy-preview-redirect.d.ts +6 -0
- package/dist/internal/routes/legacy-preview-redirect.js +12 -0
- package/dist/internal/routes/preview-index-page.d.ts +2 -0
- package/dist/internal/routes/preview-index-page.js +14 -0
- package/dist/internal/routes/repo-connections-page.d.ts +6 -0
- package/dist/internal/routes/repo-connections-page.js +8 -0
- package/dist/internal/routes/repo-home-page.d.ts +2 -0
- package/dist/internal/routes/repo-home-page.js +320 -0
- package/dist/internal/routes/repo-layout.d.ts +7 -0
- package/dist/internal/routes/repo-layout.js +76 -0
- package/dist/internal/routes/repo-package-layouts.d.ts +20 -0
- package/dist/internal/routes/repo-package-layouts.js +104 -0
- package/dist/internal/routes/root-layout.d.ts +3 -1
- package/dist/internal/routes/root-layout.js +13 -3
- package/dist/internal/routes/single-widget-page.js +5 -12
- package/dist/internal/routes/tile-page.js +20 -41
- package/dist/internal/routes/triggers-page.js +55 -62
- package/dist/internal/routes/widgets-page.js +1 -1
- package/dist/internal/server/api-router.js +46 -4
- package/dist/internal/server/approvals.d.ts +44 -0
- package/dist/internal/server/approvals.js +76 -0
- package/dist/internal/server/contract-sources.d.ts +28 -0
- package/dist/internal/server/contract-sources.js +83 -0
- package/dist/internal/server/definition-loader.d.ts +22 -0
- package/dist/internal/server/definition-loader.js +125 -0
- package/dist/internal/server/ekanos-api-router.d.ts +34 -0
- package/dist/internal/server/ekanos-api-router.js +835 -0
- package/dist/internal/server/experience-loader.d.ts +57 -0
- package/dist/internal/server/experience-loader.js +146 -0
- package/dist/internal/server/integration-lookup.d.ts +29 -0
- package/dist/internal/server/integration-lookup.js +33 -0
- package/dist/internal/server/integration-resolver.d.ts +121 -0
- package/dist/internal/server/integration-resolver.js +605 -0
- package/dist/internal/server/live-invoker.d.ts +11 -0
- package/dist/internal/server/live-invoker.js +106 -0
- package/dist/internal/server/local-secrets.d.ts +82 -1
- package/dist/internal/server/local-secrets.js +112 -1
- package/dist/internal/server/local-state.d.ts +12 -0
- package/dist/internal/server/local-state.js +45 -0
- package/dist/internal/server/oauth-persistence.d.ts +19 -0
- package/dist/internal/server/oauth-persistence.js +76 -0
- package/dist/internal/server/operation-runner.d.ts +95 -0
- package/dist/internal/server/operation-runner.js +231 -0
- package/dist/internal/server/project-manifest.d.ts +71 -0
- package/dist/internal/server/project-manifest.js +215 -0
- package/dist/internal/server/registry-cache.d.ts +68 -0
- package/dist/internal/server/registry-cache.js +328 -0
- package/dist/internal/server/repo-api-router.d.ts +33 -0
- package/dist/internal/server/repo-api-router.js +391 -0
- package/dist/internal/server/run-log.d.ts +22 -0
- package/dist/internal/server/run-log.js +32 -0
- package/dist/internal/server/semantics.d.ts +28 -0
- package/dist/internal/server/semantics.js +67 -0
- package/dist/internal/server/session-catalog.d.ts +67 -0
- package/dist/internal/server/session-catalog.js +18 -0
- package/dist/internal/server/workflow-runner.d.ts +36 -0
- package/dist/internal/server/workflow-runner.js +183 -0
- package/dist/registry.d.ts +7 -0
- package/dist/resolver.d.ts +145 -0
- package/dist/resolver.js +211 -0
- package/dist/routes.d.ts +66 -2
- package/dist/routes.js +61 -3
- package/dist/runtime.d.ts +46 -0
- package/dist/runtime.js +60 -0
- package/package.json +23 -9
- package/dist/internal/routes/integration-index-page.d.ts +0 -13
- package/dist/internal/routes/integration-index-page.js +0 -17
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compatLine
|
|
3
|
+
} from "@ekanos/integration-schema";
|
|
4
|
+
import {
|
|
5
|
+
RepoManifestError,
|
|
6
|
+
discoverRepo,
|
|
7
|
+
findRepoRoot
|
|
8
|
+
} from "@ekanos/integration-schema/repo";
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
import {
|
|
12
|
+
availableLines,
|
|
13
|
+
listContractsInDir,
|
|
14
|
+
pickLine,
|
|
15
|
+
readContractFile,
|
|
16
|
+
readShippedContract
|
|
17
|
+
} from "./contract-sources.js";
|
|
18
|
+
import {
|
|
19
|
+
loadDefinitionFromPackage,
|
|
20
|
+
loadDefinitionFromSource
|
|
21
|
+
} from "./definition-loader.js";
|
|
22
|
+
import {
|
|
23
|
+
readLockfile,
|
|
24
|
+
readProjectManifest,
|
|
25
|
+
readProjectOverrides
|
|
26
|
+
} from "./project-manifest.js";
|
|
27
|
+
import {
|
|
28
|
+
ensurePublishedIntegration
|
|
29
|
+
} from "./registry-cache.js";
|
|
30
|
+
function repoOf(projectRoot, notices) {
|
|
31
|
+
const root = findRepoRoot(projectRoot);
|
|
32
|
+
if (!root) return null;
|
|
33
|
+
try {
|
|
34
|
+
return discoverRepo(root);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (!(error instanceof RepoManifestError)) throw error;
|
|
37
|
+
notices?.push(`repo ${error.message} Resolving without the repo.`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function sameRepoPackage(repo, projectRoot, name) {
|
|
42
|
+
if (!repo) return null;
|
|
43
|
+
const here = path.resolve(projectRoot);
|
|
44
|
+
return repo.packages.find(
|
|
45
|
+
(pkg) => pkg.kind === "integration" && pkg.name === name && pkg.dir !== here
|
|
46
|
+
) ?? null;
|
|
47
|
+
}
|
|
48
|
+
function relativeToRepo(repo, dir) {
|
|
49
|
+
if (!repo) return void 0;
|
|
50
|
+
const rel = path.relative(repo.root, dir);
|
|
51
|
+
return rel && !rel.startsWith("..") && !path.isAbsolute(rel) ? rel.split(path.sep).join("/") : void 0;
|
|
52
|
+
}
|
|
53
|
+
function opKey(id) {
|
|
54
|
+
const parts = id.split("/");
|
|
55
|
+
return parts.slice(1).join("/");
|
|
56
|
+
}
|
|
57
|
+
function readPackageVersion(dir) {
|
|
58
|
+
try {
|
|
59
|
+
const parsed = JSON.parse(
|
|
60
|
+
fs.readFileSync(path.join(dir, "package.json"), "utf8")
|
|
61
|
+
);
|
|
62
|
+
return typeof parsed.version === "string" ? parsed.version : "0.0.0";
|
|
63
|
+
} catch {
|
|
64
|
+
return "0.0.0";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function findOperation(contract, id) {
|
|
68
|
+
return contract.operations.find((operation) => operation.id === id);
|
|
69
|
+
}
|
|
70
|
+
function pinProblems(entry, contract, lines) {
|
|
71
|
+
const problems = [];
|
|
72
|
+
if (contract.compatLine !== entry.version) {
|
|
73
|
+
const known = lines.length > 0 ? lines : [contract.compatLine];
|
|
74
|
+
problems.push(
|
|
75
|
+
`integration "${entry.name}" pins ${entry.name}@${entry.version} but the resolver has versions [${known.join(", ")}].`
|
|
76
|
+
);
|
|
77
|
+
return problems;
|
|
78
|
+
}
|
|
79
|
+
for (const id of entry.operations) {
|
|
80
|
+
const expectedPrefix = `${entry.name}@${entry.version}/`;
|
|
81
|
+
if (!id.startsWith(expectedPrefix) || !findOperation(contract, id)) {
|
|
82
|
+
problems.push(
|
|
83
|
+
`integration "${entry.name}": ${entry.name}@${entry.version} does not provide ${opKey(id) || id}.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return problems;
|
|
88
|
+
}
|
|
89
|
+
async function resolveIntegrations(options) {
|
|
90
|
+
const env = options.env ?? process.env;
|
|
91
|
+
const manifest = options.manifest ?? readProjectManifest(options.projectRoot);
|
|
92
|
+
const result = {
|
|
93
|
+
kind: manifest.kind,
|
|
94
|
+
integrations: [],
|
|
95
|
+
overrides: [],
|
|
96
|
+
notices: [],
|
|
97
|
+
errors: []
|
|
98
|
+
};
|
|
99
|
+
const overridesInfo = options.ignoreOverrides ? { overrides: [], bindingMode: {}, deprecatedSlotsKey: false } : readProjectOverrides(
|
|
100
|
+
options.projectRoot,
|
|
101
|
+
env,
|
|
102
|
+
manifest.integrations.map((entry) => entry.name),
|
|
103
|
+
manifest.renames
|
|
104
|
+
);
|
|
105
|
+
const repo = options.repo !== void 0 ? options.repo : manifest.kind === "experience" ? repoOf(options.projectRoot, result.notices) : null;
|
|
106
|
+
const repoModes = /* @__PURE__ */ new Map();
|
|
107
|
+
overridesInfo.overrides = overridesInfo.overrides.filter((override) => {
|
|
108
|
+
const pkg = sameRepoPackage(
|
|
109
|
+
repo,
|
|
110
|
+
options.projectRoot,
|
|
111
|
+
override.integration
|
|
112
|
+
);
|
|
113
|
+
const isRepoPackage = pkg !== null && pkg.dir === override.path;
|
|
114
|
+
if (isRepoPackage) repoModes.set(override.integration, override.mode);
|
|
115
|
+
return !isRepoPackage;
|
|
116
|
+
});
|
|
117
|
+
const lock = readLockfile(options.projectRoot);
|
|
118
|
+
if (manifest.deprecatedUses) {
|
|
119
|
+
result.notices.push(
|
|
120
|
+
'ekanos.json "uses" is deprecated: an experience declares the integrations it depends on as "integrations" (name = the integration, version = the compat line). Run "ekanos sync" to rewrite it.'
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
if (overridesInfo.deprecatedSlotsKey) {
|
|
124
|
+
result.notices.push(
|
|
125
|
+
'ekanos.local.json "slots" is deprecated: rename the key to "integrations".'
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (manifest.kind === "integration") {
|
|
129
|
+
await resolveSelf(manifest, options, result);
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
const overrideByIntegration = new Map(
|
|
133
|
+
overridesInfo.overrides.map((override) => [override.integration, override])
|
|
134
|
+
);
|
|
135
|
+
for (const override of overridesInfo.overrides) {
|
|
136
|
+
if (!manifest.integrations.some(
|
|
137
|
+
(entry) => entry.name === override.integration
|
|
138
|
+
)) {
|
|
139
|
+
result.errors.push({
|
|
140
|
+
integration: override.integration,
|
|
141
|
+
message: `override for unknown integration "${override.integration}": ekanos.json "integrations" declares [${manifest.integrations.map((u) => u.name).join(", ")}].`
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const contractsDir = options.contractsDir ?? env.EKANOS_CONTRACTS_DIR?.trim() ?? void 0;
|
|
146
|
+
const snapshotDir = path.resolve(options.projectRoot, manifest.contractsDir);
|
|
147
|
+
for (const entry of manifest.integrations) {
|
|
148
|
+
const override = overrideByIntegration.get(entry.name);
|
|
149
|
+
const bindingMode = overridesInfo.bindingMode[entry.name] ?? entry.modes[0] ?? "team";
|
|
150
|
+
const repoPackage = override ? null : sameRepoPackage(repo, options.projectRoot, entry.name);
|
|
151
|
+
try {
|
|
152
|
+
const resolved = override ? await resolveLocal(
|
|
153
|
+
entry,
|
|
154
|
+
override,
|
|
155
|
+
bindingMode,
|
|
156
|
+
options,
|
|
157
|
+
snapshotDir,
|
|
158
|
+
result
|
|
159
|
+
) : repoPackage ? await resolveLocal(
|
|
160
|
+
entry,
|
|
161
|
+
{
|
|
162
|
+
integration: entry.name,
|
|
163
|
+
path: repoPackage.dir,
|
|
164
|
+
mode: repoModes.get(entry.name) ?? "fixtures",
|
|
165
|
+
via: "file"
|
|
166
|
+
},
|
|
167
|
+
bindingMode,
|
|
168
|
+
options,
|
|
169
|
+
snapshotDir,
|
|
170
|
+
result,
|
|
171
|
+
true
|
|
172
|
+
) : await resolveRegistry(
|
|
173
|
+
entry,
|
|
174
|
+
bindingMode,
|
|
175
|
+
options,
|
|
176
|
+
contractsDir,
|
|
177
|
+
snapshotDir,
|
|
178
|
+
result
|
|
179
|
+
);
|
|
180
|
+
if (!resolved) continue;
|
|
181
|
+
if (resolved.provenance.kind === "local") {
|
|
182
|
+
const relPath = relativeToRepo(repo, resolved.provenance.path);
|
|
183
|
+
if (relPath) resolved.provenance.relPath = relPath;
|
|
184
|
+
}
|
|
185
|
+
const locked = lock[entry.name];
|
|
186
|
+
if (locked && locked.digest !== resolved.contract.digest) {
|
|
187
|
+
result.notices.push(
|
|
188
|
+
`contract drifted for integration "${entry.name}" (${entry.name}@${entry.version}): ekanos.lock.json pins ${locked.digest.slice(0, 15)}\u2026 but the resolver found ${resolved.contract.digest.slice(0, 15)}\u2026. Run "ekanos sync" to accept.`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
result.integrations.push(resolved);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
result.errors.push({
|
|
194
|
+
integration: entry.name,
|
|
195
|
+
message: error instanceof Error ? error.message : String(error)
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
result.overrides = overridesInfo.overrides.filter((o) => manifest.integrations.some((u) => u.name === o.integration)).map(toActiveOverride);
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
async function resolveSelf(manifest, options, result) {
|
|
203
|
+
const slug = manifest.slug;
|
|
204
|
+
if (!slug || !manifest.entry) return;
|
|
205
|
+
try {
|
|
206
|
+
const load = options.loadSourceDefinition ?? loadDefinitionFromSource;
|
|
207
|
+
const definition = await load(options.projectRoot);
|
|
208
|
+
const packageVersion = readPackageVersion(options.projectRoot);
|
|
209
|
+
const repo = options.repo !== void 0 ? options.repo : repoOf(options.projectRoot, result.notices);
|
|
210
|
+
const here = path.resolve(options.projectRoot);
|
|
211
|
+
const inRepo = Boolean(
|
|
212
|
+
repo?.packages.some(
|
|
213
|
+
(pkg) => pkg.kind === "integration" && path.resolve(pkg.dir) === here
|
|
214
|
+
)
|
|
215
|
+
);
|
|
216
|
+
const relPath = inRepo ? relativeToRepo(repo, here) : void 0;
|
|
217
|
+
const contract = await contractForOverride({
|
|
218
|
+
definition,
|
|
219
|
+
projectDir: options.projectRoot,
|
|
220
|
+
packageVersion,
|
|
221
|
+
derive: options.deriveContract
|
|
222
|
+
});
|
|
223
|
+
if (!contract) {
|
|
224
|
+
result.errors.push({
|
|
225
|
+
integration: slug,
|
|
226
|
+
message: `${slug}: no contract.json and none could be derived; run "ekanos contract".`
|
|
227
|
+
});
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
result.integrations.push({
|
|
231
|
+
integration: slug,
|
|
232
|
+
version: contract.compatLine,
|
|
233
|
+
required: "required",
|
|
234
|
+
operations: contract.operations.map((operation) => operation.id),
|
|
235
|
+
modes: ["team"],
|
|
236
|
+
bindingMode: "team",
|
|
237
|
+
provenance: {
|
|
238
|
+
kind: "local",
|
|
239
|
+
path: options.projectRoot,
|
|
240
|
+
packageVersion,
|
|
241
|
+
contractVersion: contract.contractVersion,
|
|
242
|
+
digest: contract.digest,
|
|
243
|
+
...inRepo ? { scope: "repo" } : {},
|
|
244
|
+
...relPath ? { relPath } : {}
|
|
245
|
+
},
|
|
246
|
+
contract,
|
|
247
|
+
runModes: ["fixtures", "live"],
|
|
248
|
+
defaultMode: "fixtures",
|
|
249
|
+
canDevelop: true,
|
|
250
|
+
self: true,
|
|
251
|
+
credentialRoot: options.projectRoot,
|
|
252
|
+
loadDefinition: async () => definition
|
|
253
|
+
});
|
|
254
|
+
} catch (error) {
|
|
255
|
+
result.errors.push({
|
|
256
|
+
integration: slug,
|
|
257
|
+
message: error instanceof Error ? error.message : String(error)
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function toActiveOverride(override) {
|
|
262
|
+
return {
|
|
263
|
+
integration: override.integration,
|
|
264
|
+
path: override.path,
|
|
265
|
+
via: override.via,
|
|
266
|
+
mode: override.mode
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async function resolveLocal(entry, override, bindingMode, options, snapshotDir, result, sameRepo = false) {
|
|
270
|
+
const fail = (message) => {
|
|
271
|
+
result.errors.push({ integration: entry.name, message });
|
|
272
|
+
return null;
|
|
273
|
+
};
|
|
274
|
+
if (!fs.existsSync(path.join(override.path, "ekanos.json"))) {
|
|
275
|
+
return fail(
|
|
276
|
+
`integration "${entry.name}": override path ${override.path} has no ekanos.json.`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
let overrideManifest;
|
|
280
|
+
try {
|
|
281
|
+
overrideManifest = readProjectManifest(override.path);
|
|
282
|
+
} catch (error) {
|
|
283
|
+
return fail(
|
|
284
|
+
`integration "${entry.name}": ${error instanceof Error ? error.message : String(error)}`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (!overrideManifest.slugs.includes(entry.name)) {
|
|
288
|
+
return fail(
|
|
289
|
+
`integration "${entry.name}": override at ${override.path} is integration "${overrideManifest.slug ?? "(none)"}", but the integration uses "${entry.name}".`
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
let canDevelop = sameRepo ? true : "unverified";
|
|
293
|
+
if (sameRepo) {
|
|
294
|
+
} else if (options.catalog) {
|
|
295
|
+
const row = options.catalog.products.find(
|
|
296
|
+
(product) => product.slug === entry.name
|
|
297
|
+
);
|
|
298
|
+
const seat = options.catalog.viewer.roles.length > 0;
|
|
299
|
+
canDevelop = Boolean(row && row.owned === true && seat);
|
|
300
|
+
if (!canDevelop) {
|
|
301
|
+
return fail(
|
|
302
|
+
`integration "${entry.name}": override-not-permitted \u2014 your Source does not hold develop on "${entry.name}", so you cannot override it locally.`
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
result.notices.push(
|
|
307
|
+
`integration "${entry.name}": local override of "${entry.name}" has an unverified permission (no CLI session catalog); it is allowed locally and publish stays blocked.`
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
const loadSource = options.loadSourceDefinition ?? loadDefinitionFromSource;
|
|
311
|
+
const definition = await loadSource(override.path);
|
|
312
|
+
const packageVersion = readPackageVersion(override.path);
|
|
313
|
+
const contract = await contractForOverride({
|
|
314
|
+
definition,
|
|
315
|
+
projectDir: override.path,
|
|
316
|
+
packageVersion,
|
|
317
|
+
derive: options.deriveContract
|
|
318
|
+
});
|
|
319
|
+
if (!contract) {
|
|
320
|
+
return fail(
|
|
321
|
+
`integration "${entry.name}": ${override.path} has no contract.json and no contract could be derived; run "ekanos contract" there.`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
if (contract.integration !== entry.name) {
|
|
325
|
+
return fail(
|
|
326
|
+
`integration "${entry.name}": the contract at ${override.path} is for "${contract.integration}", not "${entry.name}".`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
const problems = pinProblems(entry, contract, [contract.compatLine]);
|
|
330
|
+
if (problems.length > 0) {
|
|
331
|
+
problems.forEach(
|
|
332
|
+
(message) => result.errors.push({
|
|
333
|
+
integration: entry.name,
|
|
334
|
+
message: `${sameRepo ? "this repo" : "override"} ${override.path}: ${message}`
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
const pinned = snapshotContract(snapshotDir, entry);
|
|
340
|
+
if (pinned) {
|
|
341
|
+
for (const id of entry.operations) {
|
|
342
|
+
const mine = findOperation(contract, id);
|
|
343
|
+
const theirs = findOperation(pinned, id);
|
|
344
|
+
if (mine && theirs && mine.effect !== theirs.effect) {
|
|
345
|
+
return fail(
|
|
346
|
+
`integration "${entry.name}": override declares ${opKey(id)} as ${mine.effect} but the pinned contract says ${theirs.effect}.`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
integration: entry.name,
|
|
353
|
+
version: entry.version,
|
|
354
|
+
required: entry.required,
|
|
355
|
+
operations: entry.operations,
|
|
356
|
+
modes: entry.modes,
|
|
357
|
+
bindingMode,
|
|
358
|
+
provenance: {
|
|
359
|
+
kind: "local",
|
|
360
|
+
path: override.path,
|
|
361
|
+
packageVersion,
|
|
362
|
+
contractVersion: contract.contractVersion,
|
|
363
|
+
digest: contract.digest,
|
|
364
|
+
scope: sameRepo ? "repo" : "override"
|
|
365
|
+
},
|
|
366
|
+
contract,
|
|
367
|
+
runModes: ["fixtures", "live"],
|
|
368
|
+
defaultMode: override.mode,
|
|
369
|
+
canDevelop,
|
|
370
|
+
...sameRepo ? { sameRepo: true } : {},
|
|
371
|
+
credentialRoot: override.path,
|
|
372
|
+
loadDefinition: async () => definition
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
async function contractForOverride(args) {
|
|
376
|
+
if (args.derive) {
|
|
377
|
+
const derived = args.derive({
|
|
378
|
+
definition: args.definition,
|
|
379
|
+
projectDir: args.projectDir,
|
|
380
|
+
packageVersion: args.packageVersion
|
|
381
|
+
});
|
|
382
|
+
if (derived) return derived;
|
|
383
|
+
return readCommittedContract(args.projectDir);
|
|
384
|
+
}
|
|
385
|
+
const contractVersion = authoredContractVersion(args.projectDir);
|
|
386
|
+
if (contractVersion) {
|
|
387
|
+
try {
|
|
388
|
+
const sdk = await import("@ekanos/sdk/contract");
|
|
389
|
+
const previous = readCommittedContract(args.projectDir);
|
|
390
|
+
return sdk.deriveContract(args.definition, {
|
|
391
|
+
packageVersion: args.packageVersion,
|
|
392
|
+
contractVersion,
|
|
393
|
+
previous
|
|
394
|
+
});
|
|
395
|
+
} catch (error) {
|
|
396
|
+
if (error instanceof Error && error.name === "ContractDerivationError") {
|
|
397
|
+
throw error;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return readCommittedContract(args.projectDir);
|
|
402
|
+
}
|
|
403
|
+
function authoredContractVersion(dir) {
|
|
404
|
+
try {
|
|
405
|
+
const raw = JSON.parse(
|
|
406
|
+
fs.readFileSync(path.join(dir, "ekanos.json"), "utf8")
|
|
407
|
+
);
|
|
408
|
+
return typeof raw.contract?.version === "string" ? raw.contract.version : null;
|
|
409
|
+
} catch {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function readCommittedContract(dir) {
|
|
414
|
+
const file = path.join(dir, "contract.json");
|
|
415
|
+
return fs.existsSync(file) ? readContractFile(file) : null;
|
|
416
|
+
}
|
|
417
|
+
function snapshotContract(snapshotDir, entry) {
|
|
418
|
+
try {
|
|
419
|
+
return pickLine(listContractsInDir(snapshotDir, entry.name), entry.version)?.contract ?? null;
|
|
420
|
+
} catch {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
async function resolveRegistry(entry, bindingMode, options, contractsDir, snapshotDir, result) {
|
|
425
|
+
const fail = (message) => {
|
|
426
|
+
result.errors.push({ integration: entry.name, message });
|
|
427
|
+
return null;
|
|
428
|
+
};
|
|
429
|
+
let canDevelop = "unverified";
|
|
430
|
+
if (options.catalog) {
|
|
431
|
+
const row = options.catalog.products.find(
|
|
432
|
+
(product) => product.slug === entry.name
|
|
433
|
+
);
|
|
434
|
+
if (!row) {
|
|
435
|
+
return fail(
|
|
436
|
+
`integration "${entry.name}" is not available to your Source.`
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
canDevelop = row.owned === true && options.catalog.viewer.roles.length > 0;
|
|
440
|
+
}
|
|
441
|
+
let provenance = null;
|
|
442
|
+
let contract = null;
|
|
443
|
+
let lines = [];
|
|
444
|
+
let loadDefinition;
|
|
445
|
+
let runModes = ["fixtures"];
|
|
446
|
+
if (canDevelop === true && options.registry !== false) {
|
|
447
|
+
const installer = options.registry ?? {
|
|
448
|
+
ensure: (args) => ensurePublishedIntegration({
|
|
449
|
+
projectRoot: args.projectRoot,
|
|
450
|
+
integration: args.integration,
|
|
451
|
+
line: args.version
|
|
452
|
+
})
|
|
453
|
+
};
|
|
454
|
+
const ensured = await installer.ensure({
|
|
455
|
+
projectRoot: options.projectRoot,
|
|
456
|
+
integration: entry.name,
|
|
457
|
+
version: entry.version
|
|
458
|
+
});
|
|
459
|
+
if (ensured.ok) {
|
|
460
|
+
const shipped = readShippedContract(ensured.packageDir);
|
|
461
|
+
if (shipped && shipped.contract.compatLine === entry.version) {
|
|
462
|
+
contract = shipped.contract;
|
|
463
|
+
provenance = {
|
|
464
|
+
kind: "registry",
|
|
465
|
+
contractVersion: shipped.contract.contractVersion,
|
|
466
|
+
digest: shipped.contract.digest,
|
|
467
|
+
source: "package",
|
|
468
|
+
origin: `${entry.name}@${ensured.version}`,
|
|
469
|
+
stale: false,
|
|
470
|
+
cachedPackage: {
|
|
471
|
+
name: `@companydotcom/integration-${entry.name}`,
|
|
472
|
+
version: ensured.version
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
} else {
|
|
476
|
+
result.notices.push(
|
|
477
|
+
`integration "${entry.name}": published ${entry.name}@${ensured.version} ships no contract.json for version ${entry.version}; using the contracts directory.`
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
const loadPackage = options.loadPackageDefinition ?? loadDefinitionFromPackage;
|
|
481
|
+
let memo;
|
|
482
|
+
loadDefinition = () => memo ??= loadPackage(ensured.packageDir);
|
|
483
|
+
runModes = ["fixtures", "live"];
|
|
484
|
+
} else {
|
|
485
|
+
result.notices.push(
|
|
486
|
+
`integration "${entry.name}": ${entry.name} runs fixtures-only \u2014 ${ensured.message}`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
} else if (canDevelop === "unverified") {
|
|
490
|
+
result.notices.push(
|
|
491
|
+
`integration "${entry.name}": no CLI session catalog, so develop on "${entry.name}" is unverified; registry integration is fixtures-only.`
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
if (!contract) {
|
|
495
|
+
let candidates = [];
|
|
496
|
+
if (contractsDir) {
|
|
497
|
+
candidates = listContractsInDir(contractsDir, entry.name);
|
|
498
|
+
lines = availableLines(candidates);
|
|
499
|
+
const picked = pickLine(candidates, entry.version);
|
|
500
|
+
if (picked) {
|
|
501
|
+
contract = picked.contract;
|
|
502
|
+
provenance = {
|
|
503
|
+
kind: "registry",
|
|
504
|
+
contractVersion: picked.contract.contractVersion,
|
|
505
|
+
digest: picked.contract.digest,
|
|
506
|
+
source: "dir",
|
|
507
|
+
origin: contractsDir,
|
|
508
|
+
stale: false
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (!contract) {
|
|
513
|
+
const snapshots = listContractsInDir(snapshotDir, entry.name);
|
|
514
|
+
lines = [.../* @__PURE__ */ new Set([...lines, ...availableLines(snapshots)])].sort();
|
|
515
|
+
const picked = pickLine(snapshots, entry.version);
|
|
516
|
+
if (picked) {
|
|
517
|
+
contract = picked.contract;
|
|
518
|
+
provenance = {
|
|
519
|
+
kind: "registry",
|
|
520
|
+
contractVersion: picked.contract.contractVersion,
|
|
521
|
+
digest: picked.contract.digest,
|
|
522
|
+
source: "snapshot",
|
|
523
|
+
origin: snapshotDir,
|
|
524
|
+
stale: true
|
|
525
|
+
};
|
|
526
|
+
if (contractsDir) {
|
|
527
|
+
result.notices.push(
|
|
528
|
+
`integration "${entry.name}": ${entry.name}@${entry.version} is not in ${contractsDir}; using the committed snapshot (STALE SNAPSHOT).`
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (!contract || !provenance) {
|
|
535
|
+
return fail(
|
|
536
|
+
lines.length > 0 ? `integration "${entry.name}" pins ${entry.name}@${entry.version} but the resolver has versions [${lines.join(", ")}].` : `integration "${entry.name}": no contract found for ${entry.name}@${entry.version} (looked in ${[contractsDir, snapshotDir].filter(Boolean).join(" and ")}).`
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
const problems = pinProblems(entry, contract, lines);
|
|
540
|
+
if (problems.length > 0) {
|
|
541
|
+
problems.forEach(
|
|
542
|
+
(message) => result.errors.push({ integration: entry.name, message })
|
|
543
|
+
);
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
integration: entry.name,
|
|
548
|
+
version: entry.version,
|
|
549
|
+
required: entry.required,
|
|
550
|
+
operations: entry.operations,
|
|
551
|
+
modes: entry.modes,
|
|
552
|
+
bindingMode,
|
|
553
|
+
provenance,
|
|
554
|
+
contract,
|
|
555
|
+
runModes,
|
|
556
|
+
defaultMode: "fixtures",
|
|
557
|
+
canDevelop,
|
|
558
|
+
credentialRoot: options.projectRoot,
|
|
559
|
+
...loadDefinition ? { loadDefinition } : {}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function describeProvenance(integration) {
|
|
563
|
+
const p = integration.provenance;
|
|
564
|
+
if (p.kind === "local") {
|
|
565
|
+
if (p.scope === "repo") {
|
|
566
|
+
return `LOCAL this repo ${p.path} (pkg ${p.packageVersion}) ${integration.runModes.join("|")}`;
|
|
567
|
+
}
|
|
568
|
+
return `LOCAL OVERRIDE ${p.path} (pkg ${p.packageVersion}) ${integration.runModes.join("|")}`;
|
|
569
|
+
}
|
|
570
|
+
const where = p.source === "package" ? `package ${p.origin}` : p.source === "dir" ? `dir ${p.origin}` : p.source === "catalog" ? "catalog" : `snapshot ${p.origin}${p.stale ? " STALE SNAPSHOT" : ""}`;
|
|
571
|
+
const modes = integration.runModes.includes("live") ? "fixtures|live" : "fixtures-only";
|
|
572
|
+
return `REGISTRY (${where}) ${modes}`;
|
|
573
|
+
}
|
|
574
|
+
function formatProvenanceLines(resolution) {
|
|
575
|
+
const rows = resolution.integrations.map((integration) => [
|
|
576
|
+
integration.integration,
|
|
577
|
+
integration.version,
|
|
578
|
+
`contract ${integration.provenance.contractVersion} ${integration.provenance.digest.replace("sha256:", "").slice(0, 4)}\u2026`,
|
|
579
|
+
describeProvenance(integration)
|
|
580
|
+
]);
|
|
581
|
+
const header = ["integration", "version", "resolved", "from"];
|
|
582
|
+
const widths = header.map(
|
|
583
|
+
(_, column) => Math.max(...[header, ...rows].map((row) => (row[column] ?? "").length))
|
|
584
|
+
);
|
|
585
|
+
const format = (row) => row.map(
|
|
586
|
+
(cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column] ?? 0)
|
|
587
|
+
).join(" ");
|
|
588
|
+
const lines = [format(header), ...rows.map(format)];
|
|
589
|
+
for (const error of resolution.errors) {
|
|
590
|
+
lines.push(`!! integration "${error.integration}": ${error.message}`);
|
|
591
|
+
}
|
|
592
|
+
if (resolution.overrides.length > 0) {
|
|
593
|
+
lines.push(
|
|
594
|
+
`!! ${resolution.overrides.length} local override${resolution.overrides.length === 1 ? "" : "s"} active: publish is blocked.`
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
return lines;
|
|
598
|
+
}
|
|
599
|
+
export {
|
|
600
|
+
compatLine,
|
|
601
|
+
formatProvenanceLines,
|
|
602
|
+
repoOf,
|
|
603
|
+
resolveIntegrations,
|
|
604
|
+
sameRepoPackage
|
|
605
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IntegrationDefinition } from '@ekanos/sdk/integration';
|
|
2
|
+
import type { ResolvedIntegration } from './integration-resolver.js';
|
|
3
|
+
import { type LiveState } from './live-context.js';
|
|
4
|
+
import type { LiveInvoker } from './operation-runner.js';
|
|
5
|
+
export declare function liveStateFor(integration: ResolvedIntegration, networkFetch?: () => typeof globalThis.fetch): Promise<{
|
|
6
|
+
state: LiveState;
|
|
7
|
+
definition: IntegrationDefinition;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function createLiveInvoker(options?: {
|
|
10
|
+
networkFetch?: () => typeof globalThis.fetch;
|
|
11
|
+
}): LiveInvoker;
|