@amerged/ohmyhost-cli 0.1.55 → 0.1.57
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/README.md +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-4OAAJX5B.js → chunk-GODV5QDC.js} +797 -86
- package/dist/index.js +9 -1
- package/package.json +1 -1
- package/src/apps/product-cli/package.json +1 -1
- package/src/apps/product-cli/src/cli.ts +208 -11
- package/src/apps/product-cli/src/command.ts +276 -19
- package/src/apps/product-cli/src/index.ts +1 -0
- package/src/apps/product-cli/src/product-api.ts +165 -3
- package/src/apps/product-cli/src/repository-init.ts +8 -0
- package/src/apps/product-cli/src/runtime-contract.ts +81 -5
- package/src/apps/product-cli/src/user-token-file.ts +73 -0
- package/src/packages/contracts/package.json +5 -0
- package/src/packages/contracts/src/credit-pricing.ts +1 -1
- package/src/packages/contracts/src/database-events.ts +67 -0
- package/src/packages/contracts/src/framework-admission.ts +5 -4
- package/src/packages/contracts/src/framework-source-rules.ts +9 -2
- package/src/packages/contracts/src/index.ts +9 -0
- package/src/packages/contracts/src/operation-deployment-result.ts +121 -1
- package/src/packages/contracts/src/operation-failure.ts +72 -1
- package/src/packages/contracts/src/organization-mcp-connections.ts +7 -0
- package/src/packages/contracts/src/problem-policy.ts +17 -5
- package/src/packages/contracts/src/secret-names.ts +10 -2
- package/src/packages/sdk-ts/package.json +1 -1
- package/src/packages/sdk-ts/src/generated/index.ts +36 -0
- package/src/packages/sdk-ts/src/generated/sdk.gen.ts +265 -1
- package/src/packages/sdk-ts/src/generated/types.gen.ts +445 -2
- package/src/packages/sdk-ts/src/managed-mail-response.ts +12 -0
- package/src/packages/sdk-ts/src/managed-mail.ts +10 -1
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
NativeKeyringProfileRegistry,
|
|
15
15
|
NetworkTransportError,
|
|
16
16
|
OwnerOnlyProjectLinkStore,
|
|
17
|
+
PrivateSecretFileError,
|
|
17
18
|
ProductApiAuthenticationError,
|
|
18
19
|
ProductCli,
|
|
19
20
|
ProfileIndexFiles,
|
|
@@ -68,6 +69,7 @@ import {
|
|
|
68
69
|
parseCurrentIdentity,
|
|
69
70
|
parseDevAccessState,
|
|
70
71
|
parseDevAccessTicket,
|
|
72
|
+
parseGithubDisconnection,
|
|
71
73
|
parseOperation,
|
|
72
74
|
parseOperationEvent,
|
|
73
75
|
parseOrganizationReferral,
|
|
@@ -81,6 +83,7 @@ import {
|
|
|
81
83
|
parseSafeProblem,
|
|
82
84
|
parseWithLinkedProject,
|
|
83
85
|
prepareLocalSourcePublication,
|
|
86
|
+
preparePrivateSecretFile,
|
|
84
87
|
prepareUserTokenFile,
|
|
85
88
|
profileIndexDirectory,
|
|
86
89
|
profileLimitAction,
|
|
@@ -89,6 +92,7 @@ import {
|
|
|
89
92
|
publicWorkspace,
|
|
90
93
|
publishSourceSnapshot,
|
|
91
94
|
readBoundedResponseBody,
|
|
95
|
+
readPrivateWebhookCreateRequest,
|
|
92
96
|
readProjectLinks,
|
|
93
97
|
readSecretValueFromStandardInput,
|
|
94
98
|
recognizedCommandLabel,
|
|
@@ -102,7 +106,7 @@ import {
|
|
|
102
106
|
selectWorkspace,
|
|
103
107
|
verifiedUserId,
|
|
104
108
|
workspaceOf
|
|
105
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-GODV5QDC.js";
|
|
106
110
|
import {
|
|
107
111
|
CredentialStoreIntegrityError,
|
|
108
112
|
CredentialStoreUnavailableError,
|
|
@@ -269,6 +273,7 @@ export {
|
|
|
269
273
|
NetworkTransportError,
|
|
270
274
|
OwnerOnlyFileCredentialStore,
|
|
271
275
|
OwnerOnlyProjectLinkStore,
|
|
276
|
+
PrivateSecretFileError,
|
|
272
277
|
ProductApiAuthenticationError,
|
|
273
278
|
ProductCli,
|
|
274
279
|
ProfileIndexFiles,
|
|
@@ -325,6 +330,7 @@ export {
|
|
|
325
330
|
parseCurrentIdentity,
|
|
326
331
|
parseDevAccessState,
|
|
327
332
|
parseDevAccessTicket,
|
|
333
|
+
parseGithubDisconnection,
|
|
328
334
|
parseOperation,
|
|
329
335
|
parseOperationEvent,
|
|
330
336
|
parseOrganizationReferral,
|
|
@@ -338,6 +344,7 @@ export {
|
|
|
338
344
|
parseSafeProblem,
|
|
339
345
|
parseWithLinkedProject,
|
|
340
346
|
prepareLocalSourcePublication,
|
|
347
|
+
preparePrivateSecretFile,
|
|
341
348
|
prepareUserTokenFile,
|
|
342
349
|
profileIndexDirectory,
|
|
343
350
|
profileLimitAction,
|
|
@@ -346,6 +353,7 @@ export {
|
|
|
346
353
|
publicWorkspace,
|
|
347
354
|
publishSourceSnapshot,
|
|
348
355
|
readBoundedResponseBody,
|
|
356
|
+
readPrivateWebhookCreateRequest,
|
|
349
357
|
readProjectLinks,
|
|
350
358
|
readSecretValueFromStandardInput,
|
|
351
359
|
recognizedCommandLabel,
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { lstat, open } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
4
|
import {
|
|
4
5
|
assertManagedSourceResponse,
|
|
5
6
|
type ManagedProjectSource,
|
|
@@ -45,7 +46,12 @@ import {
|
|
|
45
46
|
EXPORT_PASSWORD_MIN_CHARACTERS,
|
|
46
47
|
exportPasswordMeetsMinimum,
|
|
47
48
|
} from "@ohmyhost/contracts/project-exports";
|
|
48
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
prepareUserTokenFile,
|
|
51
|
+
UserTokenFileError,
|
|
52
|
+
preparePrivateSecretFile,
|
|
53
|
+
PrivateSecretFileError,
|
|
54
|
+
} from "./user-token-file.js";
|
|
49
55
|
import { parseUserApiKeyPage } from "@ohmyhost/contracts/user-api-keys";
|
|
50
56
|
import { assertOrganizationCreditUsage } from "@ohmyhost/contracts/credit-pricing";
|
|
51
57
|
import {
|
|
@@ -108,7 +114,10 @@ import {
|
|
|
108
114
|
import {
|
|
109
115
|
parseCloudflareDnsAuthorization,
|
|
110
116
|
parseGithubConnectionAuthorization,
|
|
117
|
+
parseGithubDisconnection,
|
|
111
118
|
parseGithubOrganizationConnectionStatus,
|
|
119
|
+
parseOrganizationMcpConnectionList,
|
|
120
|
+
parseOrganizationMcpConnectionRevocation,
|
|
112
121
|
parseCloudflareDnsAuthorizationStatus,
|
|
113
122
|
parseDeploymentPlan,
|
|
114
123
|
parseProjectDataChangePlan,
|
|
@@ -352,6 +361,8 @@ const HELP_USAGE = Object.freeze({
|
|
|
352
361
|
"github connect":
|
|
353
362
|
"ohmyhost github connect --organization ULID --idempotency-key KEY --json (connect once, then link covered repositories without another browser consent)",
|
|
354
363
|
"github status": "ohmyhost github status --organization ULID --json",
|
|
364
|
+
"github disconnect":
|
|
365
|
+
"ohmyhost github disconnect --organization ULID --yes --json (Owner only; revokes the workspace GitHub connection and every repository grant under it, so auto-deploy and linked sources stop at once; the GitHub App stays installed for other workspaces, and github connect starts a new connection)",
|
|
355
366
|
"export create":
|
|
356
367
|
"ohmyhost export create --project ULID --idempotency-key KEY --stdin --json (password on stdin only; one accepted SQL ZIP per project per 24 hours)",
|
|
357
368
|
"export get":
|
|
@@ -381,6 +392,10 @@ const HELP_USAGE = Object.freeze({
|
|
|
381
392
|
"ohmyhost organization list [--profile-name NAME] --json (the workspaces of the chosen login's user and the one that login is scoped to)",
|
|
382
393
|
"organization use":
|
|
383
394
|
"ohmyhost organization use --organization ULID [--profile-name NAME] --json (binds a login that has no organization yet; another organization needs its own login)",
|
|
395
|
+
"organization mcp-connections list":
|
|
396
|
+
"ohmyhost organization mcp-connections list --organization ULID --json (Owner only; lists each MCP client connected to this workspace and the member who connected it; disconnected consents are not listed)",
|
|
397
|
+
"organization mcp-connections revoke":
|
|
398
|
+
"ohmyhost organization mcp-connections revoke --organization ULID --connection UUID --yes --json (Owner only; disconnects one MCP client from this workspace only, and the member's other workspaces are unaffected; repeat until it answers revoked)",
|
|
384
399
|
"operation get": "ohmyhost operation get OPERATION_ULID --json",
|
|
385
400
|
"operation reconcile":
|
|
386
401
|
"ohmyhost operation reconcile OPERATION_ULID --idempotency-key KEY --yes --json",
|
|
@@ -393,7 +408,7 @@ const HELP_USAGE = Object.freeze({
|
|
|
393
408
|
"feedback submit":
|
|
394
409
|
"ohmyhost feedback submit --organization ULID --kind bug|issue|feature_request --title TITLE --description REDACTED_REPORT [--project ULID] [--environment ULID] [--operation ULID] [--error-code CODE] [--client-version VERSION] --idempotency-key KEY --json",
|
|
395
410
|
"project create":
|
|
396
|
-
"ohmyhost project create --organization ULID --name NAME [--data-mode shared|isolated] [--dev-access-mode protected|public] [--region us|eu] --idempotency-key KEY --json (
|
|
411
|
+
"ohmyhost project create --organization ULID --name NAME [--include-development-environment true|false] [--data-mode shared|isolated] [--dev-access-mode protected|public] [--region us|eu] --idempotency-key KEY --json (Dev defaults to included; add it later with project dev add. Data mode defaults to shared; later changes do not copy data. The region is chosen once: us defaults to US; eu selects EU database, new files and builds; the customer API cannot change region later)",
|
|
397
412
|
"project data plan":
|
|
398
413
|
"ohmyhost project data plan --project ULID --change isolate_prod_keeps_data|isolate_dev_keeps_data|share_prod_keeps_data|reset_dev --json (shared is the optional creation default; review which data is kept or deleted; no data is copied)",
|
|
399
414
|
"project data change":
|
|
@@ -403,6 +418,7 @@ const HELP_USAGE = Object.freeze({
|
|
|
403
418
|
"project notes set":
|
|
404
419
|
"ohmyhost project notes set --project ULID --version NUMBER --markdown TEXT --idempotency-key KEY --json (no credentials or signed URLs)",
|
|
405
420
|
"project status": "ohmyhost project status --project ULID --json",
|
|
421
|
+
"project dev add": "ohmyhost project dev add --project ULID --idempotency-key KEY --json",
|
|
406
422
|
"project dev-access create": "ohmyhost project dev-access create --project ULID --json",
|
|
407
423
|
"project dev-share link": "ohmyhost project dev-share link --project ULID --json",
|
|
408
424
|
"project dev-share rotate":
|
|
@@ -444,6 +460,12 @@ const HELP_USAGE = Object.freeze({
|
|
|
444
460
|
"ohmyhost database table create --project ULID --environment dev|prod --table NAME --columns-file PATH [--primary-key COL[,COL]] --idempotency-key KEY --yes --json (the table is created in the public schema as the migration role, with the same access as migration tables, so a database watch can attach later; the columns file is a UTF-8 JSON array of 1 to 64 column objects, at most 64 KiB, each with name, type and optional nullable, identity and default; types: text, integer, bigint, boolean, numeric, double precision, timestamptz, date, uuid, jsonb; identity needs integer or bigint; default now needs timestamptz and default uuid needs uuid; identical repeats answer created false; at most 100 tables, 64 columns per table)",
|
|
445
461
|
"database webhook create":
|
|
446
462
|
"ohmyhost database webhook create --project ULID --environment dev|prod --url HTTPS_URL --event-types TYPE[,TYPE] [--headers-file PATH] --idempotency-key KEY --yes --json (the signing secret is shown once in this answer; types: database.created, database.ready, database.woke, database.slept, database.suspended, database.resized, database.deleted, data.<topic> for the rows of one watched table printed by database watch create, or data.* for every watched table; a bare * is not accepted and does not include data events; the headers file is a UTF-8 JSON object of at most 8 KiB)",
|
|
463
|
+
"database webhook subscription activate":
|
|
464
|
+
"ohmyhost database webhook subscription activate --project ULID --environment dev|prod --subscription ULID --generation N --url HTTPS_URL --event-types TYPE[,TYPE] [--headers-file PATH] --out NEW_PRIVATE_FILE --idempotency-key KEY --yes --json (the secret is written privately; repeat the same key and body after uncertainty using a new output file)",
|
|
465
|
+
"database webhook subscription deactivate":
|
|
466
|
+
"ohmyhost database webhook subscription deactivate --project ULID --environment dev|prod --subscription ULID --generation N --idempotency-key KEY --yes --json",
|
|
467
|
+
"database webhook subscription status":
|
|
468
|
+
"ohmyhost database webhook subscription status --project ULID [--environment dev|prod] --subscription ULID --json",
|
|
447
469
|
"database webhook list":
|
|
448
470
|
"ohmyhost database webhook list --project ULID [--environment dev|prod] --json (dev when omitted; the secret is never listed)",
|
|
449
471
|
"database webhook get":
|
|
@@ -568,6 +590,8 @@ const HELP_USAGE = Object.freeze({
|
|
|
568
590
|
"ohmyhost mail webhook verify --project ULID --environment ULID --idempotency-key KEY --json",
|
|
569
591
|
"mail webhook disable":
|
|
570
592
|
"ohmyhost mail webhook disable --project ULID --environment ULID --idempotency-key KEY --json",
|
|
593
|
+
"mail webhook rotate":
|
|
594
|
+
"ohmyhost mail webhook rotate --project ULID --environment ULID --idempotency-key KEY --yes --json (Owner only; issues a new signing secret for the same endpoint, stops the earlier secrets at once and ends receiving until the endpoint verifies the new one; the secret is returned once, so install it in Prod application secrets and never write it into files or notes)",
|
|
571
595
|
"mail messages list":
|
|
572
596
|
"ohmyhost mail messages list --project ULID --environment ULID [--after ULID] --json",
|
|
573
597
|
"mail messages get":
|
|
@@ -863,6 +887,48 @@ export class ProductCli {
|
|
|
863
887
|
}),
|
|
864
888
|
});
|
|
865
889
|
}
|
|
890
|
+
if (command.kind === "github-disconnect") {
|
|
891
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
892
|
+
const github = parseGithubDisconnection(await api.disconnectGithub(command.organizationId));
|
|
893
|
+
if (
|
|
894
|
+
github.connection !== null &&
|
|
895
|
+
github.connection.organization_id !== command.organizationId
|
|
896
|
+
)
|
|
897
|
+
throw new ResponseContractError();
|
|
898
|
+
return success(name, {
|
|
899
|
+
status: github.status,
|
|
900
|
+
github,
|
|
901
|
+
...(github.status === "connected"
|
|
902
|
+
? {}
|
|
903
|
+
: { next_action: this.githubConnectAction(command.organizationId) }),
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
if (command.kind === "organization-mcp-connections-list") {
|
|
907
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
908
|
+
const page = parseOrganizationMcpConnectionList(
|
|
909
|
+
await api.listOrganizationMcpConnections(command.organizationId),
|
|
910
|
+
);
|
|
911
|
+
return success(name, { status: "listed", connections: page.connections });
|
|
912
|
+
}
|
|
913
|
+
if (command.kind === "organization-mcp-connection-revoke") {
|
|
914
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
915
|
+
const revocation = parseOrganizationMcpConnectionRevocation(
|
|
916
|
+
await api.revokeOrganizationMcpConnection({
|
|
917
|
+
organizationId: command.organizationId,
|
|
918
|
+
connectionId: command.connectionId,
|
|
919
|
+
}),
|
|
920
|
+
);
|
|
921
|
+
return success(name, {
|
|
922
|
+
status: revocation.state,
|
|
923
|
+
revocation,
|
|
924
|
+
...(revocation.state === "revoked"
|
|
925
|
+
? {}
|
|
926
|
+
: {
|
|
927
|
+
next_action:
|
|
928
|
+
"Repeat this exact command until status is revoked; the client's active provider use is still draining.",
|
|
929
|
+
}),
|
|
930
|
+
});
|
|
931
|
+
}
|
|
866
932
|
if (command.kind === "whoami") return await this.getCurrentIdentity(command, signal);
|
|
867
933
|
if (
|
|
868
934
|
command.kind === "token-create" ||
|
|
@@ -1133,6 +1199,8 @@ export class ProductCli {
|
|
|
1133
1199
|
return success("project notes set", { status: "succeeded", notes });
|
|
1134
1200
|
}
|
|
1135
1201
|
if (command.kind === "project-status") return await this.getProjectStatus(command, signal);
|
|
1202
|
+
if (command.kind === "project-development-add")
|
|
1203
|
+
return await this.addProjectDevelopment(command, signal);
|
|
1136
1204
|
if (command.kind === "project-dev-access-create")
|
|
1137
1205
|
return await this.createDevAccessTicket(command, signal);
|
|
1138
1206
|
if (command.kind === "project-flag-status" || command.kind === "project-flag-set") {
|
|
@@ -1241,6 +1309,12 @@ export class ProductCli {
|
|
|
1241
1309
|
return await this.createDatabaseTable(command, signal);
|
|
1242
1310
|
if (command.kind === "database-webhook-create")
|
|
1243
1311
|
return await this.createDatabaseWebhook(command, signal);
|
|
1312
|
+
if (
|
|
1313
|
+
command.kind === "database-webhook-subscription-activate" ||
|
|
1314
|
+
command.kind === "database-webhook-subscription-deactivate" ||
|
|
1315
|
+
command.kind === "database-webhook-subscription-status"
|
|
1316
|
+
)
|
|
1317
|
+
return await this.databaseWebhookSubscription(command, signal);
|
|
1244
1318
|
if (command.kind === "database-webhook-list")
|
|
1245
1319
|
return await this.listDatabaseWebhooks(command, signal);
|
|
1246
1320
|
if (command.kind === "database-webhook-get")
|
|
@@ -1329,7 +1403,7 @@ export class ProductCli {
|
|
|
1329
1403
|
}
|
|
1330
1404
|
return await this.deleteEnvironmentSecret(command, signal);
|
|
1331
1405
|
} catch (error) {
|
|
1332
|
-
if (error instanceof UserTokenFileError)
|
|
1406
|
+
if (error instanceof UserTokenFileError || error instanceof PrivateSecretFileError)
|
|
1333
1407
|
return failure(name, 3, error.code, false, error.message);
|
|
1334
1408
|
if (error instanceof InteractiveSessionRequiredError)
|
|
1335
1409
|
return failure(
|
|
@@ -1904,6 +1978,9 @@ export class ProductCli {
|
|
|
1904
1978
|
name: command.name,
|
|
1905
1979
|
...(command.dataMode === undefined ? {} : { dataMode: command.dataMode }),
|
|
1906
1980
|
...(command.devAccessMode === undefined ? {} : { devAccessMode: command.devAccessMode }),
|
|
1981
|
+
...(command.includeDevelopmentEnvironment === undefined
|
|
1982
|
+
? {}
|
|
1983
|
+
: { includeDevelopmentEnvironment: command.includeDevelopmentEnvironment }),
|
|
1907
1984
|
...(command.region === undefined ? {} : { region: command.region }),
|
|
1908
1985
|
idempotencyKey: command.idempotencyKey,
|
|
1909
1986
|
}),
|
|
@@ -1959,6 +2036,20 @@ export class ProductCli {
|
|
|
1959
2036
|
return success("project status", { status: "succeeded", project, context: this.context() });
|
|
1960
2037
|
}
|
|
1961
2038
|
|
|
2039
|
+
private async addProjectDevelopment(
|
|
2040
|
+
command: Extract<ProductCliCommand, { kind: "project-development-add" }>,
|
|
2041
|
+
signal: AbortSignal,
|
|
2042
|
+
): Promise<CliResult> {
|
|
2043
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
2044
|
+
const operation = parseOperation(
|
|
2045
|
+
await api.addProjectDevelopmentEnvironment({
|
|
2046
|
+
projectId: command.projectId,
|
|
2047
|
+
idempotencyKey: command.idempotencyKey,
|
|
2048
|
+
}),
|
|
2049
|
+
);
|
|
2050
|
+
return success("project dev add", { status: "accepted", operation });
|
|
2051
|
+
}
|
|
2052
|
+
|
|
1962
2053
|
private async createDevAccessTicket(
|
|
1963
2054
|
command: Extract<ProductCliCommand, { kind: "project-dev-access-create" }>,
|
|
1964
2055
|
signal: AbortSignal,
|
|
@@ -2106,6 +2197,63 @@ export class ProductCli {
|
|
|
2106
2197
|
return success("database webhook create", { status: "succeeded", webhook });
|
|
2107
2198
|
}
|
|
2108
2199
|
|
|
2200
|
+
private async databaseWebhookSubscription(
|
|
2201
|
+
command: Extract<
|
|
2202
|
+
ProductCliCommand,
|
|
2203
|
+
{
|
|
2204
|
+
kind:
|
|
2205
|
+
| "database-webhook-subscription-activate"
|
|
2206
|
+
| "database-webhook-subscription-deactivate"
|
|
2207
|
+
| "database-webhook-subscription-status";
|
|
2208
|
+
}
|
|
2209
|
+
>,
|
|
2210
|
+
signal: AbortSignal,
|
|
2211
|
+
): Promise<CliResult> {
|
|
2212
|
+
const common = {
|
|
2213
|
+
projectId: command.projectId,
|
|
2214
|
+
environment: command.environment,
|
|
2215
|
+
subscriptionId: command.subscriptionId,
|
|
2216
|
+
};
|
|
2217
|
+
if (command.kind === "database-webhook-subscription-activate") {
|
|
2218
|
+
const request = await webhookCreateRequest(command);
|
|
2219
|
+
const file = await preparePrivateSecretFile(command.outputPath);
|
|
2220
|
+
try {
|
|
2221
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
2222
|
+
const value = await api.activateDatabaseWebhookSubscription({
|
|
2223
|
+
...common,
|
|
2224
|
+
generation: command.generation,
|
|
2225
|
+
idempotencyKey: command.idempotencyKey,
|
|
2226
|
+
request,
|
|
2227
|
+
});
|
|
2228
|
+
await file.save(value.secret);
|
|
2229
|
+
const subscription = {
|
|
2230
|
+
id: value.id,
|
|
2231
|
+
environment: value.environment,
|
|
2232
|
+
state: value.state,
|
|
2233
|
+
generation: value.generation,
|
|
2234
|
+
provider_id: value.provider_id,
|
|
2235
|
+
};
|
|
2236
|
+
return success(parsedCommandName(command), {
|
|
2237
|
+
status: "succeeded",
|
|
2238
|
+
subscription,
|
|
2239
|
+
secret_file: file.path,
|
|
2240
|
+
});
|
|
2241
|
+
} finally {
|
|
2242
|
+
await file.close();
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
2246
|
+
const subscription =
|
|
2247
|
+
command.kind === "database-webhook-subscription-status"
|
|
2248
|
+
? await api.getDatabaseWebhookSubscription(common)
|
|
2249
|
+
: await api.deactivateDatabaseWebhookSubscription({
|
|
2250
|
+
...common,
|
|
2251
|
+
generation: command.generation,
|
|
2252
|
+
idempotencyKey: command.idempotencyKey,
|
|
2253
|
+
});
|
|
2254
|
+
return success(parsedCommandName(command), { status: "succeeded", subscription });
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2109
2257
|
private async listDatabaseWebhooks(
|
|
2110
2258
|
command: Extract<ProductCliCommand, { kind: "database-webhook-list" }>,
|
|
2111
2259
|
signal: AbortSignal,
|
|
@@ -2742,7 +2890,7 @@ export class ProductCli {
|
|
|
2742
2890
|
await api.planDeployment({
|
|
2743
2891
|
projectId: command.projectId,
|
|
2744
2892
|
commitSha: command.commitSha,
|
|
2745
|
-
environment: command.environment,
|
|
2893
|
+
...(command.environment === undefined ? {} : { environment: command.environment }),
|
|
2746
2894
|
}),
|
|
2747
2895
|
);
|
|
2748
2896
|
let accepted: unknown;
|
|
@@ -2777,7 +2925,7 @@ export class ProductCli {
|
|
|
2777
2925
|
const notes =
|
|
2778
2926
|
operation.state === "succeeded"
|
|
2779
2927
|
? [
|
|
2780
|
-
`
|
|
2928
|
+
`If this is a Dev deployment, check project status for dev_access_mode. For protected Dev, run '${this.dependencies.commandPrefix} project dev-share link --project ULID --json' and open or share its persistent share_url; public Dev opens directly.`,
|
|
2781
2929
|
]
|
|
2782
2930
|
: [];
|
|
2783
2931
|
return success("deploy", {
|
|
@@ -3471,17 +3619,42 @@ const readBoundedUtf8File = async (
|
|
|
3471
3619
|
path: string,
|
|
3472
3620
|
maxBytes: number,
|
|
3473
3621
|
refusal: () => ProductCliFailure,
|
|
3622
|
+
privateFile = false,
|
|
3474
3623
|
): Promise<string> => {
|
|
3475
3624
|
let file: Awaited<ReturnType<typeof open>>;
|
|
3625
|
+
let before: Awaited<ReturnType<typeof lstat>> | undefined;
|
|
3476
3626
|
try {
|
|
3477
|
-
|
|
3627
|
+
if (privateFile) {
|
|
3628
|
+
if (!isAbsolute(path)) throw refusal();
|
|
3629
|
+
before = await lstat(path);
|
|
3630
|
+
if (
|
|
3631
|
+
!before.isFile() ||
|
|
3632
|
+
before.isSymbolicLink() ||
|
|
3633
|
+
before.nlink !== 1 ||
|
|
3634
|
+
(process.platform !== "win32" &&
|
|
3635
|
+
(before.uid !== process.getuid?.() || (before.mode & 0o077) !== 0))
|
|
3636
|
+
)
|
|
3637
|
+
throw refusal();
|
|
3638
|
+
}
|
|
3639
|
+
file = await open(path, privateFile ? constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) : "r");
|
|
3478
3640
|
} catch {
|
|
3479
3641
|
throw refusal();
|
|
3480
3642
|
}
|
|
3481
3643
|
const buffer = Buffer.alloc(maxBytes + 1);
|
|
3482
3644
|
try {
|
|
3483
3645
|
const stat = await file.stat();
|
|
3484
|
-
if (
|
|
3646
|
+
if (
|
|
3647
|
+
!stat.isFile() ||
|
|
3648
|
+
stat.size > maxBytes ||
|
|
3649
|
+
(before !== undefined &&
|
|
3650
|
+
(stat.ino !== before.ino ||
|
|
3651
|
+
stat.dev !== before.dev ||
|
|
3652
|
+
stat.nlink !== 1 ||
|
|
3653
|
+
stat.size !== before.size ||
|
|
3654
|
+
(process.platform !== "win32" &&
|
|
3655
|
+
(stat.uid !== process.getuid?.() || (stat.mode & 0o077) !== 0))))
|
|
3656
|
+
)
|
|
3657
|
+
throw refusal();
|
|
3485
3658
|
let length = 0;
|
|
3486
3659
|
while (length < buffer.length) {
|
|
3487
3660
|
const read = await file.read(buffer, length, buffer.length - length, null);
|
|
@@ -3501,14 +3674,19 @@ const readBoundedUtf8File = async (
|
|
|
3501
3674
|
|
|
3502
3675
|
/** The create request with the headers of `--headers-file`; a refused file sends nothing. */
|
|
3503
3676
|
const webhookCreateRequest = async (
|
|
3504
|
-
command:
|
|
3677
|
+
command: {
|
|
3678
|
+
readonly url: string;
|
|
3679
|
+
readonly eventTypes: readonly import("@ohmyhost/contracts/database-events").DatabaseWebhookEventPattern[];
|
|
3680
|
+
readonly headersFile: string | null;
|
|
3681
|
+
},
|
|
3682
|
+
privateHeaders = false,
|
|
3505
3683
|
) => {
|
|
3506
3684
|
const headersFailure = () =>
|
|
3507
3685
|
new ProductCliFailure(2, "headers_file_invalid", false, HEADERS_FILE_INVALID_ACTION);
|
|
3508
3686
|
const headers =
|
|
3509
3687
|
command.headersFile === null
|
|
3510
3688
|
? undefined
|
|
3511
|
-
: await readBoundedUtf8File(command.headersFile, 8_192, headersFailure).then(
|
|
3689
|
+
: await readBoundedUtf8File(command.headersFile, 8_192, headersFailure, privateHeaders).then(
|
|
3512
3690
|
(text: string): unknown => {
|
|
3513
3691
|
try {
|
|
3514
3692
|
return JSON.parse(text) as unknown;
|
|
@@ -3528,6 +3706,13 @@ const webhookCreateRequest = async (
|
|
|
3528
3706
|
}
|
|
3529
3707
|
};
|
|
3530
3708
|
|
|
3709
|
+
/** The local MCP webhook action reads only an absolute, owner-private header file, never a raw argument. */
|
|
3710
|
+
export const readPrivateWebhookCreateRequest = (input: {
|
|
3711
|
+
readonly url: string;
|
|
3712
|
+
readonly eventTypes: readonly import("@ohmyhost/contracts/database-events").DatabaseWebhookEventPattern[];
|
|
3713
|
+
readonly headersFile: string | null;
|
|
3714
|
+
}) => webhookCreateRequest(input, true);
|
|
3715
|
+
|
|
3531
3716
|
/**
|
|
3532
3717
|
* The schedule request of `database schedule set`: the statements file is a UTF-8 JSON array, and
|
|
3533
3718
|
* the schedule fields are checked by the same contract the service uses. A refused file or field
|
|
@@ -3702,12 +3887,18 @@ const parsedCommandName = (command: ProductCliCommand): CommandLabel => {
|
|
|
3702
3887
|
if (command.kind === "organization-use") return "organization use";
|
|
3703
3888
|
if (command.kind === "github-connect") return "github connect";
|
|
3704
3889
|
if (command.kind === "github-status") return "github status";
|
|
3890
|
+
if (command.kind === "github-disconnect") return "github disconnect";
|
|
3891
|
+
if (command.kind === "organization-mcp-connections-list")
|
|
3892
|
+
return "organization mcp-connections list";
|
|
3893
|
+
if (command.kind === "organization-mcp-connection-revoke")
|
|
3894
|
+
return "organization mcp-connections revoke";
|
|
3705
3895
|
if (command.kind === "project-list") return "project list";
|
|
3706
3896
|
if (command.kind === "database-compute-set") return "database compute set";
|
|
3707
3897
|
if (command.kind === "database-compute-get") return "database compute get";
|
|
3708
3898
|
if (command.kind === "project-context") return "project context";
|
|
3709
3899
|
if (command.kind === "project-notes-set") return "project notes set";
|
|
3710
3900
|
if (command.kind === "project-status") return "project status";
|
|
3901
|
+
if (command.kind === "project-development-add") return "project dev add";
|
|
3711
3902
|
if (command.kind === "project-dev-access-create") return "project dev-access create";
|
|
3712
3903
|
if (command.kind === "project-dev-share-link") return "project dev-share link";
|
|
3713
3904
|
if (command.kind === "project-dev-share-rotate") return "project dev-share rotate";
|
|
@@ -3728,6 +3919,12 @@ const parsedCommandName = (command: ProductCliCommand): CommandLabel => {
|
|
|
3728
3919
|
if (command.kind === "database-watch-delete") return "database watch delete";
|
|
3729
3920
|
if (command.kind === "database-table-create") return "database table create";
|
|
3730
3921
|
if (command.kind === "database-webhook-create") return "database webhook create";
|
|
3922
|
+
if (command.kind === "database-webhook-subscription-activate")
|
|
3923
|
+
return "database webhook subscription activate";
|
|
3924
|
+
if (command.kind === "database-webhook-subscription-deactivate")
|
|
3925
|
+
return "database webhook subscription deactivate";
|
|
3926
|
+
if (command.kind === "database-webhook-subscription-status")
|
|
3927
|
+
return "database webhook subscription status";
|
|
3731
3928
|
if (command.kind === "database-webhook-list") return "database webhook list";
|
|
3732
3929
|
if (command.kind === "database-webhook-get") return "database webhook get";
|
|
3733
3930
|
if (command.kind === "database-webhook-delete") return "database webhook delete";
|