@amerged/ohmyhost-cli 0.1.56 → 0.1.58

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.
@@ -96,6 +96,34 @@ const deploymentProgressActions = {
96
96
  "Mail readiness could not be observed. Read 'ohmyhost mail status --project PROJECT --environment PROD_ENVIRONMENT_ULID --json' (MCP mail_status) with the Prod environment ID from 'ohmyhost project status', and report a persistent error; keep this operation.",
97
97
  } as const;
98
98
  export type DeploymentProgressPhase = keyof typeof deploymentProgressActions;
99
+ export interface DeploymentMailProgress {
100
+ readonly domain: string;
101
+ readonly status:
102
+ | "configured"
103
+ | "delegation_required"
104
+ | "ready"
105
+ | "verification_pending"
106
+ | "verification_failed";
107
+ readonly configured_at: string;
108
+ readonly observed_at?: string;
109
+ readonly verification_issue?:
110
+ | "identity_missing"
111
+ | "identity_verification_failed"
112
+ | "dkim_verification_failed"
113
+ | "dkim_records_changed"
114
+ | "tenant_association_missing"
115
+ | null;
116
+ readonly next_check_after_seconds?: 60 | 3600 | null;
117
+ readonly sending?: "disabled" | "pending" | "ready" | "failed";
118
+ readonly receiving?: "disabled" | "pending" | "ready" | "failed";
119
+ readonly dns_records: {
120
+ readonly type: "MX" | "TXT" | "CNAME";
121
+ readonly name: string;
122
+ readonly value: string;
123
+ readonly status: string;
124
+ readonly priority?: number;
125
+ }[];
126
+ }
99
127
  export interface OperationDeploymentProgress {
100
128
  readonly build_completed_at?: string;
101
129
  readonly phase: DeploymentProgressPhase;
@@ -104,6 +132,7 @@ export interface OperationDeploymentProgress {
104
132
  readonly observed_at: string;
105
133
  readonly next_poll_after_seconds: 60;
106
134
  readonly suggested_action: string;
135
+ readonly mail?: DeploymentMailProgress;
107
136
  }
108
137
  export function createOperationDeploymentProgress(input: {
109
138
  build_completed_at?: string;
@@ -111,6 +140,7 @@ export function createOperationDeploymentProgress(input: {
111
140
  project_id: string;
112
141
  deployment_id: string;
113
142
  observed_at: string;
143
+ mail?: DeploymentMailProgress;
114
144
  }): OperationDeploymentProgress {
115
145
  const project = ulid(input.project_id);
116
146
  ulid(input.deployment_id);
@@ -126,6 +156,8 @@ export function createOperationDeploymentProgress(input: {
126
156
  new Date(input.build_completed_at).toISOString() !== input.build_completed_at)
127
157
  )
128
158
  invalid();
159
+ const mail = input.mail === undefined ? undefined : parseDeploymentMailProgress(input.mail);
160
+ if (mail !== undefined && input.phase !== "waiting_for_mail") invalid();
129
161
  return Object.freeze({
130
162
  ...(input.build_completed_at === undefined
131
163
  ? {}
@@ -135,8 +167,93 @@ export function createOperationDeploymentProgress(input: {
135
167
  deployment_id: input.deployment_id,
136
168
  observed_at: input.observed_at,
137
169
  next_poll_after_seconds: 60 as const,
138
- suggested_action: deploymentProgressActions[input.phase].replace("PROJECT", project),
170
+ suggested_action:
171
+ mail === undefined || mail.dns_records.length === 0
172
+ ? deploymentProgressActions[input.phase].replace("PROJECT", project)
173
+ : "Follow the mail readiness and DNS records shown here, then poll this same operation. Do not rebuild or repeat correct DNS changes.",
174
+ ...(mail === undefined ? {} : { mail }),
175
+ });
176
+ }
177
+ function parseDeploymentMailProgress(value: unknown): DeploymentMailProgress {
178
+ if (typeof value !== "object" || value === null || Array.isArray(value)) invalid();
179
+ const raw = value as Record<string, unknown>;
180
+ const keys = ["domain", "status", "configured_at", "dns_records"];
181
+ for (const optional of [
182
+ "observed_at",
183
+ "verification_issue",
184
+ "next_check_after_seconds",
185
+ "sending",
186
+ "receiving",
187
+ ])
188
+ if (raw[optional] !== undefined) keys.push(optional);
189
+ const row = exactRecord(raw, keys),
190
+ time = (v: unknown) =>
191
+ typeof v === "string" && Number.isFinite(Date.parse(v)) && new Date(v).toISOString() === v,
192
+ state = ["disabled", "pending", "ready", "failed"];
193
+ if (
194
+ typeof row["domain"] !== "string" ||
195
+ row["domain"].length > 253 ||
196
+ !/^[a-z0-9.-]+$/u.test(row["domain"]) ||
197
+ ![
198
+ "configured",
199
+ "delegation_required",
200
+ "ready",
201
+ "verification_pending",
202
+ "verification_failed",
203
+ ].includes(String(row["status"])) ||
204
+ !time(row["configured_at"]) ||
205
+ (row["observed_at"] !== undefined && !time(row["observed_at"])) ||
206
+ (row["verification_issue"] !== undefined &&
207
+ row["verification_issue"] !== null &&
208
+ ![
209
+ "identity_missing",
210
+ "identity_verification_failed",
211
+ "dkim_verification_failed",
212
+ "dkim_records_changed",
213
+ "tenant_association_missing",
214
+ ].includes(String(row["verification_issue"]))) ||
215
+ (row["next_check_after_seconds"] !== undefined &&
216
+ ![60, 3600, null].includes(row["next_check_after_seconds"] as 60 | 3600 | null)) ||
217
+ (row["sending"] !== undefined && !state.includes(String(row["sending"]))) ||
218
+ (row["receiving"] !== undefined && !state.includes(String(row["receiving"]))) ||
219
+ !Array.isArray(row["dns_records"]) ||
220
+ row["dns_records"].length > 16
221
+ )
222
+ invalid();
223
+ const records = row["dns_records"].map((value: unknown) => {
224
+ if (typeof value !== "object" || value === null || Array.isArray(value)) invalid();
225
+ const item = value as Record<string, unknown>;
226
+ const record = exactRecord(
227
+ item,
228
+ item["priority"] === undefined
229
+ ? ["type", "name", "value", "status"]
230
+ : ["type", "name", "value", "status", "priority"],
231
+ );
232
+ if (
233
+ !["MX", "TXT", "CNAME"].includes(String(record["type"])) ||
234
+ typeof record["name"] !== "string" ||
235
+ record["name"].length === 0 ||
236
+ record["name"].length > 253 ||
237
+ /[\r\n\0]/u.test(record["name"]) ||
238
+ !(record["name"] === row["domain"] || record["name"].endsWith(`.${row["domain"]}`)) ||
239
+ typeof record["value"] !== "string" ||
240
+ record["value"].length === 0 ||
241
+ record["value"].length > 4096 ||
242
+ /[\r\n\0]/u.test(record["value"]) ||
243
+ typeof record["status"] !== "string" ||
244
+ record["status"].length === 0 ||
245
+ record["status"].length > 32 ||
246
+ /[\r\n\0]/u.test(record["status"]) ||
247
+ (record["type"] === "MX" &&
248
+ (!Number.isSafeInteger(record["priority"]) ||
249
+ Number(record["priority"]) < 0 ||
250
+ Number(record["priority"]) > 65535)) ||
251
+ (record["type"] !== "MX" && record["priority"] !== undefined)
252
+ )
253
+ invalid();
254
+ return Object.freeze({ ...record }) as DeploymentMailProgress["dns_records"][number];
139
255
  });
256
+ return Object.freeze({ ...row, dns_records: records }) as unknown as DeploymentMailProgress;
140
257
  }
141
258
  export function parseOperationDeploymentProgress(value: unknown): OperationDeploymentProgress {
142
259
  const keys = [
@@ -149,6 +266,8 @@ export function parseOperationDeploymentProgress(value: unknown): OperationDeplo
149
266
  ];
150
267
  if (typeof value === "object" && value !== null && Object.hasOwn(value, "build_completed_at"))
151
268
  keys.push("build_completed_at");
269
+ if (typeof value === "object" && value !== null && Object.hasOwn(value, "mail"))
270
+ keys.push("mail");
152
271
  const row = exactRecord(value, keys);
153
272
  const parsed = createOperationDeploymentProgress({
154
273
  ...(row["build_completed_at"] === undefined
@@ -158,6 +277,7 @@ export function parseOperationDeploymentProgress(value: unknown): OperationDeplo
158
277
  project_id: row["project_id"] as string,
159
278
  deployment_id: row["deployment_id"] as string,
160
279
  observed_at: row["observed_at"] as string,
280
+ ...(row["mail"] === undefined ? {} : { mail: parseDeploymentMailProgress(row["mail"]) }),
161
281
  });
162
282
  if (row["next_poll_after_seconds"] !== 60 || row["suggested_action"] !== parsed.suggested_action)
163
283
  invalid();
@@ -1,4 +1,8 @@
1
- import { frameworkConversionDetail } from "./framework-admission.js";
1
+ import {
2
+ frameworkConversionDetail,
3
+ parseFrameworkConversionDiagnostic,
4
+ type FrameworkConversionDiagnostic,
5
+ } from "./framework-admission.js";
2
6
 
3
7
  const failures = {
4
8
  authorization_changed: [
@@ -147,6 +151,70 @@ export interface PublicOperationFailure {
147
151
  readonly suggested_action: string;
148
152
  /** The catalog sentence naming the refused file and its fix, only for an auto-deploy rejection. */
149
153
  readonly detail?: string;
154
+ readonly migration?: MigrationFailureDiagnostic;
155
+ }
156
+
157
+ export interface MigrationFailureDiagnostic {
158
+ readonly reason: "catalog_changed" | "execution_failed" | "ledger_conflict" | "not_admitted";
159
+ readonly file: string | null;
160
+ readonly statement_index?: number;
161
+ readonly sqlstate?: string;
162
+ }
163
+ export type OperationFailureDiagnostic = FrameworkConversionDiagnostic | MigrationFailureDiagnostic;
164
+
165
+ /** Each diagnostic variant validates its exact closed shape before crossing a read boundary. */
166
+ export function parseOperationFailureDiagnostic(value: unknown): OperationFailureDiagnostic | null {
167
+ return parseFrameworkConversionDiagnostic(value) ?? parseMigrationFailureDiagnostic(value);
168
+ }
169
+
170
+ /** Closed metadata only: PostgreSQL messages, SQL and parameters are never public diagnostics. */
171
+ export function parseMigrationFailureDiagnostic(value: unknown): MigrationFailureDiagnostic | null {
172
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
173
+ const r = value as Record<string, unknown>;
174
+ if (
175
+ Object.keys(r).some(
176
+ (key) => !["reason", "file", "statement_index", "sqlstate"].includes(key),
177
+ ) ||
178
+ !["catalog_changed", "execution_failed", "ledger_conflict", "not_admitted"].includes(
179
+ String(r["reason"]),
180
+ ) ||
181
+ !(
182
+ r["file"] === null ||
183
+ (typeof r["file"] === "string" &&
184
+ r["file"].length <= 512 &&
185
+ /^(?:[A-Za-z0-9][A-Za-z0-9._-]*\/)*\d{14}_[a-z0-9][a-z0-9_-]*\.sql$/u.test(r["file"]))
186
+ )
187
+ )
188
+ return null;
189
+ const ordinal = r["statement_index"],
190
+ state = r["sqlstate"];
191
+ if (
192
+ (Object.hasOwn(r, "statement_index") && ordinal === undefined) ||
193
+ (Object.hasOwn(r, "sqlstate") && state === undefined)
194
+ )
195
+ return null;
196
+ if (
197
+ (ordinal === undefined) !== (state === undefined) ||
198
+ (ordinal !== undefined &&
199
+ (r["reason"] !== "execution_failed" ||
200
+ r["file"] === null ||
201
+ typeof ordinal !== "number" ||
202
+ !Number.isSafeInteger(ordinal) ||
203
+ ordinal < 1)) ||
204
+ (state !== undefined &&
205
+ (ordinal === undefined ||
206
+ typeof state !== "string" ||
207
+ !/^[0-9A-Z]{5}$/u.test(state) ||
208
+ state.startsWith("08") ||
209
+ /^57P0[123]$/u.test(state)))
210
+ )
211
+ return null;
212
+ return Object.freeze({
213
+ reason: r["reason"] as MigrationFailureDiagnostic["reason"],
214
+ file: r["file"] as string | null,
215
+ ...(ordinal === undefined ? {} : { statement_index: ordinal as number }),
216
+ ...(state === undefined ? {} : { sqlstate: state as string }),
217
+ });
150
218
  }
151
219
 
152
220
  export interface OperationReconciliationObservation {
@@ -198,11 +266,14 @@ export function publicOperationFailure(
198
266
  const [message, suggested_action] = failures[code];
199
267
  const detail =
200
268
  code === "auto_deploy_plan_rejected" ? frameworkConversionDetail(diagnostic) : null;
269
+ const migration =
270
+ code === "database_migration_failed" ? parseMigrationFailureDiagnostic(diagnostic) : null;
201
271
  return Object.freeze({
202
272
  code,
203
273
  message,
204
274
  retryable: false,
205
275
  suggested_action,
206
276
  ...(detail === null ? {} : { detail }),
277
+ ...(migration === null ? {} : { migration }),
207
278
  });
208
279
  }
@@ -441,9 +441,21 @@ export const PROBLEM_POLICY = {
441
441
  status: 409,
442
442
  retryable: false,
443
443
  action:
444
- "Plan and deploy this commit to Dev, then run 'ohmyhost deployment promote plan' to reach Prod.",
444
+ "This is a legacy deployment restriction. Update the CLI and MCP to the current release, then plan with environment prod. The current platform permits direct Prod deployment with shared data; its migrations affect both environments when Dev exists. If the restriction persists, report the request ID.",
445
445
  title: "Shared data requires promotion",
446
446
  },
447
+ development_environment_exists: {
448
+ status: 409,
449
+ retryable: false,
450
+ action: "Read project status and use the existing Dev environment ID.",
451
+ title: "Development environment already exists",
452
+ },
453
+ development_environment_missing: {
454
+ status: 409,
455
+ retryable: false,
456
+ action: "Select environment prod, or add Dev with 'ohmyhost project dev add'.",
457
+ title: "Development environment is missing",
458
+ },
447
459
  production_deployment_required: {
448
460
  status: 409,
449
461
  retryable: false,
@@ -10,16 +10,17 @@ const FIXED_PLATFORM_NAMES = new Set([
10
10
  "IMAGES",
11
11
  "STORAGE",
12
12
  ]);
13
- /** The four keys the platform installs; control-store's rotation accepts exactly these names. */
13
+ /** The five keys the platform installs; control-store's rotation accepts exactly these names. */
14
14
  export const INSTALLED_PLATFORM_KEY_NAMES = [
15
15
  "OHMYHOST_STORAGE_KEY",
16
16
  "OHMYHOST_MAIL_KEY",
17
17
  "OHMYHOST_AI_KEY",
18
+ "OHMYHOST_BROWSER_KEY",
18
19
  "BETTER_AUTH_SECRET",
19
20
  ] as const;
20
21
  const INSTALLED_PLATFORM_KEYS = new Set<string>(INSTALLED_PLATFORM_KEY_NAMES);
21
22
 
22
- /** The four keys the platform installs. An owner may rotate them; a customer may never set or delete them. */
23
+ /** The five keys the platform installs. An owner may rotate them; a customer may never set or delete them. */
23
24
  export function isInstalledPlatformKeyName(value: unknown): value is string {
24
25
  return typeof value === "string" && INSTALLED_PLATFORM_KEYS.has(value);
25
26
  }
@@ -0,0 +1,15 @@
1
+ /** Bounded, explicit campaign parameters carried through the first account signup. */
2
+ export function isSignupUtm(value: unknown): value is Record<string, string> {
3
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
4
+ const entries = Object.entries(value);
5
+ return (
6
+ entries.length <= 20 &&
7
+ entries.every(
8
+ ([key, item]) =>
9
+ /^utm_[a-z0-9_]{1,60}$/u.test(key) &&
10
+ typeof item === "string" &&
11
+ Array.from(item).length <= 256,
12
+ ) &&
13
+ new TextEncoder().encode(JSON.stringify(value)).byteLength <= 1024
14
+ );
15
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohmyhost/sdk-ts",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,8 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
 
3
3
  export {
4
+ activateDatabaseWebhookSubscription,
5
+ addProjectDevelopmentEnvironment,
4
6
  applyPaidProjectDomain,
5
7
  authorizeApplicationDomainIdentityDns,
6
8
  authorizeWorkspaceMailDomainDns,
@@ -33,6 +35,7 @@ export {
33
35
  createProjectExportDownloadLink,
34
36
  createUserApiKey,
35
37
  createWorkspaceMailDomain,
38
+ deactivateDatabaseWebhookSubscription,
36
39
  declareApplicationDomainIdentity,
37
40
  deleteEnvironmentSecret,
38
41
  deleteManagedMailDomain,
@@ -55,6 +58,7 @@ export {
55
58
  getCloudflareDnsAuthorizationStatus,
56
59
  getCurrentIdentity,
57
60
  getDatabaseCompute,
61
+ getDatabaseWebhookSubscription,
58
62
  getDeployment,
59
63
  getDeploymentLogs,
60
64
  getFeatureInterests,
@@ -165,6 +169,16 @@ export {
165
169
  } from "./sdk.gen.js";
166
170
  export type {
167
171
  AccountProfile,
172
+ ActivateDatabaseWebhookSubscriptionData,
173
+ ActivateDatabaseWebhookSubscriptionError,
174
+ ActivateDatabaseWebhookSubscriptionErrors,
175
+ ActivateDatabaseWebhookSubscriptionResponse,
176
+ ActivateDatabaseWebhookSubscriptionResponses,
177
+ AddProjectDevelopmentEnvironmentData,
178
+ AddProjectDevelopmentEnvironmentError,
179
+ AddProjectDevelopmentEnvironmentErrors,
180
+ AddProjectDevelopmentEnvironmentResponse,
181
+ AddProjectDevelopmentEnvironmentResponses,
168
182
  ApplicationDomainIdentity,
169
183
  ApplicationDomainIdentityRequest,
170
184
  ApplicationDomainIdentitySummary,
@@ -388,10 +402,19 @@ export type {
388
402
  DatabaseWebhookEventPattern,
389
403
  DatabaseWebhookEventPatternWritable,
390
404
  DatabaseWebhookEventType,
405
+ DatabaseWebhookGeneration,
391
406
  DatabaseWebhookId,
392
407
  DatabaseWebhookPage,
393
408
  DatabaseWebhookReplayAccepted,
409
+ DatabaseWebhookSubscription,
410
+ DatabaseWebhookSubscriptionActivation,
411
+ DatabaseWebhookSubscriptionId,
394
412
  DatabaseWebhookTestResult,
413
+ DeactivateDatabaseWebhookSubscriptionData,
414
+ DeactivateDatabaseWebhookSubscriptionError,
415
+ DeactivateDatabaseWebhookSubscriptionErrors,
416
+ DeactivateDatabaseWebhookSubscriptionResponse,
417
+ DeactivateDatabaseWebhookSubscriptionResponses,
395
418
  DeclareApplicationDomainIdentityData,
396
419
  DeclareApplicationDomainIdentityError,
397
420
  DeclareApplicationDomainIdentityErrors,
@@ -444,6 +467,7 @@ export type {
444
467
  DeploymentDiagnosticPage,
445
468
  DeploymentId,
446
469
  DeploymentLimit,
470
+ DeploymentMailProgress,
447
471
  DeploymentPage,
448
472
  DeploymentPlan,
449
473
  DeploymentPlanWritable,
@@ -527,6 +551,11 @@ export type {
527
551
  GetDatabaseComputeErrors,
528
552
  GetDatabaseComputeResponse,
529
553
  GetDatabaseComputeResponses,
554
+ GetDatabaseWebhookSubscriptionData,
555
+ GetDatabaseWebhookSubscriptionError,
556
+ GetDatabaseWebhookSubscriptionErrors,
557
+ GetDatabaseWebhookSubscriptionResponse,
558
+ GetDatabaseWebhookSubscriptionResponses,
530
559
  GetDeploymentData,
531
560
  GetDeploymentError,
532
561
  GetDeploymentErrors,
@@ -838,6 +867,7 @@ export type {
838
867
  ManagedSourceUploadReceipt,
839
868
  ManagedSourceUploadRequest,
840
869
  ManagedSourceVersions,
870
+ MigrationFailureDiagnostic,
841
871
  NativeAuthConfiguration,
842
872
  NativeAuthConfigurationUpdate,
843
873
  NativeAuthProviderStatus,