@amerged/ohmyhost-cli 0.1.54 → 0.1.55
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-4OAAJX5B.js} +297 -54
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/apps/product-cli/package.json +1 -1
- package/src/apps/product-cli/src/cli.ts +70 -25
- package/src/apps/product-cli/src/command.ts +52 -5
- package/src/apps/product-cli/src/product-api.ts +36 -2
- package/src/apps/product-cli/src/repository-init.ts +46 -9
- package/src/apps/product-cli/src/runtime-contract.ts +14 -4
- package/src/packages/contracts/package.json +5 -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/problem-policy.ts +74 -2
- package/src/packages/contracts/src/project-exports.ts +30 -0
- 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 +33 -0
- package/src/packages/sdk-ts/src/generated/sdk.gen.ts +253 -13
- package/src/packages/sdk-ts/src/generated/types.gen.ts +385 -11
- package/src/packages/workos-auth-contracts/src/webhooks.ts +7 -0
|
@@ -232,7 +232,13 @@ export interface PublicCloudflareDnsAuthorization {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
export interface PublicCloudflareDnsAuthorizationStatus {
|
|
235
|
-
readonly status:
|
|
235
|
+
readonly status:
|
|
236
|
+
| "not_authorized"
|
|
237
|
+
| "pending"
|
|
238
|
+
| "authorized"
|
|
239
|
+
| "reauthorization_required"
|
|
240
|
+
| "expired"
|
|
241
|
+
| "revoked";
|
|
236
242
|
readonly zone: string | null;
|
|
237
243
|
readonly scopes: readonly ("dns.write" | "zone.read")[];
|
|
238
244
|
readonly expires_at: string | null;
|
|
@@ -428,6 +434,7 @@ export const parseCloudflareDnsAuthorizationStatus = (
|
|
|
428
434
|
(status !== "not_authorized" &&
|
|
429
435
|
status !== "pending" &&
|
|
430
436
|
status !== "authorized" &&
|
|
437
|
+
status !== "reauthorization_required" &&
|
|
431
438
|
status !== "expired" &&
|
|
432
439
|
status !== "revoked") ||
|
|
433
440
|
(status === "not_authorized"
|
|
@@ -439,7 +446,8 @@ export const parseCloudflareDnsAuthorizationStatus = (
|
|
|
439
446
|
new Set(scopes).size !== scopes.length ||
|
|
440
447
|
(input["expires_at"] !== null && !isIsoInstant(input["expires_at"])) ||
|
|
441
448
|
(status === "authorized" && [...scopes].sort().join(",") !== "dns.write,zone.read") ||
|
|
442
|
-
(status === "not_authorized" && (scopes.length !== 0 || input["expires_at"] !== null))
|
|
449
|
+
(status === "not_authorized" && (scopes.length !== 0 || input["expires_at"] !== null)) ||
|
|
450
|
+
(status === "reauthorization_required" && (scopes.length !== 0 || input["expires_at"] !== null))
|
|
443
451
|
) {
|
|
444
452
|
throw new ResponseContractError();
|
|
445
453
|
}
|
|
@@ -1042,7 +1050,7 @@ export interface PublicFunctionRun {
|
|
|
1042
1050
|
readonly deployment_id: string;
|
|
1043
1051
|
readonly cron: string;
|
|
1044
1052
|
readonly scheduled_at: string;
|
|
1045
|
-
readonly state: "due" | "running" | "retry" | "succeeded" | "failed";
|
|
1053
|
+
readonly state: "due" | "running" | "retry" | "succeeded" | "failed" | "skipped";
|
|
1046
1054
|
readonly attempt: number;
|
|
1047
1055
|
readonly status_code: number | null;
|
|
1048
1056
|
readonly started_at: string | null;
|
|
@@ -1073,7 +1081,9 @@ const parseFunctionRun = (value: unknown): PublicFunctionRun => {
|
|
|
1073
1081
|
input["cron"].length === 0 ||
|
|
1074
1082
|
input["cron"].length > 64 ||
|
|
1075
1083
|
!isIsoInstant(input["scheduled_at"]) ||
|
|
1076
|
-
!["due", "running", "retry", "succeeded", "failed"].includes(
|
|
1084
|
+
!["due", "running", "retry", "succeeded", "failed", "skipped"].includes(
|
|
1085
|
+
String(input["state"]),
|
|
1086
|
+
) ||
|
|
1077
1087
|
!Number.isSafeInteger(input["attempt"]) ||
|
|
1078
1088
|
Number(input["attempt"]) < 0 ||
|
|
1079
1089
|
Number(input["attempt"]) > 3 ||
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"types": "./dist/platform-origins.d.ts",
|
|
46
46
|
"import": "./dist/platform-origins.js"
|
|
47
47
|
},
|
|
48
|
+
"./wfp-dispatch": {
|
|
49
|
+
"source": "./src/wfp-dispatch.ts",
|
|
50
|
+
"types": "./dist/wfp-dispatch.d.ts",
|
|
51
|
+
"import": "./dist/wfp-dispatch.js"
|
|
52
|
+
},
|
|
48
53
|
".": {
|
|
49
54
|
"source": "./src/index.ts",
|
|
50
55
|
"types": "./dist/index.d.ts",
|
|
@@ -33,6 +33,7 @@ export const DATABASE_SCHEDULE_STATEMENT_MAX_BYTES = 16 * 1024;
|
|
|
33
33
|
export const DATABASE_SCHEDULE_STATEMENTS_MAX_BYTES = 64 * 1024;
|
|
34
34
|
export const DATABASE_SCHEDULE_MIN_TIMEOUT_MS = 1_000;
|
|
35
35
|
export const DATABASE_SCHEDULE_DEFAULT_TIMEOUT_MS = 10_000;
|
|
36
|
+
/** timeout_ms sets only the schedule's initial statement_timeout; the schedule's own statements can change it. The real bound is the platform abort at timeout_ms plus 75 seconds. */
|
|
36
37
|
export const DATABASE_SCHEDULE_MAX_TIMEOUT_MS = 30_000;
|
|
37
38
|
|
|
38
39
|
export const DATABASE_SCHEDULE_OUTCOMES = [
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type DatabaseMigrationCaptureTrigger,
|
|
6
6
|
} from "./database-migration-capture.js";
|
|
7
7
|
import {
|
|
8
|
+
isSqlKeyword,
|
|
8
9
|
readMigrationSql,
|
|
9
10
|
rejectMigrationSqlReferences,
|
|
10
11
|
type MigrationSqlToken,
|
|
@@ -151,6 +152,33 @@ function rejectFunctionBodyReferences(sql: string): void {
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
/**
|
|
156
|
+
* A SECURITY DEFINER body runs with its definer's rights, so every `SET search_path` in the statement header must pin the
|
|
157
|
+
* path to an empty list or one that starts with pg_catalog. A path the session can change, or one that starts with a
|
|
158
|
+
* customer schema, lets the caller decide which relation or function the definer touches. The body is one dollar-quoted
|
|
159
|
+
* token, so only the header can name a path, and a later SET overrides an earlier one: each occurrence must pin.
|
|
160
|
+
*/
|
|
161
|
+
function pinsSearchPath(tokens: readonly MigrationSqlToken[]): boolean {
|
|
162
|
+
let found = false;
|
|
163
|
+
for (let index = 0; index + 2 < tokens.length; index += 1) {
|
|
164
|
+
if (!isSqlKeyword(tokens[index], "set") || !isSqlKeyword(tokens[index + 1], "search_path"))
|
|
165
|
+
continue;
|
|
166
|
+
const operator = tokens[index + 2];
|
|
167
|
+
const assigns =
|
|
168
|
+
isSqlKeyword(operator, "to") || (operator?.kind === "symbol" && operator.value === "=");
|
|
169
|
+
const first = tokens[index + 3];
|
|
170
|
+
if (!assigns || !first) return false;
|
|
171
|
+
found = true;
|
|
172
|
+
if (first.kind === "string") {
|
|
173
|
+
const list = first.value.trim().toLowerCase();
|
|
174
|
+
if (list !== "" && !/^pg_catalog(?:\s*,|$)/u.test(list)) return false;
|
|
175
|
+
} else if (first.kind === "word" || first.kind === "identifier") {
|
|
176
|
+
if (first.value.toLowerCase() !== "pg_catalog") return false;
|
|
177
|
+
} else return false;
|
|
178
|
+
}
|
|
179
|
+
return found;
|
|
180
|
+
}
|
|
181
|
+
|
|
154
182
|
function admitStatement(tokens: readonly MigrationSqlToken[], sql: string): void {
|
|
155
183
|
const normalized = tokens
|
|
156
184
|
.map((token) => (token.kind === "string" ? "'literal'" : token.text.toLowerCase()))
|
|
@@ -161,10 +189,12 @@ function admitStatement(tokens: readonly MigrationSqlToken[], sql: string): void
|
|
|
161
189
|
rejectFunctionBodyReferences(sql);
|
|
162
190
|
if (
|
|
163
191
|
!/\blanguage\s+(?:sql|plpgsql)\b/u.test(normalized) ||
|
|
164
|
-
(/\bsecurity\s+definer\b/u.test(normalized) &&
|
|
165
|
-
!/\bset\s+search_path\s*(?:=\s*|to\s+)/u.test(normalized))
|
|
192
|
+
(/\bsecurity\s+definer\b/u.test(normalized) && !pinsSearchPath(tokens))
|
|
166
193
|
) {
|
|
167
|
-
throw new DatabaseMigrationAdmissionError(
|
|
194
|
+
throw new DatabaseMigrationAdmissionError(
|
|
195
|
+
"unsupported",
|
|
196
|
+
"a SECURITY DEFINER function needs every SET search_path to be '' or to start with pg_catalog",
|
|
197
|
+
);
|
|
168
198
|
}
|
|
169
199
|
return;
|
|
170
200
|
}
|
|
@@ -7,8 +7,16 @@ export type DatabaseMigrationAdmissionReason =
|
|
|
7
7
|
export class DatabaseMigrationAdmissionError extends Error {
|
|
8
8
|
public readonly code = "database_migration_not_admitted";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** `detail` names the exact requirement for a refusal whose cause the customer can change; the code and reason do not change. */
|
|
11
|
+
public constructor(
|
|
12
|
+
public readonly reason: DatabaseMigrationAdmissionReason,
|
|
13
|
+
detail?: string,
|
|
14
|
+
) {
|
|
15
|
+
super(
|
|
16
|
+
detail === undefined
|
|
17
|
+
? "Database migration is not admitted"
|
|
18
|
+
: `Database migration is not admitted: ${detail}`,
|
|
19
|
+
);
|
|
12
20
|
this.name = "DatabaseMigrationAdmissionError";
|
|
13
21
|
}
|
|
14
22
|
}
|
|
@@ -93,6 +93,7 @@ const detailSentence = new RegExp(
|
|
|
93
93
|
"(?:title|description) must be a string\\.",
|
|
94
94
|
"(?:title|description) must not be empty\\.",
|
|
95
95
|
"(?:title|description) must not start or end with whitespace; trim it\\.",
|
|
96
|
+
"(?:title|description) must not contain a credential, key or connection string; remove it and submit again\\.",
|
|
96
97
|
"(?:title|description) has [1-9][0-9]{0,8} characters, over the (?:160|8000)-character limit; shorten it, it is never truncated\\.",
|
|
97
98
|
"title must not contain line breaks, tabs or other control characters\\.",
|
|
98
99
|
"description must not contain control characters other than tabs and line breaks, such as terminal color codes\\.",
|
|
@@ -147,6 +148,10 @@ export function parseFeedbackSubmission(value: unknown): FeedbackSubmission {
|
|
|
147
148
|
return v as unknown as FeedbackSubmission;
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/** Token, key and connection-string shapes that a customer must not paste into feedback; feedback is stored without expiry. */
|
|
152
|
+
const CREDENTIAL_SHAPE =
|
|
153
|
+
/whsec_[A-Za-z0-9]{20,}|omh_(?:ab|am)_[A-Za-z0-9_-]{16,}|sk_(?:live|test)_[A-Za-z0-9]{10,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s@/?#]+@/iu;
|
|
154
|
+
|
|
150
155
|
/** The same rules as validText, each failure named for one field. */
|
|
151
156
|
function textProblems(field: string, value: unknown, max: number, multiline: boolean): string[] {
|
|
152
157
|
if (typeof value !== "string") return [`${field} must be a string.`];
|
|
@@ -159,6 +164,10 @@ function textProblems(field: string, value: unknown, max: number, multiline: boo
|
|
|
159
164
|
problems.push(
|
|
160
165
|
`${field} has ${String(length)} characters, over the ${String(max)}-character limit; shorten it, it is never truncated.`,
|
|
161
166
|
);
|
|
167
|
+
if (CREDENTIAL_SHAPE.test(value))
|
|
168
|
+
problems.push(
|
|
169
|
+
`${field} must not contain a credential, key or connection string; remove it and submit again.`,
|
|
170
|
+
);
|
|
162
171
|
if (hasControlCharacter(value, multiline))
|
|
163
172
|
problems.push(
|
|
164
173
|
multiline
|
|
@@ -375,6 +375,10 @@ const FRAMEWORK_CONVERSION_DETAILS = Object.freeze({
|
|
|
375
375
|
paths: ["module"],
|
|
376
376
|
template: `"{{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". ${PUSH_AND_PLAN}`,
|
|
377
377
|
},
|
|
378
|
+
socket_primitive_unsupported: {
|
|
379
|
+
paths: ["module"],
|
|
380
|
+
template: `"{{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. ${PUSH_AND_PLAN}`,
|
|
381
|
+
},
|
|
378
382
|
source_syntax_invalid: {
|
|
379
383
|
paths: ["module"],
|
|
380
384
|
template:
|
|
@@ -143,6 +143,21 @@ const PNPM_RESOLVED_VERSION = /^([^()]+)(?:\(.*\))?$/u;
|
|
|
143
143
|
const DEFAULT_EXPORT_PATTERN = /\bexport\s+default\b/u;
|
|
144
144
|
const FETCH_HANDLER_PATTERN = /(?:[{,;}]|\basync)\s*fetch\s*(?:\(|:|,|\})/u;
|
|
145
145
|
const SCHEDULED_HANDLER_PATTERN = /\bscheduled\s*(?:\(|:|,|\})/u;
|
|
146
|
+
/** The raw TCP primitive of the Workers runtime; a customer Worker never loads it. */
|
|
147
|
+
export const SOCKET_PRIMITIVE_SPECIFIER = "cloudflare:sockets" as const;
|
|
148
|
+
// The early hint reads the raw text: the quoted specifier, after string escapes are decoded.
|
|
149
|
+
const SOCKET_PRIMITIVE_PATTERN = new RegExp(`["'\`]${SOCKET_PRIMITIVE_SPECIFIER}["'\`]`, "u");
|
|
150
|
+
const STRING_ESCAPE =
|
|
151
|
+
/\\(?:x([0-9A-Fa-f]{2})|u([0-9A-Fa-f]{4})|u\{([0-9A-Fa-f]{1,6})\}|(?:\r\n|[\n\r\u2028\u2029])|([^\n\r\u2028\u2029]))/gu;
|
|
152
|
+
const SIMPLE_STRING_ESCAPES: Readonly<Record<string, string>> = Object.freeze({
|
|
153
|
+
b: "\b",
|
|
154
|
+
f: "\f",
|
|
155
|
+
n: "\n",
|
|
156
|
+
r: "\r",
|
|
157
|
+
t: "\t",
|
|
158
|
+
v: "\v",
|
|
159
|
+
"0": "\0",
|
|
160
|
+
});
|
|
146
161
|
// No connection string reaches a customer Worker, and a Worker cannot open a socket.
|
|
147
162
|
const DATABASE_CONTRACT_PATTERNS = Object.freeze([
|
|
148
163
|
[
|
|
@@ -440,6 +455,38 @@ export function databaseContractCodes(source: string): readonly DatabaseContract
|
|
|
440
455
|
);
|
|
441
456
|
}
|
|
442
457
|
|
|
458
|
+
/**
|
|
459
|
+
* The early hint that a module names the raw socket primitive `cloudflare:sockets` in quotes, for
|
|
460
|
+
* `ohmyhost init`, which cannot parse source. It reads the raw text with string escapes decoded
|
|
461
|
+
* (`"cloudflare\x3asockets"` is found) and blanks no comment, so a regex literal cannot hide an
|
|
462
|
+
* import; a mention in a comment, a type-only import and a variable that holds the specifier count
|
|
463
|
+
* too. Planning does not rely on it: SourceFetcher decides from parsed, decoded specifiers.
|
|
464
|
+
*/
|
|
465
|
+
export function importsSocketPrimitive(source: string): boolean {
|
|
466
|
+
return SOCKET_PRIMITIVE_PATTERN.test(decodeStringEscapes(source));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function decodeStringEscapes(source: string): string {
|
|
470
|
+
return source.replace(
|
|
471
|
+
STRING_ESCAPE,
|
|
472
|
+
(
|
|
473
|
+
match,
|
|
474
|
+
hex: string | undefined,
|
|
475
|
+
unit: string | undefined,
|
|
476
|
+
braces: string | undefined,
|
|
477
|
+
plain: string | undefined,
|
|
478
|
+
) => {
|
|
479
|
+
const code = hex ?? unit ?? braces;
|
|
480
|
+
if (code !== undefined) {
|
|
481
|
+
const point = Number.parseInt(code, 16);
|
|
482
|
+
return point > 0x10ffff ? match : String.fromCodePoint(point);
|
|
483
|
+
}
|
|
484
|
+
// A line continuation spells nothing; any other escaped character stands for itself.
|
|
485
|
+
return plain === undefined ? "" : (SIMPLE_STRING_ESCAPES[plain] ?? plain);
|
|
486
|
+
},
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
|
|
443
490
|
/**
|
|
444
491
|
* The handler rules a Worker module breaks, ignoring comments: a default export, with fetch when
|
|
445
492
|
* the module serves requests (runtime.mode: functions) and scheduled when crons are declared.
|
|
@@ -522,6 +569,14 @@ export function isDatabaseContractModule(path: string): boolean {
|
|
|
522
569
|
return /\.(?:astro|ts|tsx|js|jsx|mjs|mts)$/u.test(path) && !/\.d\.[cm]?ts$/u.test(path);
|
|
523
570
|
}
|
|
524
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Whether `ohmyhost init` scans a module for the socket primitive: every source extension a Worker
|
|
574
|
+
* bundle can load, without TypeScript declaration files, which never run.
|
|
575
|
+
*/
|
|
576
|
+
export function isSocketPrimitiveModule(path: string): boolean {
|
|
577
|
+
return /\.(?:astro|[cm]?[jt]sx?)$/u.test(path) && !/\.d\.[cm]?ts$/u.test(path);
|
|
578
|
+
}
|
|
579
|
+
|
|
525
580
|
function manifestFindings(
|
|
526
581
|
input: FrameworkSourceRuleInput,
|
|
527
582
|
versions: readonly FrameworkVersionAdmission[],
|
|
@@ -130,6 +130,14 @@ const failures = {
|
|
|
130
130
|
"The Prod deployment changed before promotion could start.",
|
|
131
131
|
"Read current Prod status, run 'ohmyhost deployment promote plan' again and confirm it with the new resource_etag and confirmation_token. Replaying this terminal operation cannot replace its stale target.",
|
|
132
132
|
],
|
|
133
|
+
project_handle_taken: [
|
|
134
|
+
"The requested project handle was taken before the rename could finish. The project keeps its current handle.",
|
|
135
|
+
"Run 'ohmyhost project handle check --handle NAME --json' or MCP project_handle_check, choose a handle that is still free, then submit the rename again with the current ETag and a new idempotency key. Replaying this terminal operation cannot take the handle.",
|
|
136
|
+
],
|
|
137
|
+
managed_source_dispatch_failed: [
|
|
138
|
+
"The managed source change could not be dispatched for processing, so it was ended.",
|
|
139
|
+
"Read the current source to confirm it did not change, then submit the change again with a new idempotency key.",
|
|
140
|
+
],
|
|
133
141
|
} as const;
|
|
134
142
|
|
|
135
143
|
export interface PublicOperationFailure {
|
|
@@ -326,6 +326,13 @@ export const PROBLEM_POLICY = {
|
|
|
326
326
|
action: "The project already answers on this address; no rename is needed.",
|
|
327
327
|
title: "Project address is unchanged",
|
|
328
328
|
},
|
|
329
|
+
database_limit_reached: {
|
|
330
|
+
status: 409,
|
|
331
|
+
retryable: false,
|
|
332
|
+
action:
|
|
333
|
+
"Delete a database you no longer need, or the project whose database it is, then deploy again. The limit counts the organization's live databases.",
|
|
334
|
+
title: "Database limit reached",
|
|
335
|
+
},
|
|
329
336
|
project_rename_blocked: {
|
|
330
337
|
status: 409,
|
|
331
338
|
retryable: true,
|
|
@@ -407,6 +414,13 @@ export const PROBLEM_POLICY = {
|
|
|
407
414
|
"Read the workspace sender resource and project binding. Reuse requires explicit domain-use authority, target-project editing and a current verified application identity with the same registrable main domain. Read the current revision before changing settings. Detach a shared project binding explicitly; legacy domain deletion cannot retire a resource used by another project.",
|
|
408
415
|
title: "Mail domain conflict",
|
|
409
416
|
},
|
|
417
|
+
mail_domain_pending_limit: {
|
|
418
|
+
status: 409,
|
|
419
|
+
retryable: false,
|
|
420
|
+
action:
|
|
421
|
+
"This organization already holds the maximum number of unverified workspace mail domains. Verify one of them, or retire an unused one, and then add this domain again.",
|
|
422
|
+
title: "Mail domain pending limit",
|
|
423
|
+
},
|
|
410
424
|
mail_domain_required: {
|
|
411
425
|
status: 409,
|
|
412
426
|
retryable: false,
|
|
@@ -501,6 +515,13 @@ export const PROBLEM_POLICY = {
|
|
|
501
515
|
"Keep the flag on, remove the custom domain with 'ohmyhost domain paid delete', or buy Paid, then switch the flag off.",
|
|
502
516
|
title: "Powered-by flag required",
|
|
503
517
|
},
|
|
518
|
+
build_capacity_reached: {
|
|
519
|
+
status: 429,
|
|
520
|
+
retryable: false,
|
|
521
|
+
action:
|
|
522
|
+
"This organization already has its maximum number of open builds. Wait for an open deployment to finish, then start a new deployment with a new idempotency key.",
|
|
523
|
+
title: "Build capacity reached",
|
|
524
|
+
},
|
|
504
525
|
rate_limited: {
|
|
505
526
|
status: 429,
|
|
506
527
|
retryable: true,
|
|
@@ -561,6 +582,13 @@ export const PROBLEM_POLICY = {
|
|
|
561
582
|
"Stop retries and submit feedback with this operation ID. A platform recovery review is required.",
|
|
562
583
|
title: "Recovery attempts exhausted",
|
|
563
584
|
},
|
|
585
|
+
reconciliation_not_pending: {
|
|
586
|
+
status: 409,
|
|
587
|
+
retryable: false,
|
|
588
|
+
action:
|
|
589
|
+
"Do not repeat this reconciliation: no uncertain delivery or provider mutation is pending for this operation. If the operation still does not finish, submit feedback with this operation ID.",
|
|
590
|
+
title: "No recovery pending",
|
|
591
|
+
},
|
|
564
592
|
service_unavailable: {
|
|
565
593
|
status: 503,
|
|
566
594
|
retryable: true,
|
|
@@ -583,11 +611,20 @@ export const PROBLEM_POLICY = {
|
|
|
583
611
|
status: 409,
|
|
584
612
|
retryable: false,
|
|
585
613
|
action:
|
|
586
|
-
"A live
|
|
614
|
+
"A live connection holds it; its holder removes it with ohmyhost domain paid delete --project ULID --hostname HOST --yes --json. To connect it here, run application_domain_identity_declare (CLI: ohmyhost mail identity declare --project ULID --hostname HOST --idempotency-key KEY --json), add the _omh-project.HOST TXT record it returns, run application_domain_identity_verify (CLI: ohmyhost mail identity verify --project ULID --expected-revision N --idempotency-key KEY --json), then apply again.",
|
|
587
615
|
restAction:
|
|
588
|
-
"A live
|
|
616
|
+
"A live connection holds it; its holder removes it with ohmyhost domain paid delete --project ULID --hostname HOST --yes --json. To connect it here, run application_domain_identity_declare (CLI: ohmyhost mail identity declare --project ULID --hostname HOST --idempotency-key KEY --json), add the _omh-project.HOST TXT record it returns, run application_domain_identity_verify (CLI: ohmyhost mail identity verify --project ULID --expected-revision N --idempotency-key KEY --json), then apply again.",
|
|
589
617
|
title: "Domain hostname is already connected",
|
|
590
618
|
},
|
|
619
|
+
domain_ownership_required: {
|
|
620
|
+
status: 409,
|
|
621
|
+
retryable: false,
|
|
622
|
+
action:
|
|
623
|
+
"This hostname is not verified for this project yet. Run application_domain_identity_declare (CLI: ohmyhost mail identity declare --project ULID --hostname HOST --idempotency-key KEY --json) and add the _omh-project.HOST TXT record it returns; then application_domain_identity_verify (CLI: ohmyhost mail identity verify --project ULID --expected-revision N --idempotency-key KEY --json), then apply again. Repeating before then cannot work.",
|
|
624
|
+
restAction:
|
|
625
|
+
"This hostname is not verified for this project yet. Run application_domain_identity_declare (CLI: ohmyhost mail identity declare --project ULID --hostname HOST --idempotency-key KEY --json) and add the _omh-project.HOST TXT record it returns; then application_domain_identity_verify (CLI: ohmyhost mail identity verify --project ULID --expected-revision N --idempotency-key KEY --json), then apply again. Repeating before then cannot work.",
|
|
626
|
+
title: "Verify the domain before connecting it",
|
|
627
|
+
},
|
|
591
628
|
domain_dns_conflict: {
|
|
592
629
|
status: 409,
|
|
593
630
|
retryable: false,
|
|
@@ -645,6 +682,41 @@ export const PROBLEM_POLICY = {
|
|
|
645
682
|
action:
|
|
646
683
|
"Read project status and Paid domain status to identify the pending change. If a Paid domain removal is pending, retry it as a current owner with a new idempotency key. If a project address change is pending, submit a fresh address change as a current owner. After it finishes, create a new project deletion plan.",
|
|
647
684
|
},
|
|
685
|
+
native_auth_launch_unavailable: {
|
|
686
|
+
status: 409,
|
|
687
|
+
retryable: false,
|
|
688
|
+
title: "Native Auth cannot launch yet",
|
|
689
|
+
action:
|
|
690
|
+
"Read the Native Auth configuration with 'ohmyhost auth config get --project ULID --environment ULID --json'. Its readiness shows which requirement is missing: a Paid plan, a verified sender domain, an approved canonical origin or storage. Complete that requirement, then send the change again with a new idempotency key. Repeating unchanged does not help.",
|
|
691
|
+
},
|
|
692
|
+
native_auth_provider_unavailable: {
|
|
693
|
+
status: 409,
|
|
694
|
+
retryable: false,
|
|
695
|
+
title: "Native Auth provider unavailable",
|
|
696
|
+
action:
|
|
697
|
+
"This sign-in provider cannot be enabled for this project's current Native Auth state. Read the provider with 'ohmyhost auth provider get --project ULID --environment ULID --provider google|github --json' and complete the Native Auth configuration it reports. Repeating unchanged does not help.",
|
|
698
|
+
},
|
|
699
|
+
native_auth_epoch_exhausted: {
|
|
700
|
+
status: 409,
|
|
701
|
+
retryable: false,
|
|
702
|
+
title: "Native Auth policy changes exhausted",
|
|
703
|
+
action:
|
|
704
|
+
"This project's Native Auth policy has reached its revision limit, so no further policy change is accepted. Do not retry. Contact support with the request_id of this response.",
|
|
705
|
+
},
|
|
706
|
+
project_domains_conflict: {
|
|
707
|
+
status: 409,
|
|
708
|
+
retryable: false,
|
|
709
|
+
title: "Project domains belong to another handle",
|
|
710
|
+
action:
|
|
711
|
+
"The domains of this project were configured under another project handle. Read the project with 'ohmyhost project status --project ULID --json' to see its current handle, then repeat the domain configuration with a new idempotency key. Do not replay the earlier request.",
|
|
712
|
+
},
|
|
713
|
+
native_user_conflict: {
|
|
714
|
+
status: 409,
|
|
715
|
+
retryable: false,
|
|
716
|
+
title: "Native Auth user conflicts with current state",
|
|
717
|
+
action:
|
|
718
|
+
"The user already exists, or the user is not in the state this action needs (for example a pending user cannot be suspended, and only a pending invitation can be resent). Read the user with 'ohmyhost auth user get --project ULID --environment ULID --user UUID --json' and choose the action that matches its status.",
|
|
719
|
+
},
|
|
648
720
|
} as const;
|
|
649
721
|
|
|
650
722
|
export type ProblemCode = keyof typeof PROBLEM_POLICY;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { publicOperationFailure, type PublicOperationFailure } from "./operation-failure.js";
|
|
2
|
+
/** Minimum characters for a new export password; restore and capture keep their own bounds. */
|
|
3
|
+
export const EXPORT_PASSWORD_MIN_CHARACTERS = 12;
|
|
4
|
+
/** Counts code points, the characters a customer types, matching JSON Schema minLength. */
|
|
5
|
+
export function exportPasswordMeetsMinimum(value: string): boolean {
|
|
6
|
+
return Array.from(value).length >= EXPORT_PASSWORD_MIN_CHARACTERS;
|
|
7
|
+
}
|
|
2
8
|
export interface ProjectExport {
|
|
3
9
|
readonly id: string;
|
|
4
10
|
readonly project_id: string;
|
|
@@ -18,6 +24,30 @@ export interface ProjectExport {
|
|
|
18
24
|
} | null;
|
|
19
25
|
}
|
|
20
26
|
/** The public export shape carries no job password, source URL or permanent storage credential. */
|
|
27
|
+
/** The answer of one audited download link: a signed URL and its expiry, never the archive state. */
|
|
28
|
+
export interface ProjectExportDownloadLink {
|
|
29
|
+
id: string;
|
|
30
|
+
project_id: string;
|
|
31
|
+
download_url: string;
|
|
32
|
+
download_expires_at: string;
|
|
33
|
+
}
|
|
34
|
+
export function assertProjectExportDownloadLink(
|
|
35
|
+
value: unknown,
|
|
36
|
+
): asserts value is ProjectExportDownloadLink {
|
|
37
|
+
if (
|
|
38
|
+
!record(value) ||
|
|
39
|
+
Object.keys(value).sort().join(",") !== "download_expires_at,download_url,id,project_id" ||
|
|
40
|
+
typeof value["id"] !== "string" ||
|
|
41
|
+
!id.test(value["id"]) ||
|
|
42
|
+
typeof value["project_id"] !== "string" ||
|
|
43
|
+
!id.test(value["project_id"]) ||
|
|
44
|
+
typeof value["download_url"] !== "string" ||
|
|
45
|
+
!value["download_url"].startsWith("https://") ||
|
|
46
|
+
!timestamp(value["download_expires_at"])
|
|
47
|
+
)
|
|
48
|
+
throw new TypeError("Project export download link is invalid");
|
|
49
|
+
}
|
|
50
|
+
|
|
21
51
|
export function assertProjectExport(value: unknown): asserts value is ProjectExport {
|
|
22
52
|
if (
|
|
23
53
|
!record(value) ||
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every dynamic-dispatch call that runs customer code carries. The public gateway, the
|
|
3
|
+
* functions scheduler and the deploy health probe all read this module, so no path runs customer
|
|
4
|
+
* code under looser limits than the live request path, and the egress context has one shape for
|
|
5
|
+
* the one outbound policy Worker that parses it.
|
|
6
|
+
*/
|
|
7
|
+
export const WFP_DISPATCH_LIMITS = Object.freeze({
|
|
8
|
+
cpuMs: 50,
|
|
9
|
+
subRequests: 10,
|
|
10
|
+
});
|
|
11
|
+
export const WFP_EGRESS_CONTEXT_VERSION = 1 as const;
|
|
12
|
+
|
|
13
|
+
/** The trusted `EGRESS_CONTEXT` parameter the dispatcher hands the outbound policy Worker. */
|
|
14
|
+
export type WfpEgressContext = Readonly<{
|
|
15
|
+
version: typeof WFP_EGRESS_CONTEXT_VERSION;
|
|
16
|
+
projectId: string;
|
|
17
|
+
allowedOrigins: readonly string[];
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The context of one project: its ULID and the sorted allowed HTTPS origins, nothing else. The
|
|
22
|
+
* outbound Worker fails closed on anything it cannot parse, so every dispatcher builds it here.
|
|
23
|
+
*/
|
|
24
|
+
export function buildEgressContext(
|
|
25
|
+
projectId: string,
|
|
26
|
+
allowedOrigins: readonly string[],
|
|
27
|
+
): WfpEgressContext {
|
|
28
|
+
return Object.freeze({
|
|
29
|
+
version: WFP_EGRESS_CONTEXT_VERSION,
|
|
30
|
+
projectId,
|
|
31
|
+
allowedOrigins: Object.freeze([...allowedOrigins]),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The error a Worker raises when an invocation exceeds the CPU limit above. */
|
|
36
|
+
export function isCpuLimitError(error: unknown): boolean {
|
|
37
|
+
return error instanceof Error && error.message.includes("CPU time limit");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** What a visitor and the deploy health verdict are told when that limit stops an invocation. */
|
|
41
|
+
export function cpuLimitMessage(): string {
|
|
42
|
+
return `Runtime limit exceeded: this request used more than ${WFP_DISPATCH_LIMITS.cpuMs} ms of CPU time. This is not a rate limit; reduce the work per request.`;
|
|
43
|
+
}
|
|
@@ -30,6 +30,7 @@ export {
|
|
|
30
30
|
createProjectDataChange,
|
|
31
31
|
createProjectDevAccessTicket,
|
|
32
32
|
createProjectExport,
|
|
33
|
+
createProjectExportDownloadLink,
|
|
33
34
|
createUserApiKey,
|
|
34
35
|
createWorkspaceMailDomain,
|
|
35
36
|
declareApplicationDomainIdentity,
|
|
@@ -44,6 +45,7 @@ export {
|
|
|
44
45
|
detachProjectMailDomainBinding,
|
|
45
46
|
diffManagedSource,
|
|
46
47
|
disableManagedMailReceiving,
|
|
48
|
+
disconnectGithubOrganization,
|
|
47
49
|
ensureProjectDevShareLink,
|
|
48
50
|
getAccountProfile,
|
|
49
51
|
getApplicationDomainIdentity,
|
|
@@ -97,6 +99,7 @@ export {
|
|
|
97
99
|
listManagedSourceFiles,
|
|
98
100
|
listManagedSourceVersions,
|
|
99
101
|
listNativeAuthUsers,
|
|
102
|
+
listOrganizationMcpConnections,
|
|
100
103
|
listProjectDatabaseAccess,
|
|
101
104
|
listProjectDatabaseScheduleRuns,
|
|
102
105
|
listProjectDatabaseSchedules,
|
|
@@ -132,11 +135,13 @@ export {
|
|
|
132
135
|
revokeApplicationDomainIdentityDnsAuthorization,
|
|
133
136
|
revokeCurrentSession,
|
|
134
137
|
revokeNativeAuthUserSessions,
|
|
138
|
+
revokeOrganizationMcpConnection,
|
|
135
139
|
revokeProjectDatabaseAccess,
|
|
136
140
|
revokeProjectDevShareLink,
|
|
137
141
|
revokeUserApiKey,
|
|
138
142
|
revokeWorkspaceMailDomainDnsAuthorization,
|
|
139
143
|
rollbackDeployment,
|
|
144
|
+
rotateManagedMailWebhookSecret,
|
|
140
145
|
rotateProjectDevShareLink,
|
|
141
146
|
runProjectDatabaseSchedule,
|
|
142
147
|
setProjectCreditBudget,
|
|
@@ -320,6 +325,11 @@ export type {
|
|
|
320
325
|
CreateProjectError,
|
|
321
326
|
CreateProjectErrors,
|
|
322
327
|
CreateProjectExportData,
|
|
328
|
+
CreateProjectExportDownloadLinkData,
|
|
329
|
+
CreateProjectExportDownloadLinkError,
|
|
330
|
+
CreateProjectExportDownloadLinkErrors,
|
|
331
|
+
CreateProjectExportDownloadLinkResponse,
|
|
332
|
+
CreateProjectExportDownloadLinkResponses,
|
|
323
333
|
CreateProjectExportError,
|
|
324
334
|
CreateProjectExportErrors,
|
|
325
335
|
CreateProjectExportResponse,
|
|
@@ -453,6 +463,11 @@ export type {
|
|
|
453
463
|
DisableManagedMailReceivingErrors,
|
|
454
464
|
DisableManagedMailReceivingResponse,
|
|
455
465
|
DisableManagedMailReceivingResponses,
|
|
466
|
+
DisconnectGithubOrganizationData,
|
|
467
|
+
DisconnectGithubOrganizationError,
|
|
468
|
+
DisconnectGithubOrganizationErrors,
|
|
469
|
+
DisconnectGithubOrganizationResponse,
|
|
470
|
+
DisconnectGithubOrganizationResponses,
|
|
456
471
|
EnsureProjectDevShareLinkData,
|
|
457
472
|
EnsureProjectDevShareLinkError,
|
|
458
473
|
EnsureProjectDevShareLinkErrors,
|
|
@@ -744,6 +759,11 @@ export type {
|
|
|
744
759
|
ListNativeAuthUsersErrors,
|
|
745
760
|
ListNativeAuthUsersResponse,
|
|
746
761
|
ListNativeAuthUsersResponses,
|
|
762
|
+
ListOrganizationMcpConnectionsData,
|
|
763
|
+
ListOrganizationMcpConnectionsError,
|
|
764
|
+
ListOrganizationMcpConnectionsErrors,
|
|
765
|
+
ListOrganizationMcpConnectionsResponse,
|
|
766
|
+
ListOrganizationMcpConnectionsResponses,
|
|
747
767
|
ListProjectDatabaseAccessData,
|
|
748
768
|
ListProjectDatabaseAccessError,
|
|
749
769
|
ListProjectDatabaseAccessErrors,
|
|
@@ -838,6 +858,9 @@ export type {
|
|
|
838
858
|
OrganizationAccount,
|
|
839
859
|
OrganizationCredits,
|
|
840
860
|
OrganizationCreditUsage,
|
|
861
|
+
OrganizationMcpConnection,
|
|
862
|
+
OrganizationMcpConnectionList,
|
|
863
|
+
OrganizationMcpConnectionRevocation,
|
|
841
864
|
OrganizationReferral,
|
|
842
865
|
PaidDomain,
|
|
843
866
|
PaidDomainPlan,
|
|
@@ -1004,6 +1027,11 @@ export type {
|
|
|
1004
1027
|
RevokeNativeAuthUserSessionsErrors,
|
|
1005
1028
|
RevokeNativeAuthUserSessionsResponse,
|
|
1006
1029
|
RevokeNativeAuthUserSessionsResponses,
|
|
1030
|
+
RevokeOrganizationMcpConnectionData,
|
|
1031
|
+
RevokeOrganizationMcpConnectionError,
|
|
1032
|
+
RevokeOrganizationMcpConnectionErrors,
|
|
1033
|
+
RevokeOrganizationMcpConnectionResponse,
|
|
1034
|
+
RevokeOrganizationMcpConnectionResponses,
|
|
1007
1035
|
RevokeProjectDatabaseAccessData,
|
|
1008
1036
|
RevokeProjectDatabaseAccessError,
|
|
1009
1037
|
RevokeProjectDatabaseAccessErrors,
|
|
@@ -1029,6 +1057,11 @@ export type {
|
|
|
1029
1057
|
RollbackDeploymentErrors,
|
|
1030
1058
|
RollbackDeploymentResponse,
|
|
1031
1059
|
RollbackDeploymentResponses,
|
|
1060
|
+
RotateManagedMailWebhookSecretData,
|
|
1061
|
+
RotateManagedMailWebhookSecretError,
|
|
1062
|
+
RotateManagedMailWebhookSecretErrors,
|
|
1063
|
+
RotateManagedMailWebhookSecretResponse,
|
|
1064
|
+
RotateManagedMailWebhookSecretResponses,
|
|
1032
1065
|
RotateProjectDevShareLinkData,
|
|
1033
1066
|
RotateProjectDevShareLinkError,
|
|
1034
1067
|
RotateProjectDevShareLinkErrors,
|