@amerged/ohmyhost-cli 0.1.54 → 0.1.56
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-ZEKUTE7M.js → chunk-HNFWXGDN.js} +511 -60
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/src/apps/product-cli/package.json +1 -1
- package/src/apps/product-cli/src/cli.ts +128 -25
- package/src/apps/product-cli/src/command.ts +143 -20
- package/src/apps/product-cli/src/index.ts +1 -0
- package/src/apps/product-cli/src/product-api.ts +75 -2
- package/src/apps/product-cli/src/repository-init.ts +46 -9
- package/src/apps/product-cli/src/runtime-contract.ts +52 -4
- package/src/packages/contracts/package.json +10 -0
- package/src/packages/contracts/src/database-events.ts +1 -0
- package/src/packages/contracts/src/database-migration-admission.ts +33 -3
- package/src/packages/contracts/src/database-migration-errors.ts +10 -2
- package/src/packages/contracts/src/feedback.ts +9 -0
- package/src/packages/contracts/src/framework-admission.ts +4 -0
- package/src/packages/contracts/src/framework-source-rules.ts +55 -0
- package/src/packages/contracts/src/operation-failure.ts +8 -0
- package/src/packages/contracts/src/organization-mcp-connections.ts +7 -0
- package/src/packages/contracts/src/problem-policy.ts +74 -2
- package/src/packages/contracts/src/project-exports.ts +30 -0
- package/src/packages/contracts/src/secret-names.ts +9 -2
- package/src/packages/contracts/src/wfp-dispatch.ts +43 -0
- package/src/packages/sdk-ts/package.json +1 -1
- package/src/packages/sdk-ts/src/generated/index.ts +39 -0
- package/src/packages/sdk-ts/src/generated/sdk.gen.ts +303 -13
- package/src/packages/sdk-ts/src/generated/types.gen.ts +460 -12
- package/src/packages/sdk-ts/src/managed-mail-response.ts +12 -0
- package/src/packages/sdk-ts/src/managed-mail.ts +10 -1
- package/src/packages/workos-auth-contracts/src/webhooks.ts +7 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isUserSecretName } from "@ohmyhost/contracts/secret-names";
|
|
2
|
+
import { MCP_CONNECTION_ID_PATTERN } from "@ohmyhost/contracts/organization-mcp-connections";
|
|
2
3
|
import {
|
|
3
4
|
DATABASE_PAGE_MAX_ITEMS,
|
|
4
5
|
parseDatabaseCursor,
|
|
@@ -124,6 +125,24 @@ export type ProductCliCommand =
|
|
|
124
125
|
readonly organizationId: string;
|
|
125
126
|
readonly credentialStore: "native";
|
|
126
127
|
}
|
|
128
|
+
| {
|
|
129
|
+
readonly kind: "github-disconnect";
|
|
130
|
+
readonly organizationId: string;
|
|
131
|
+
readonly yes: true;
|
|
132
|
+
readonly credentialStore: "native";
|
|
133
|
+
}
|
|
134
|
+
| {
|
|
135
|
+
readonly kind: "organization-mcp-connections-list";
|
|
136
|
+
readonly organizationId: string;
|
|
137
|
+
readonly credentialStore: "native";
|
|
138
|
+
}
|
|
139
|
+
| {
|
|
140
|
+
readonly kind: "organization-mcp-connection-revoke";
|
|
141
|
+
readonly organizationId: string;
|
|
142
|
+
readonly connectionId: string;
|
|
143
|
+
readonly yes: true;
|
|
144
|
+
readonly credentialStore: "native";
|
|
145
|
+
}
|
|
127
146
|
| ({
|
|
128
147
|
readonly kind: "database-compute-set";
|
|
129
148
|
readonly projectId: string;
|
|
@@ -164,6 +183,12 @@ export type ProductCliCommand =
|
|
|
164
183
|
readonly exportId: string;
|
|
165
184
|
readonly credentialStore: "native";
|
|
166
185
|
}
|
|
186
|
+
| {
|
|
187
|
+
readonly kind: "export-download-link";
|
|
188
|
+
readonly projectId: string;
|
|
189
|
+
readonly exportId: string;
|
|
190
|
+
readonly credentialStore: "native";
|
|
191
|
+
}
|
|
167
192
|
| {
|
|
168
193
|
readonly kind: "token-create";
|
|
169
194
|
readonly organizationId: string;
|
|
@@ -485,6 +510,7 @@ export type ProductCliCommand =
|
|
|
485
510
|
readonly projectId: string;
|
|
486
511
|
readonly environment: "dev" | "prod";
|
|
487
512
|
readonly webhookId: string;
|
|
513
|
+
readonly idempotencyKey: string | null;
|
|
488
514
|
readonly yes: true;
|
|
489
515
|
readonly credentialStore: "native";
|
|
490
516
|
}
|
|
@@ -493,6 +519,7 @@ export type ProductCliCommand =
|
|
|
493
519
|
readonly projectId: string;
|
|
494
520
|
readonly environment: "dev" | "prod";
|
|
495
521
|
readonly webhookId: string;
|
|
522
|
+
readonly idempotencyKey: string | null;
|
|
496
523
|
readonly yes: true;
|
|
497
524
|
readonly credentialStore: "native";
|
|
498
525
|
}
|
|
@@ -510,6 +537,7 @@ export type ProductCliCommand =
|
|
|
510
537
|
readonly projectId: string;
|
|
511
538
|
readonly environment: "dev" | "prod";
|
|
512
539
|
readonly deliveryId: string;
|
|
540
|
+
readonly idempotencyKey: string | null;
|
|
513
541
|
readonly yes: true;
|
|
514
542
|
readonly credentialStore: "native";
|
|
515
543
|
}
|
|
@@ -560,6 +588,7 @@ export type ProductCliCommand =
|
|
|
560
588
|
readonly projectId: string;
|
|
561
589
|
readonly environment: "dev" | "prod";
|
|
562
590
|
readonly name: string;
|
|
591
|
+
readonly idempotencyKey: string | null;
|
|
563
592
|
readonly yes: true;
|
|
564
593
|
readonly credentialStore: "native";
|
|
565
594
|
}
|
|
@@ -736,6 +765,7 @@ export type ProductCliCommand =
|
|
|
736
765
|
| "mail webhook set"
|
|
737
766
|
| "mail webhook verify"
|
|
738
767
|
| "mail webhook disable"
|
|
768
|
+
| "mail webhook rotate"
|
|
739
769
|
| "mail messages list"
|
|
740
770
|
| "mail messages get"
|
|
741
771
|
| "mail messages retry";
|
|
@@ -1008,6 +1038,7 @@ export type RecognizedCommandLabel =
|
|
|
1008
1038
|
| "project notes set"
|
|
1009
1039
|
| "export create"
|
|
1010
1040
|
| "export get"
|
|
1041
|
+
| "export download-link"
|
|
1011
1042
|
| "billing recharge get"
|
|
1012
1043
|
| "billing recharge set"
|
|
1013
1044
|
| "billing checkout"
|
|
@@ -1038,8 +1069,11 @@ export type RecognizedCommandLabel =
|
|
|
1038
1069
|
| "organization create"
|
|
1039
1070
|
| "organization list"
|
|
1040
1071
|
| "organization use"
|
|
1072
|
+
| "organization mcp-connections list"
|
|
1073
|
+
| "organization mcp-connections revoke"
|
|
1041
1074
|
| "github connect"
|
|
1042
1075
|
| "github status"
|
|
1076
|
+
| "github disconnect"
|
|
1043
1077
|
| "project list"
|
|
1044
1078
|
| "project status"
|
|
1045
1079
|
| "project dev-access create"
|
|
@@ -1104,6 +1138,7 @@ export type RecognizedCommandLabel =
|
|
|
1104
1138
|
| "mail webhook set"
|
|
1105
1139
|
| "mail webhook verify"
|
|
1106
1140
|
| "mail webhook disable"
|
|
1141
|
+
| "mail webhook rotate"
|
|
1107
1142
|
| "mail messages list"
|
|
1108
1143
|
| "mail messages get"
|
|
1109
1144
|
| "mail messages retry"
|
|
@@ -1164,6 +1199,7 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
|
|
|
1164
1199
|
if (value === "profile" && values[0] === "list") return "profile list";
|
|
1165
1200
|
if (value === "github" && values[0] === "connect") return "github connect";
|
|
1166
1201
|
if (value === "github" && values[0] === "status") return "github status";
|
|
1202
|
+
if (value === "github" && values[0] === "disconnect") return "github disconnect";
|
|
1167
1203
|
if (value === "operation" && values[0] === "get") return "operation get";
|
|
1168
1204
|
if (value === "credits" && values[0] === "account") return "credits account";
|
|
1169
1205
|
if (value === "referral" && values[0] === "link") return "referral link";
|
|
@@ -1181,7 +1217,10 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
|
|
|
1181
1217
|
if (value === "operation" && values[0] === "reconcile") return "operation reconcile";
|
|
1182
1218
|
if (value === "token" && ["create", "list", "revoke"].includes(values[0] ?? ""))
|
|
1183
1219
|
return `token ${values[0]}` as RecognizedCommandLabel;
|
|
1184
|
-
if (
|
|
1220
|
+
if (
|
|
1221
|
+
value === "export" &&
|
|
1222
|
+
(values[0] === "create" || values[0] === "get" || values[0] === "download-link")
|
|
1223
|
+
)
|
|
1185
1224
|
return `export ${values[0]}`;
|
|
1186
1225
|
if (value === "feedback" && values[0] === "submit") return "feedback submit";
|
|
1187
1226
|
if (value === "feedback" && values[0] === "status") return "feedback status";
|
|
@@ -1193,6 +1232,10 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
|
|
|
1193
1232
|
if (value === "organization" && values[0] === "create") return "organization create";
|
|
1194
1233
|
if (value === "organization" && values[0] === "list") return "organization list";
|
|
1195
1234
|
if (value === "organization" && values[0] === "use") return "organization use";
|
|
1235
|
+
if (value === "organization" && values[0] === "mcp-connections") {
|
|
1236
|
+
if (values[1] === "list") return "organization mcp-connections list";
|
|
1237
|
+
if (values[1] === "revoke") return "organization mcp-connections revoke";
|
|
1238
|
+
}
|
|
1196
1239
|
if (value === "project" && values[0] === "list") return "project list";
|
|
1197
1240
|
if (value === "project" && values[0] === "context") return "project context";
|
|
1198
1241
|
if (value === "project" && values[0] === "notes" && values[1] === "set")
|
|
@@ -1316,6 +1359,7 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
|
|
|
1316
1359
|
if (values[1] === "set") return "mail webhook set";
|
|
1317
1360
|
if (values[1] === "verify") return "mail webhook verify";
|
|
1318
1361
|
if (values[1] === "disable") return "mail webhook disable";
|
|
1362
|
+
if (values[1] === "rotate") return "mail webhook rotate";
|
|
1319
1363
|
}
|
|
1320
1364
|
if (values[0] === "messages") {
|
|
1321
1365
|
if (values[1] === "list") return "mail messages list";
|
|
@@ -1956,14 +2000,19 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
1956
2000
|
}
|
|
1957
2001
|
if (first === "github") {
|
|
1958
2002
|
const subcommand = values.shift();
|
|
1959
|
-
if (
|
|
1960
|
-
if (subcommand !== "connect" && subcommand !== "status"
|
|
2003
|
+
if (wait || follow || stdin) throw new InvalidCommandError();
|
|
2004
|
+
if (subcommand !== "connect" && subcommand !== "status" && subcommand !== "disconnect")
|
|
2005
|
+
throw new InvalidCommandError();
|
|
2006
|
+
// Only disconnecting is destructive, and it requires --yes; the route reads no idempotency key.
|
|
2007
|
+
if (yes !== (subcommand === "disconnect")) throw new InvalidCommandError();
|
|
1961
2008
|
const options = parseOptions(
|
|
1962
2009
|
values,
|
|
1963
2010
|
subcommand === "connect" ? ["--organization", "--idempotency-key"] : ["--organization"],
|
|
1964
2011
|
);
|
|
1965
2012
|
const organizationId = options["--organization"];
|
|
1966
2013
|
if (!ORGANIZATION_ULID.test(organizationId)) throw new InvalidCommandError();
|
|
2014
|
+
if (subcommand === "disconnect")
|
|
2015
|
+
return { kind: "github-disconnect", organizationId, yes: true, credentialStore };
|
|
1967
2016
|
return subcommand === "connect"
|
|
1968
2017
|
? {
|
|
1969
2018
|
kind: "github-connect",
|
|
@@ -1973,6 +2022,33 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
1973
2022
|
}
|
|
1974
2023
|
: { kind: "github-status", organizationId, credentialStore };
|
|
1975
2024
|
}
|
|
2025
|
+
if (first === "organization" && values[0] === "mcp-connections") {
|
|
2026
|
+
values.shift();
|
|
2027
|
+
const subcommand = values.shift();
|
|
2028
|
+
if (wait || follow || stdin) throw new InvalidCommandError();
|
|
2029
|
+
// Only disconnecting a client is destructive, and it requires --yes; the route reads no key.
|
|
2030
|
+
if (yes !== (subcommand === "revoke")) throw new InvalidCommandError();
|
|
2031
|
+
if (subcommand === "list") {
|
|
2032
|
+
const organizationId = parseOptions(values, ["--organization"])["--organization"];
|
|
2033
|
+
if (!ORGANIZATION_ULID.test(organizationId)) throw new InvalidCommandError();
|
|
2034
|
+
return { kind: "organization-mcp-connections-list", organizationId, credentialStore };
|
|
2035
|
+
}
|
|
2036
|
+
if (subcommand === "revoke") {
|
|
2037
|
+
const options = parseOptions(values, ["--organization", "--connection"]);
|
|
2038
|
+
const organizationId = options["--organization"];
|
|
2039
|
+
const connectionId = options["--connection"];
|
|
2040
|
+
if (!ORGANIZATION_ULID.test(organizationId) || !MCP_CONNECTION_ID_PATTERN.test(connectionId))
|
|
2041
|
+
throw new InvalidCommandError();
|
|
2042
|
+
return {
|
|
2043
|
+
kind: "organization-mcp-connection-revoke",
|
|
2044
|
+
organizationId,
|
|
2045
|
+
connectionId,
|
|
2046
|
+
yes: true,
|
|
2047
|
+
credentialStore,
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
throw new InvalidCommandError();
|
|
2051
|
+
}
|
|
1976
2052
|
if (first === "organization") {
|
|
1977
2053
|
const subcommand = values.shift();
|
|
1978
2054
|
if (yes || wait || follow || stdin) throw new InvalidCommandError();
|
|
@@ -2552,10 +2628,16 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2552
2628
|
}
|
|
2553
2629
|
if (subcommand === "delete" || subcommand === "test") {
|
|
2554
2630
|
if (!yes || wait || follow || revoke || stdin) throw new InvalidCommandError();
|
|
2555
|
-
const options = parseOptionalOptions(values, [
|
|
2631
|
+
const options = parseOptionalOptions(values, [
|
|
2632
|
+
"--project",
|
|
2633
|
+
"--environment",
|
|
2634
|
+
"--webhook",
|
|
2635
|
+
"--idempotency-key",
|
|
2636
|
+
]);
|
|
2556
2637
|
const projectId = options["--project"],
|
|
2557
2638
|
environment = options["--environment"],
|
|
2558
|
-
webhookId = options["--webhook"]
|
|
2639
|
+
webhookId = options["--webhook"],
|
|
2640
|
+
idempotencyKey = options["--idempotency-key"] ?? null;
|
|
2559
2641
|
if (!isValue(projectId)) throw new InvalidCommandError();
|
|
2560
2642
|
if (environment !== "dev" && environment !== "prod") throw new InvalidCommandError();
|
|
2561
2643
|
const target = contractValue(() => parseDatabaseWebhookId(webhookId));
|
|
@@ -2565,6 +2647,7 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2565
2647
|
projectId,
|
|
2566
2648
|
environment,
|
|
2567
2649
|
webhookId: target,
|
|
2650
|
+
idempotencyKey,
|
|
2568
2651
|
yes: true,
|
|
2569
2652
|
credentialStore,
|
|
2570
2653
|
};
|
|
@@ -2573,6 +2656,7 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2573
2656
|
projectId,
|
|
2574
2657
|
environment,
|
|
2575
2658
|
webhookId: target,
|
|
2659
|
+
idempotencyKey,
|
|
2576
2660
|
yes: true,
|
|
2577
2661
|
credentialStore,
|
|
2578
2662
|
};
|
|
@@ -2611,7 +2695,12 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2611
2695
|
}
|
|
2612
2696
|
if (subcommand === "replay") {
|
|
2613
2697
|
if (!yes || wait || follow || revoke || stdin) throw new InvalidCommandError();
|
|
2614
|
-
const options = parseOptionalOptions(values, [
|
|
2698
|
+
const options = parseOptionalOptions(values, [
|
|
2699
|
+
"--project",
|
|
2700
|
+
"--environment",
|
|
2701
|
+
"--delivery",
|
|
2702
|
+
"--idempotency-key",
|
|
2703
|
+
]);
|
|
2615
2704
|
const projectId = options["--project"],
|
|
2616
2705
|
environment = options["--environment"],
|
|
2617
2706
|
deliveryId = options["--delivery"];
|
|
@@ -2622,6 +2711,7 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2622
2711
|
projectId,
|
|
2623
2712
|
environment,
|
|
2624
2713
|
deliveryId: contractValue(() => parseDatabaseDeliveryId(deliveryId)),
|
|
2714
|
+
idempotencyKey: options["--idempotency-key"] ?? null,
|
|
2625
2715
|
yes: true,
|
|
2626
2716
|
credentialStore,
|
|
2627
2717
|
};
|
|
@@ -2723,7 +2813,12 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2723
2813
|
}
|
|
2724
2814
|
if (subcommand === "delete" || subcommand === "run") {
|
|
2725
2815
|
if (!yes || wait || follow || revoke || stdin) throw new InvalidCommandError();
|
|
2726
|
-
const options = parseOptionalOptions(
|
|
2816
|
+
const options = parseOptionalOptions(
|
|
2817
|
+
values,
|
|
2818
|
+
subcommand === "run"
|
|
2819
|
+
? ["--project", "--environment", "--name", "--idempotency-key"]
|
|
2820
|
+
: ["--project", "--environment", "--name"],
|
|
2821
|
+
);
|
|
2727
2822
|
const projectId = options["--project"],
|
|
2728
2823
|
environment = options["--environment"];
|
|
2729
2824
|
if (!isValue(projectId) || (environment !== "dev" && environment !== "prod"))
|
|
@@ -2743,6 +2838,7 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2743
2838
|
projectId,
|
|
2744
2839
|
environment,
|
|
2745
2840
|
name,
|
|
2841
|
+
idempotencyKey: options["--idempotency-key"] ?? null,
|
|
2746
2842
|
yes: true,
|
|
2747
2843
|
credentialStore,
|
|
2748
2844
|
};
|
|
@@ -3087,6 +3183,19 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
3087
3183
|
const options = parseOptions(values, ["--project"]);
|
|
3088
3184
|
return { kind: "export-get", projectId: options["--project"], exportId, credentialStore };
|
|
3089
3185
|
}
|
|
3186
|
+
if (first === "export" && values[0] === "download-link") {
|
|
3187
|
+
if (yes || wait || follow || stdin) throw new InvalidCommandError();
|
|
3188
|
+
values.shift();
|
|
3189
|
+
const exportId = values.shift();
|
|
3190
|
+
if (!exportId) throw new InvalidCommandError();
|
|
3191
|
+
const options = parseOptions(values, ["--project"]);
|
|
3192
|
+
return {
|
|
3193
|
+
kind: "export-download-link",
|
|
3194
|
+
projectId: options["--project"],
|
|
3195
|
+
exportId,
|
|
3196
|
+
credentialStore,
|
|
3197
|
+
};
|
|
3198
|
+
}
|
|
3090
3199
|
if (first === "secret" && values[0] === "list") {
|
|
3091
3200
|
if (yes || wait || follow || stdin) throw new InvalidCommandError();
|
|
3092
3201
|
values.shift();
|
|
@@ -3263,20 +3372,27 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
3263
3372
|
const area = values.shift();
|
|
3264
3373
|
const sub =
|
|
3265
3374
|
area === "webhook" || area === "messages" || area === "domain" ? values.shift() : undefined;
|
|
3266
|
-
// Only retiring the mail domain
|
|
3375
|
+
// Only retiring the mail domain and rotating the webhook secret are destructive: each needs --yes.
|
|
3267
3376
|
const retiring = area === "domain" && sub === "delete";
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3377
|
+
const rotating = area === "webhook" && sub === "rotate";
|
|
3378
|
+
if (yes !== (retiring || rotating) || wait || follow || stdin) throw new InvalidCommandError();
|
|
3379
|
+
// Rotation takes only its scope and key, so any other option is refused rather than dropped.
|
|
3380
|
+
const options = parseOptionalOptions(
|
|
3381
|
+
values,
|
|
3382
|
+
rotating
|
|
3383
|
+
? ["--project", "--environment", "--idempotency-key"]
|
|
3384
|
+
: [
|
|
3385
|
+
"--project",
|
|
3386
|
+
"--environment",
|
|
3387
|
+
"--domain",
|
|
3388
|
+
"--sending",
|
|
3389
|
+
"--receiving",
|
|
3390
|
+
"--url",
|
|
3391
|
+
"--idempotency-key",
|
|
3392
|
+
"--message",
|
|
3393
|
+
"--after",
|
|
3394
|
+
],
|
|
3395
|
+
);
|
|
3280
3396
|
const required = (key: keyof typeof options) => {
|
|
3281
3397
|
const value = options[key];
|
|
3282
3398
|
if (!value) throw new InvalidCommandError();
|
|
@@ -3317,6 +3433,13 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
3317
3433
|
idempotencyKey: required("--idempotency-key"),
|
|
3318
3434
|
};
|
|
3319
3435
|
label = "mail webhook set";
|
|
3436
|
+
} else if (rotating) {
|
|
3437
|
+
request = {
|
|
3438
|
+
...scope,
|
|
3439
|
+
action: "webhook_rotate",
|
|
3440
|
+
idempotencyKey: required("--idempotency-key"),
|
|
3441
|
+
};
|
|
3442
|
+
label = "mail webhook rotate";
|
|
3320
3443
|
} else if (area === "webhook" && (sub === "verify" || sub === "disable")) {
|
|
3321
3444
|
request = {
|
|
3322
3445
|
...scope,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import {
|
|
2
3
|
executeManagedMail,
|
|
3
4
|
executeSharedMail,
|
|
@@ -72,7 +73,12 @@ import {
|
|
|
72
73
|
type ProjectContext,
|
|
73
74
|
type ProjectNotesReceipt,
|
|
74
75
|
} from "@ohmyhost/contracts/project-context";
|
|
75
|
-
import {
|
|
76
|
+
import {
|
|
77
|
+
assertProjectExport,
|
|
78
|
+
assertProjectExportDownloadLink,
|
|
79
|
+
type ProjectExport,
|
|
80
|
+
type ProjectExportDownloadLink,
|
|
81
|
+
} from "@ohmyhost/contracts/project-exports";
|
|
76
82
|
import {
|
|
77
83
|
parseUserApiKeyCreation,
|
|
78
84
|
parseUserApiKeyPage,
|
|
@@ -88,6 +94,7 @@ import {
|
|
|
88
94
|
createClient,
|
|
89
95
|
createProjectExport,
|
|
90
96
|
getProjectExport,
|
|
97
|
+
createProjectExportDownloadLink,
|
|
91
98
|
createUserApiKey,
|
|
92
99
|
listUserApiKeys,
|
|
93
100
|
revokeUserApiKey,
|
|
@@ -129,8 +136,13 @@ import {
|
|
|
129
136
|
type Organization,
|
|
130
137
|
type GithubConnectionAuthorization,
|
|
131
138
|
type GithubOrganizationConnectionStatus,
|
|
139
|
+
type OrganizationMcpConnectionList,
|
|
140
|
+
type OrganizationMcpConnectionRevocation,
|
|
132
141
|
connectGithubOrganization,
|
|
133
142
|
getGithubOrganizationConnection,
|
|
143
|
+
disconnectGithubOrganization,
|
|
144
|
+
listOrganizationMcpConnections,
|
|
145
|
+
revokeOrganizationMcpConnection,
|
|
134
146
|
deleteEnvironmentSecret,
|
|
135
147
|
deleteProject,
|
|
136
148
|
deletePaidProjectDomain,
|
|
@@ -295,6 +307,10 @@ export interface ProductApi {
|
|
|
295
307
|
idempotencyKey: string;
|
|
296
308
|
}): Promise<Operation>;
|
|
297
309
|
getProjectExport(input: { projectId: string; exportId: string }): Promise<ProjectExport>;
|
|
310
|
+
createProjectExportDownloadLink(input: {
|
|
311
|
+
projectId: string;
|
|
312
|
+
exportId: string;
|
|
313
|
+
}): Promise<ProjectExportDownloadLink>;
|
|
298
314
|
createUserApiKey(input: {
|
|
299
315
|
organizationId: string;
|
|
300
316
|
name: string;
|
|
@@ -397,11 +413,14 @@ export interface ProductApi {
|
|
|
397
413
|
readonly projectId: string;
|
|
398
414
|
readonly environment: "dev" | "prod";
|
|
399
415
|
readonly webhookId: string;
|
|
416
|
+
/** One new key per call when absent; the same key retries the same request and gets its stored answer. */
|
|
417
|
+
readonly idempotencyKey?: string;
|
|
400
418
|
}): Promise<DatabaseWebhookDeleted>;
|
|
401
419
|
testProjectDatabaseWebhook(input: {
|
|
402
420
|
readonly projectId: string;
|
|
403
421
|
readonly environment: "dev" | "prod";
|
|
404
422
|
readonly webhookId: string;
|
|
423
|
+
readonly idempotencyKey?: string;
|
|
405
424
|
}): Promise<DatabaseWebhookTestResult>;
|
|
406
425
|
createProjectDatabaseWatch(input: {
|
|
407
426
|
readonly projectId: string;
|
|
@@ -436,6 +455,7 @@ export interface ProductApi {
|
|
|
436
455
|
readonly projectId: string;
|
|
437
456
|
readonly environment: "dev" | "prod";
|
|
438
457
|
readonly deliveryId: string;
|
|
458
|
+
readonly idempotencyKey?: string;
|
|
439
459
|
}): Promise<DatabaseWebhookReplayAccepted>;
|
|
440
460
|
setProjectDatabaseSchedule(input: {
|
|
441
461
|
readonly projectId: string;
|
|
@@ -467,6 +487,7 @@ export interface ProductApi {
|
|
|
467
487
|
readonly projectId: string;
|
|
468
488
|
readonly environment: "dev" | "prod";
|
|
469
489
|
readonly name: string;
|
|
490
|
+
readonly idempotencyKey?: string;
|
|
470
491
|
}): Promise<DatabaseScheduleRunAccepted>;
|
|
471
492
|
getProjectDatabaseExecutionUsage(input: {
|
|
472
493
|
readonly projectId: string;
|
|
@@ -532,6 +553,12 @@ export interface ProductApi {
|
|
|
532
553
|
readonly idempotencyKey: string;
|
|
533
554
|
}): Promise<GithubConnectionAuthorization>;
|
|
534
555
|
getGithubConnection(organizationId: string): Promise<GithubOrganizationConnectionStatus>;
|
|
556
|
+
disconnectGithub(organizationId: string): Promise<GithubOrganizationConnectionStatus>;
|
|
557
|
+
listOrganizationMcpConnections(organizationId: string): Promise<OrganizationMcpConnectionList>;
|
|
558
|
+
revokeOrganizationMcpConnection(input: {
|
|
559
|
+
readonly organizationId: string;
|
|
560
|
+
readonly connectionId: string;
|
|
561
|
+
}): Promise<OrganizationMcpConnectionRevocation>;
|
|
535
562
|
linkSource(input: {
|
|
536
563
|
readonly projectId: string;
|
|
537
564
|
readonly repositoryOwner: string;
|
|
@@ -777,6 +804,16 @@ export class GeneratedSdkProductApi implements ProductApi {
|
|
|
777
804
|
assertProjectExport(result);
|
|
778
805
|
return result;
|
|
779
806
|
}
|
|
807
|
+
public async createProjectExportDownloadLink(
|
|
808
|
+
input: Parameters<ProductApi["createProjectExportDownloadLink"]>[0],
|
|
809
|
+
) {
|
|
810
|
+
const result = await createProjectExportDownloadLink(
|
|
811
|
+
{ project_id: input.projectId, export_id: input.exportId },
|
|
812
|
+
{ client: this.#client },
|
|
813
|
+
);
|
|
814
|
+
assertProjectExportDownloadLink(result);
|
|
815
|
+
return result;
|
|
816
|
+
}
|
|
780
817
|
public async getCurrentIdentity(): Promise<CurrentIdentity> {
|
|
781
818
|
return getCurrentIdentity({}, { client: this.#client });
|
|
782
819
|
}
|
|
@@ -1148,6 +1185,7 @@ export class GeneratedSdkProductApi implements ProductApi {
|
|
|
1148
1185
|
): Promise<DatabaseWebhookDeleted> {
|
|
1149
1186
|
const value = await deleteProjectDatabaseWebhook(
|
|
1150
1187
|
{
|
|
1188
|
+
"Idempotency-Key": input.idempotencyKey ?? randomUUID(),
|
|
1151
1189
|
project_id: input.projectId,
|
|
1152
1190
|
environment: input.environment,
|
|
1153
1191
|
webhook_id: input.webhookId,
|
|
@@ -1164,6 +1202,7 @@ export class GeneratedSdkProductApi implements ProductApi {
|
|
|
1164
1202
|
): Promise<DatabaseWebhookTestResult> {
|
|
1165
1203
|
const value = await testProjectDatabaseWebhook(
|
|
1166
1204
|
{
|
|
1205
|
+
"Idempotency-Key": input.idempotencyKey ?? randomUUID(),
|
|
1167
1206
|
project_id: input.projectId,
|
|
1168
1207
|
environment: input.environment,
|
|
1169
1208
|
webhook_id: input.webhookId,
|
|
@@ -1201,6 +1240,7 @@ export class GeneratedSdkProductApi implements ProductApi {
|
|
|
1201
1240
|
): Promise<DatabaseWebhookReplayAccepted> {
|
|
1202
1241
|
const value = await replayProjectDatabaseWebhookDelivery(
|
|
1203
1242
|
{
|
|
1243
|
+
"Idempotency-Key": input.idempotencyKey ?? randomUUID(),
|
|
1204
1244
|
project_id: input.projectId,
|
|
1205
1245
|
environment: input.environment,
|
|
1206
1246
|
delivery_id: input.deliveryId,
|
|
@@ -1299,7 +1339,12 @@ export class GeneratedSdkProductApi implements ProductApi {
|
|
|
1299
1339
|
input: Parameters<ProductApi["runProjectDatabaseSchedule"]>[0],
|
|
1300
1340
|
): Promise<DatabaseScheduleRunAccepted> {
|
|
1301
1341
|
const value = await runProjectDatabaseSchedule(
|
|
1302
|
-
{
|
|
1342
|
+
{
|
|
1343
|
+
"Idempotency-Key": input.idempotencyKey ?? randomUUID(),
|
|
1344
|
+
project_id: input.projectId,
|
|
1345
|
+
environment: input.environment,
|
|
1346
|
+
name: input.name,
|
|
1347
|
+
},
|
|
1303
1348
|
{ client: this.#client },
|
|
1304
1349
|
);
|
|
1305
1350
|
assertDatabaseScheduleRunAccepted(value);
|
|
@@ -1522,6 +1567,34 @@ export class GeneratedSdkProductApi implements ProductApi {
|
|
|
1522
1567
|
);
|
|
1523
1568
|
}
|
|
1524
1569
|
|
|
1570
|
+
public async disconnectGithub(
|
|
1571
|
+
organizationId: string,
|
|
1572
|
+
): Promise<GithubOrganizationConnectionStatus> {
|
|
1573
|
+
return disconnectGithubOrganization(
|
|
1574
|
+
{ organization_id: organizationId },
|
|
1575
|
+
{ client: this.#client },
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
public async listOrganizationMcpConnections(
|
|
1580
|
+
organizationId: string,
|
|
1581
|
+
): Promise<OrganizationMcpConnectionList> {
|
|
1582
|
+
return listOrganizationMcpConnections(
|
|
1583
|
+
{ organization_id: organizationId },
|
|
1584
|
+
{ client: this.#client },
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
public async revokeOrganizationMcpConnection(input: {
|
|
1589
|
+
readonly organizationId: string;
|
|
1590
|
+
readonly connectionId: string;
|
|
1591
|
+
}): Promise<OrganizationMcpConnectionRevocation> {
|
|
1592
|
+
return revokeOrganizationMcpConnection(
|
|
1593
|
+
{ organization_id: input.organizationId, connection_id: input.connectionId },
|
|
1594
|
+
{ client: this.#client },
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1525
1598
|
public async linkSource(input: {
|
|
1526
1599
|
readonly projectId: string;
|
|
1527
1600
|
readonly repositoryOwner: string;
|
|
@@ -23,7 +23,9 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
databaseContractCodes,
|
|
25
25
|
declaredDependencyNames,
|
|
26
|
+
importsSocketPrimitive,
|
|
26
27
|
isDatabaseContractModule,
|
|
28
|
+
isSocketPrimitiveModule,
|
|
27
29
|
MANAGED_BETTER_AUTH_VERSION,
|
|
28
30
|
packageManagerDeclaration,
|
|
29
31
|
parsePackageManifest,
|
|
@@ -79,11 +81,15 @@ const GATEWAY_BINDING_NAME = /^OHMYHOST_(?:MAIL|STORAGE)_GATEWAY$/u;
|
|
|
79
81
|
const GATEWAY_WORD_TOKEN = /[\p{ID_Start}_$][\p{ID_Continue}$]*/uy;
|
|
80
82
|
// The catalog names a module only by a path of its grammar; a file name with a space, for example,
|
|
81
83
|
// is not one, so its blocker carries the path beside a sentence that does not quote it.
|
|
82
|
-
const UNNAMED_MODULE_MESSAGES: Readonly<
|
|
84
|
+
const UNNAMED_MODULE_MESSAGES: Readonly<
|
|
85
|
+
Record<DatabaseContractCode | "socket_primitive_unsupported", string>
|
|
86
|
+
> = Object.freeze({
|
|
83
87
|
database_binding_private:
|
|
84
88
|
'The module at path reads a database connection string (DATABASE_URL, HYPERDRIVE, connectionString or a postgres:// URL); none reaches a customer Worker. Call the database with createPrivateDatabaseClient from "@ohmyhost/customer-runtime/database". Commit and push the change, then plan the new commit.',
|
|
85
89
|
database_driver_unsupported:
|
|
86
90
|
'The module at path imports a database socket driver (pg, postgres, pg-native or mysql2); customer Workers cannot open sockets. Call the database with createPrivateDatabaseClient from "@ohmyhost/customer-runtime/database". Commit and push the change, then plan the new commit.',
|
|
91
|
+
socket_primitive_unsupported:
|
|
92
|
+
"The module at path loads cloudflare:sockets; customer Workers cannot open sockets. Call HTTPS services through the global fetch function and declare each origin in runtime.egress.allow in ohmyhost.yaml. Commit and push the change, then plan the new commit.",
|
|
87
93
|
});
|
|
88
94
|
|
|
89
95
|
// Only a call constructs the client; a comment or a type-only import never does.
|
|
@@ -538,6 +544,7 @@ async function judgeSource(
|
|
|
538
544
|
...source.findings.map((finding) => requiredCatalogBlocker(finding, context.applicationRoot)),
|
|
539
545
|
...(await workerModuleBlockers(context)),
|
|
540
546
|
...(await databaseContractBlockers(context, context.provider)),
|
|
547
|
+
...(await socketPrimitiveBlockers(context)),
|
|
541
548
|
...(await gatewayBindingBlockers(context)),
|
|
542
549
|
...(await storageClientBlockers(context)),
|
|
543
550
|
...(await migrationSqlBlockers(context, context.provider)),
|
|
@@ -837,14 +844,44 @@ async function databaseContractBlockers(
|
|
|
837
844
|
const information = await stat(absolute);
|
|
838
845
|
if (!information.isFile() || information.size > MAXIMUM_SOURCE_BYTES) continue;
|
|
839
846
|
for (const code of databaseContractCodes(await readFile(absolute, "utf8")))
|
|
840
|
-
blockers.push(
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
847
|
+
blockers.push(moduleBlocker(code, path, context.applicationRoot));
|
|
848
|
+
}
|
|
849
|
+
return blockers;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** The blocker of a module refused by a code of the catalog's module grammar. */
|
|
853
|
+
function moduleBlocker(
|
|
854
|
+
code: keyof typeof UNNAMED_MODULE_MESSAGES,
|
|
855
|
+
path: string,
|
|
856
|
+
applicationRoot: ApplicationRoot,
|
|
857
|
+
): RepositoryInitBlocker {
|
|
858
|
+
return (
|
|
859
|
+
catalogBlocker({ code, path }, applicationRoot) ??
|
|
860
|
+
Object.freeze({
|
|
861
|
+
code,
|
|
862
|
+
path: repositoryPath(applicationRoot, path),
|
|
863
|
+
message: UNNAMED_MODULE_MESSAGES[code],
|
|
864
|
+
})
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* A customer Worker opens no raw TCP socket: only fetch() passes the egress policy. Planning parses
|
|
870
|
+
* the reachable modules and refuses `cloudflare:sockets` whatever the configuration. Init cannot
|
|
871
|
+
* parse (the CLI denies `@babel/`), so its early hint lists every module whose raw text names the
|
|
872
|
+
* quoted specifier, reachable or not and comments included, with or without the database.
|
|
873
|
+
*/
|
|
874
|
+
async function socketPrimitiveBlockers(
|
|
875
|
+
context: SourceCheckContext,
|
|
876
|
+
): Promise<RepositoryInitBlocker[]> {
|
|
877
|
+
const blockers: RepositoryInitBlocker[] = [];
|
|
878
|
+
for (const path of context.files) {
|
|
879
|
+
if (!isSocketPrimitiveModule(path)) continue;
|
|
880
|
+
const absolute = resolve(context.applicationDirectory, path);
|
|
881
|
+
const information = await stat(absolute);
|
|
882
|
+
if (!information.isFile() || information.size > MAXIMUM_SOURCE_BYTES) continue;
|
|
883
|
+
if (importsSocketPrimitive(await readFile(absolute, "utf8")))
|
|
884
|
+
blockers.push(moduleBlocker("socket_primitive_unsupported", path, context.applicationRoot));
|
|
848
885
|
}
|
|
849
886
|
return blockers;
|
|
850
887
|
}
|