@zackbart/connecta 0.37.1 → 0.39.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/CHANGELOG.md +94 -0
- package/README.md +5 -4
- package/bin/connecta.mjs +1 -39
- package/bin/version.mjs +1 -1
- package/dist/access-tokens.js +2 -4
- package/dist/agent-identity.js +1 -1
- package/dist/agent-routes.js +231 -0
- package/dist/auth/clerk-sdk/generated.js +2 -1
- package/dist/auth/downstream-oauth/consent.js +519 -0
- package/dist/auth/downstream-oauth/grant-store.js +439 -0
- package/dist/auth/downstream-oauth/refresh-coordinator.js +562 -0
- package/dist/auth/downstream-oauth/refresh-records.js +447 -0
- package/dist/auth/downstream-oauth/sdk-hooks.js +242 -0
- package/dist/auth/downstream-oauth.js +66 -2516
- package/dist/auth/downstream-revocation.js +1 -1
- package/dist/auth/native.js +27 -0
- package/dist/auth/oauth-grant.js +24 -0
- package/dist/auth/oauth-token-response.js +1 -1
- package/dist/auth/static-oauth.js +153 -131
- package/dist/auth/vercel-agent.js +2 -1
- package/dist/auth-elicitation.js +9 -3
- package/dist/authorization-handoff.js +11 -5
- package/dist/branding.d.ts +1 -15
- package/dist/branding.js +2 -2
- package/dist/bytes.js +42 -0
- package/dist/call-admission-context.js +2 -5
- package/dist/call-recovery.js +0 -3
- package/dist/catalog-cache.js +130 -43
- package/dist/catalog-fingerprint.js +2 -18
- package/dist/catalog-policy.js +18 -0
- package/dist/catalog-service.js +285 -48
- package/dist/catalog.js +18 -2
- package/dist/config-defaults.d.ts +1 -0
- package/dist/config-defaults.js +1 -0
- package/dist/config-schema.d.ts +1 -1
- package/dist/config-schema.js +6 -2
- package/dist/config.d.ts +57 -25
- package/dist/config.js +30 -77
- package/dist/connector-caller.d.ts +1 -1
- package/dist/connector-health.js +59 -0
- package/dist/connector-status.js +117 -0
- package/dist/connectors/api-connector.d.ts +7 -2
- package/dist/connectors/api-connector.js +11 -7
- package/dist/connectors/guarded-fetch.d.ts +0 -6
- package/dist/connectors/guarded-fetch.js +1 -11
- package/dist/connectors/negotiation-cache.js +22 -4
- package/dist/connectors/remote-mcp/call.js +164 -0
- package/dist/connectors/remote-mcp/catalog.js +278 -0
- package/dist/connectors/remote-mcp/config.js +263 -0
- package/dist/connectors/remote-mcp/connection.js +671 -0
- package/dist/connectors/remote-mcp/errors.js +488 -0
- package/dist/connectors/remote-mcp/oauth.js +469 -0
- package/dist/connectors/remote-mcp/resources.js +473 -0
- package/dist/connectors/remote-mcp/runtime.js +1 -0
- package/dist/connectors/remote-mcp/transport.js +544 -0
- package/dist/connectors/remote-mcp.js +61 -2898
- package/dist/connectors/resource-uri.js +0 -4
- package/dist/credential-contract.d.ts +23 -0
- package/dist/credential-reads.js +17 -0
- package/dist/credential-verification.js +53 -0
- package/dist/credentials.d.ts +7 -0
- package/dist/credentials.js +60 -25
- package/dist/d1.d.ts +0 -89
- package/dist/d1.js +0 -34
- package/dist/describe-config.d.ts +12 -2
- package/dist/describe-config.js +2 -0
- package/dist/discovery-health.js +199 -0
- package/dist/downstream-input.js +4 -2
- package/dist/errors.d.ts +55 -17
- package/dist/errors.js +95 -41
- package/dist/execute.js +172 -125
- package/dist/executor-result.js +5 -2
- package/dist/executors/quickjs-runtime.js +2 -25
- package/dist/executors/quickjs.js +1 -1
- package/dist/guest-functions.js +83 -0
- package/dist/guest-runtime.js +63 -20
- package/dist/guest-types.d.ts +24 -10
- package/dist/http/argument-problems.js +35 -0
- package/dist/http/client.js +1 -1
- package/dist/http/errors.js +7 -6
- package/dist/http/fields.js +192 -13
- package/dist/http/hatch-response.js +73 -0
- package/dist/http/hatch.js +88 -23
- package/dist/http/json-schema.js +1 -1
- package/dist/http/node-transport.js +0 -1
- package/dist/http/oauth.js +4 -3
- package/dist/http/paging.js +6 -9
- package/dist/http/provider.js +33 -5
- package/dist/http/safety.js +9 -1
- package/dist/http/services.js +1 -8
- package/dist/http/tools.js +45 -30
- package/dist/http/vendor.js +7 -7
- package/dist/identity.js +2 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -2
- package/dist/invocation-auth.js +2 -1
- package/dist/invocation.js +21 -6
- package/dist/membership.d.ts +13 -5
- package/dist/membership.js +34 -2
- package/dist/meta-tools.js +50 -35
- package/dist/native-recovery.js +4 -16
- package/dist/native-tools.js +6 -2
- package/dist/oauth-handoff.js +2 -2
- package/dist/oauth-sealing.js +10 -0
- package/dist/operation-vocabulary.js +136 -14
- package/dist/operator-record.d.ts +2 -2
- package/dist/operator-record.js +2 -49
- package/dist/operator-ui/contract.d.ts +12 -2
- package/dist/operator-ui/generated.js +3 -3
- package/dist/operator-ui/model.d.ts +22 -1
- package/dist/program-writes.js +3 -8
- package/dist/provider-call.js +0 -7
- package/dist/provider.d.ts +1 -1
- package/dist/providers/_shared/google/kit.js +1 -6
- package/dist/providers/_shared/google/service-account.js +1 -3
- package/dist/providers/_shared/google/workspace.d.ts +1 -1
- package/dist/providers/_shared/guide.js +3 -0
- package/dist/providers/_shared/json.js +12 -0
- package/dist/providers/_shared/rest/compact-index.js +1 -1
- package/dist/providers/_shared/rest/kit.js +1 -3
- package/dist/providers/_shared/rest/operation-index.js +49 -53
- package/dist/providers/_shared/rest/value-safety.js +106 -28
- package/dist/providers/breeze/api.js +9 -8
- package/dist/providers/breeze/index.js +4 -2
- package/dist/providers/breeze/skill.generated.js +1 -1
- package/dist/providers/breeze/tools.js +7 -7
- package/dist/providers/ccb/api.js +3 -7
- package/dist/providers/ccb/index.js +7 -1
- package/dist/providers/ccb/skill.generated.js +1 -1
- package/dist/providers/ccb/tools.js +1 -6
- package/dist/providers/cloudflare/api.js +10 -3
- package/dist/providers/cloudflare/index.js +2 -1
- package/dist/providers/cloudflare/safety.js +3 -3
- package/dist/providers/cloudflare/skill.generated.js +1 -1
- package/dist/providers/docs/lib/schemas.js +24 -22
- package/dist/providers/docs/safety.js +2 -0
- package/dist/providers/docs/skill.generated.js +1 -1
- package/dist/providers/docs/tools.js +4 -14
- package/dist/providers/drive/api.js +1 -0
- package/dist/providers/drive/lib/contracts.js +8 -5
- package/dist/providers/drive/skill.generated.js +1 -1
- package/dist/providers/drive/tools.js +23 -41
- package/dist/providers/forms/api.js +1 -0
- package/dist/providers/forms/skill.generated.js +1 -1
- package/dist/providers/forms/tools.js +11 -16
- package/dist/providers/github/api.js +1 -0
- package/dist/providers/github/lib/discovery.js +1 -1
- package/dist/providers/github/skill.generated.js +1 -1
- package/dist/providers/github/tools.js +61 -17
- package/dist/providers/gmail/lib/schemas.js +60 -50
- package/dist/providers/gmail/skill.generated.js +1 -1
- package/dist/providers/gmail/tools.js +12 -26
- package/dist/providers/granola/index.js +2 -0
- package/dist/providers/granola/skill.generated.js +1 -1
- package/dist/providers/overflow/api.js +8 -4
- package/dist/providers/overflow/index.js +2 -1
- package/dist/providers/overflow/skill.generated.js +1 -1
- package/dist/providers/overflow/tools.js +3 -7
- package/dist/providers/planning-center/api.js +5 -2
- package/dist/providers/planning-center/lib/constants.d.ts +1 -1
- package/dist/providers/planning-center/lib/json-api.js +1 -9
- package/dist/providers/planning-center/skill.generated.js +1 -1
- package/dist/providers/planning-center/tools.js +2 -1
- package/dist/providers/quickbooks/safety.js +80 -39
- package/dist/providers/quickbooks/skill.generated.js +1 -1
- package/dist/providers/sheets/api.js +1 -0
- package/dist/providers/sheets/skill.generated.js +1 -1
- package/dist/providers/sheets/tools.js +14 -23
- package/dist/providers/slides/skill.generated.js +1 -1
- package/dist/providers/slides/tools.js +19 -26
- package/dist/providers/stripe/index.js +2 -1
- package/dist/providers/stripe/safety.js +2 -2
- package/dist/providers/stripe/skill.generated.js +1 -1
- package/dist/providers/tithely/api.js +5 -8
- package/dist/providers/tithely/index.js +3 -2
- package/dist/providers/tithely/skill.generated.js +1 -1
- package/dist/providers/tithely/tools.js +7 -5
- package/dist/providers/vercel/api.js +2 -7
- package/dist/providers/vercel/lib/pin.js +1 -1
- package/dist/providers/vercel/safety.js +1 -1
- package/dist/providers/vercel/skill.generated.js +1 -1
- package/dist/providers/vercel/tools.js +6 -4
- package/dist/redaction-marker.js +2 -2
- package/dist/registry.d.ts +11 -5
- package/dist/registry.js +46 -20
- package/dist/request-principal.js +1 -1
- package/dist/request-state.js +2 -2
- package/dist/routes/access-tokens.js +1 -1
- package/dist/routes/activity-disclosure.js +1 -1
- package/dist/routes/connect.js +2 -2
- package/dist/routes/credentials.js +130 -61
- package/dist/routes/dispatch.js +5 -1
- package/dist/routes/mcp.js +34 -17
- package/dist/routes/oauth-management.js +1 -1
- package/dist/routes/operator.js +6 -5
- package/dist/routes/shared.d.ts +13 -8
- package/dist/routes/shared.js +15 -9
- package/dist/routes/ui-config.js +3 -3
- package/dist/routes/ui-data.js +126 -20
- package/dist/routes/ui.js +17 -1
- package/dist/runtime/call-admission.js +1 -1
- package/dist/runtime/call.js +8 -3
- package/dist/runtime/native-storage.js +9 -0
- package/dist/runtime/request-reads.js +182 -0
- package/dist/runtime/request-scope.js +16 -0
- package/dist/runtime/settlement.js +1 -1
- package/dist/runtime/shared-read.js +2 -15
- package/dist/runtime/storage.js +12 -0
- package/dist/sent-secrets.d.ts +1 -2
- package/dist/sent-secrets.js +3 -8
- package/dist/server.js +4 -4
- package/dist/skills.js +44 -54
- package/dist/sqlite.d.ts +0 -19
- package/dist/sqlite.js +2 -83
- package/dist/storage/keys.js +69 -128
- package/dist/storage/memory.js +8 -2
- package/dist/storage/sql-native.js +27 -101
- package/dist/storage/sql.d.ts +1 -24
- package/dist/storage/sql.js +13 -14
- package/dist/storage-digest.js +32 -0
- package/dist/timeout.js +8 -0
- package/dist/tool-error.js +4 -0
- package/dist/types.d.ts +33 -0
- package/dist/url-safety.js +0 -4
- package/dist/usage-guide.js +18 -37
- package/dist/validate.d.ts +3 -0
- package/dist/validate.js +220 -158
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker.js +1 -1
- package/dist/write-outcome.js +0 -3
- package/documentation/README.md +19 -55
- package/documentation/architecture.md +436 -515
- package/documentation/auth.md +229 -88
- package/documentation/code-mode.md +201 -94
- package/documentation/deploying.md +25 -43
- package/documentation/integrating.md +18 -19
- package/documentation/meta-tools.md +225 -51
- package/documentation/migration-0.33.md +10 -6
- package/documentation/migration-0.34.md +5 -5
- package/documentation/migration-retired-layouts.md +74 -0
- package/documentation/operator-tests.md +20 -120
- package/documentation/operator-ui.md +108 -16
- package/documentation/pool-membership-upgrade.md +44 -0
- package/documentation/provider-auth-migration.md +4 -10
- package/documentation/provider-migration-0.29.md +4 -15
- package/documentation/providers.md +105 -0
- package/examples/worker/AGENTS.md +14 -16
- package/examples/worker/README.md +24 -118
- package/examples/worker/src/connecta.config.ts +1 -0
- package/guides/connecting-agents.md +9 -31
- package/guides/how-it-works.md +6 -4
- package/guides/safety-and-trust.md +4 -1
- package/package.json +19 -19
- package/templates/node/AGENTS.md +13 -12
- package/templates/node/README.md +9 -26
- package/templates/node/package.json +1 -1
- package/templates/node/src/connecta.config.ts +1 -0
- package/dist/auth/oauth-v2-migration.js +0 -135
- package/dist/provider-call-facts.d.ts +0 -115
- package/dist/provider-call.d.ts +0 -112
- package/dist/storage/d1-copy.js +0 -255
- package/dist/storage/sql-schema.d.ts +0 -6
- package/examples/worker/kv-to-d1.wrangler.jsonc +0 -26
- package/examples/worker/scripts/copy-kv-to-d1.mjs +0 -162
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Bindings for the one-shot Workers KV → D1 copy in scripts/copy-kv-to-d1.mjs.
|
|
2
|
-
// Never deployed: `wrangler deploy` reads wrangler.jsonc, which binds no KV.
|
|
3
|
-
// Both bindings are remote, so the script reads the real namespace and writes
|
|
4
|
-
// the real database through your `wrangler login` session. Fill in the ids,
|
|
5
|
-
// stop traffic/writers, wait for stable KV, copy and verify before deploying,
|
|
6
|
-
// then mark cutover before reopening traffic. README.md § "Upgrading from
|
|
7
|
-
// 0.28" has the steps.
|
|
8
|
-
{
|
|
9
|
-
"name": "connecta-kv-to-d1",
|
|
10
|
-
"compatibility_date": "2025-01-01",
|
|
11
|
-
"kv_namespaces": [
|
|
12
|
-
{
|
|
13
|
-
"binding": "CONNECTA_KV",
|
|
14
|
-
"id": "replace-with-kv-namespace-id",
|
|
15
|
-
"remote": true,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
"d1_databases": [
|
|
19
|
-
{
|
|
20
|
-
"binding": "CONNECTA_DB",
|
|
21
|
-
"database_name": "connecta",
|
|
22
|
-
"database_id": "replace-with-d1-database-id",
|
|
23
|
-
"remote": true,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Run only during the maintenance-window cutover. See README "Upgrading from 0.28".
|
|
3
|
-
|
|
4
|
-
export const HELP = `Usage: node scripts/copy-kv-to-d1.mjs [config] --maintenance [options]
|
|
5
|
-
Config defaults to kv-to-d1.wrangler.jsonc; source is its CONNECTA_KV namespace id.
|
|
6
|
-
1. Bulk-export KV and export D1 with wrangler d1 export. Preserve the credentials key.
|
|
7
|
-
2. Block traffic and all background writers, then drain in-flight requests.
|
|
8
|
-
3. Wait at least 60 seconds, or the longest configured KV cacheTtl, whichever is
|
|
9
|
-
greater. Propagation can take longer. Two consecutive listing/hash passes
|
|
10
|
-
must match; this script checks them before copying or verifying.
|
|
11
|
-
4. Copy BEFORE switching traffic. Resolve invalid/conflict counts under maintenance.
|
|
12
|
-
--overwrite-family <family> may be repeated; there is no blanket overwrite.
|
|
13
|
-
Token/OAuth/vault families also require --confirm-stale-d1 after the operator
|
|
14
|
-
confirms that D1's conflicting rows are stale. Run --verify for exact value
|
|
15
|
-
hashes and expiries; it reports mismatch counts by family, never payloads.
|
|
16
|
-
5. Deploy D1 config under maintenance. Run doctor and check an existing OAuth
|
|
17
|
-
connector, cta_ token, vault credential, and visible activity. Set
|
|
18
|
-
CONNECTA_ACTIVITY="on"; config lives in src/connecta.config.ts.
|
|
19
|
-
6. Run --mark-live before reopening traffic. It permanently seals this source
|
|
20
|
-
in D1. Never rerun afterward. --i-know-this-is-stale overrides the seal only
|
|
21
|
-
after assessing stale KV state, with traffic and writers stopped again.
|
|
22
|
-
Keep backups before deleting KV.
|
|
23
|
-
Options: --verify, --mark-live, --overwrite-family <family>, --confirm-stale-d1,
|
|
24
|
-
--i-know-this-is-stale, --maintenance, --help`;
|
|
25
|
-
|
|
26
|
-
export class MigrationUsageError extends Error {}
|
|
27
|
-
|
|
28
|
-
export function parseArgs(args) {
|
|
29
|
-
const options = { configPath: "kv-to-d1.wrangler.jsonc", overwriteFamilies: [] };
|
|
30
|
-
let hasConfig = false;
|
|
31
|
-
for (let i = 0; i < args.length; i++) {
|
|
32
|
-
const arg = args[i];
|
|
33
|
-
if (arg === "--overwrite-family") {
|
|
34
|
-
const family = args[++i];
|
|
35
|
-
if (!family || family.startsWith("--")) throw new MigrationUsageError("--overwrite-family requires a family");
|
|
36
|
-
options.overwriteFamilies.push(family);
|
|
37
|
-
} else if (arg === "--maintenance") options.maintenance = true;
|
|
38
|
-
else if (arg === "--verify") options.verify = true;
|
|
39
|
-
else if (arg === "--mark-live") options.markLive = true;
|
|
40
|
-
else if (arg === "--confirm-stale-d1") options.confirmStale = true;
|
|
41
|
-
else if (arg === "--i-know-this-is-stale") options.allowStale = true;
|
|
42
|
-
else if (arg === "--help") options.help = true;
|
|
43
|
-
else if (!arg.startsWith("--") && !hasConfig) {
|
|
44
|
-
options.configPath = arg;
|
|
45
|
-
hasConfig = true;
|
|
46
|
-
} else throw new MigrationUsageError("Unknown argument; use --help");
|
|
47
|
-
}
|
|
48
|
-
if (options.help) return options;
|
|
49
|
-
if (!options.maintenance)
|
|
50
|
-
throw new MigrationUsageError(
|
|
51
|
-
"Traffic and writers must be stopped; pass --maintenance after draining and waiting for KV propagation",
|
|
52
|
-
);
|
|
53
|
-
if (
|
|
54
|
-
options.overwriteFamilies.some(
|
|
55
|
-
(family) => family === "access-token" || family === "credential" || family.startsWith("oauth"),
|
|
56
|
-
) &&
|
|
57
|
-
!options.confirmStale
|
|
58
|
-
) {
|
|
59
|
-
throw new MigrationUsageError(
|
|
60
|
-
"Token/OAuth/vault overwrite requires --confirm-stale-d1 after confirming D1 rows are stale",
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
if ((options.verify || options.markLive) && options.overwriteFamilies.length)
|
|
64
|
-
throw new MigrationUsageError("Verification and cutover marking cannot overwrite families");
|
|
65
|
-
if (options.verify && options.markLive)
|
|
66
|
-
throw new MigrationUsageError("Verify before marking cutover in a separate command");
|
|
67
|
-
return options;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const encode = new TextEncoder();
|
|
71
|
-
const hash = async (value) => {
|
|
72
|
-
const bytes = await crypto.subtle.digest("SHA-256", encode.encode(value));
|
|
73
|
-
return Array.from(new Uint8Array(bytes), (n) => n.toString(16).padStart(2, "0")).join("");
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Keep only entry digests. Sorting makes the comparison independent of list order.
|
|
77
|
-
async function sourceHash(kv) {
|
|
78
|
-
const digests = [];
|
|
79
|
-
let cursor;
|
|
80
|
-
do {
|
|
81
|
-
const page = await kv.list({ limit: 1000, ...(cursor ? { cursor } : {}) });
|
|
82
|
-
for (const key of page.keys) {
|
|
83
|
-
if (key.expiration !== undefined && key.expiration * 1000 <= Date.now()) continue;
|
|
84
|
-
const value = await kv.get(key.name, "text");
|
|
85
|
-
if (value !== null) digests.push(await hash(JSON.stringify([key.name, key.expiration ?? null, value])));
|
|
86
|
-
}
|
|
87
|
-
cursor = page.list_complete ? undefined : page.cursor;
|
|
88
|
-
} while (cursor);
|
|
89
|
-
return hash(digests.sort().join(""));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Injected operations let the Workers suite exercise the real migration flow. */
|
|
93
|
-
export async function runMigration(kv, db, options, operations, output = console) {
|
|
94
|
-
if (!options.maintenance) throw new MigrationUsageError("Migration requires maintenance");
|
|
95
|
-
if (options.markLive) {
|
|
96
|
-
await operations.markKvToD1Live(db, options.source);
|
|
97
|
-
output.log("Cutover sealed in D1. Reopen traffic after deployment verification; never copy stale KV afterward.");
|
|
98
|
-
return 0;
|
|
99
|
-
}
|
|
100
|
-
if ((await sourceHash(kv)) !== (await sourceHash(kv))) {
|
|
101
|
-
throw new MigrationUsageError("Workers KV source is not stable; keep maintenance active, wait, and repeat");
|
|
102
|
-
}
|
|
103
|
-
const families = {};
|
|
104
|
-
let cursor;
|
|
105
|
-
do {
|
|
106
|
-
const result = await operations.copyKvToD1(kv, db, {
|
|
107
|
-
source: options.source,
|
|
108
|
-
cursor,
|
|
109
|
-
overwriteFamilies: options.overwriteFamilies,
|
|
110
|
-
verify: options.verify,
|
|
111
|
-
allowStale: options.allowStale,
|
|
112
|
-
});
|
|
113
|
-
for (const [family, counts] of Object.entries(result.families)) {
|
|
114
|
-
const into = (families[family] ??= {});
|
|
115
|
-
for (const [field, n] of Object.entries(counts)) into[field] = (into[field] ?? 0) + n;
|
|
116
|
-
}
|
|
117
|
-
cursor = result.cursor;
|
|
118
|
-
} while (cursor);
|
|
119
|
-
output.table(families);
|
|
120
|
-
if (Object.values(families).some((counts) => counts.invalid > 0 || counts.conflicts > 0 || counts.mismatches > 0)) {
|
|
121
|
-
output.error(
|
|
122
|
-
"Invalid entries, conflicts, or verification mismatches remain. Keep maintenance active and resolve the per-family counts.",
|
|
123
|
-
);
|
|
124
|
-
return 1;
|
|
125
|
-
}
|
|
126
|
-
return 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function main() {
|
|
130
|
-
let proxy;
|
|
131
|
-
let operations;
|
|
132
|
-
try {
|
|
133
|
-
const options = parseArgs(process.argv.slice(2));
|
|
134
|
-
if (options.help) {
|
|
135
|
-
console.log(HELP);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const wranglerModule = "wrangler";
|
|
139
|
-
const d1Module = "@zackbart/connecta/d1";
|
|
140
|
-
const { getPlatformProxy, unstable_readConfig } = await import(/* @vite-ignore */ wranglerModule);
|
|
141
|
-
operations = await import(/* @vite-ignore */ d1Module);
|
|
142
|
-
const config = unstable_readConfig({ config: options.configPath });
|
|
143
|
-
const source = config.kv_namespaces?.find((binding) => binding.binding === "CONNECTA_KV")?.id;
|
|
144
|
-
if (!source || source.startsWith("replace-"))
|
|
145
|
-
throw new MigrationUsageError("Configure the CONNECTA_KV namespace id before copying");
|
|
146
|
-
proxy = await getPlatformProxy({ configPath: options.configPath, persist: false });
|
|
147
|
-
const { CONNECTA_KV: kv, CONNECTA_DB: db } = proxy.env;
|
|
148
|
-
if (!kv || !db) throw new MigrationUsageError("Copy config must bind CONNECTA_KV and CONNECTA_DB");
|
|
149
|
-
process.exitCode = await runMigration(kv, db, { ...options, source }, operations);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.error(
|
|
152
|
-
error instanceof MigrationUsageError || (operations && error instanceof operations.KvToD1CopyError)
|
|
153
|
-
? error.message
|
|
154
|
-
: "Workers KV to D1 migration stopped; keep maintenance active and inspect the configuration",
|
|
155
|
-
);
|
|
156
|
-
process.exitCode = 1;
|
|
157
|
-
} finally {
|
|
158
|
-
await proxy?.dispose();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (typeof process !== "undefined" && import.meta.url === `file://${process.argv?.[1]}`) await main();
|