@amerged/ohmyhost-cli 0.1.62 → 0.1.64

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @amerged/ohmyhost-cli
2
2
 
3
- ohmyho.st cli client, version 0.1.62.
3
+ ohmyho.st cli client, version 0.1.64.
4
4
 
5
5
  ```sh
6
6
  npm install --global @amerged/ohmyhost-cli
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __ohmyhostCreateRequire } from "node:module"; const require = __ohmyhostCreateRequire(import.meta.url);
3
3
  import {
4
4
  runProductionCli
5
- } from "./chunk-WER7CYZD.js";
5
+ } from "./chunk-RW66TG5O.js";
6
6
  import "./chunk-7D2RFLWM.js";
7
7
 
8
8
  // apps/product-cli/dist/bin.js
@@ -43613,7 +43613,7 @@ var recognizedCommandLabel = (argv) => {
43613
43613
  return value;
43614
43614
  if (value === "profile" && values[0] === "list")
43615
43615
  return "profile list";
43616
- if (value === "connection" && ["begin", "list", "status", "discover", "disconnect"].includes(values[0] ?? ""))
43616
+ if (value === "connection" && ["begin", "list", "status", "discover", "import", "disconnect"].includes(values[0] ?? ""))
43617
43617
  return `connection ${values[0]}`;
43618
43618
  if (value === "github" && values[0] === "connect")
43619
43619
  return "github connect";
@@ -44412,7 +44412,8 @@ var parseProductCliCommand = (argv) => {
44412
44412
  "--request",
44413
44413
  "--idempotency-key",
44414
44414
  "--provider-organization",
44415
- "--team"
44415
+ "--team",
44416
+ "--connection"
44416
44417
  ]);
44417
44418
  const org = options["--organization"];
44418
44419
  if (!org || !ORGANIZATION_ULID.test(org))
@@ -44421,12 +44422,11 @@ var parseProductCliCommand = (argv) => {
44421
44422
  const scoped = () => options["--project"] && options["--environment"] && ORGANIZATION_ULID.test(options["--project"]) && ORGANIZATION_ULID.test(options["--environment"]);
44422
44423
  if (operation === "list" && exact7(["--organization"]))
44423
44424
  return { kind: "connection-list", organizationId: org, credentialStore };
44424
- if (operation === "begin" && scoped() && exact7(["--organization", "--project", "--environment", "--idempotency-key"]))
44425
+ if (operation === "begin" && (exact7(["--organization", "--idempotency-key"]) || scoped() && exact7(["--organization", "--project", "--environment", "--idempotency-key"])))
44425
44426
  return {
44426
44427
  kind: "connection-begin",
44427
44428
  organizationId: org,
44428
- projectId: options["--project"] ?? "",
44429
- environmentId: options["--environment"] ?? "",
44429
+ ...options["--project"] ? { projectId: options["--project"], environmentId: options["--environment"] } : {},
44430
44430
  idempotencyKey: options["--idempotency-key"] ?? "",
44431
44431
  credentialStore
44432
44432
  };
@@ -44446,7 +44446,34 @@ var parseProductCliCommand = (argv) => {
44446
44446
  yes: true,
44447
44447
  credentialStore
44448
44448
  };
44449
- if (operation === "discover" && scoped() && ORGANIZATION_ULID.test(options["--grant"] ?? "") && Object.keys(options).every((k) => [
44449
+ if (operation === "import" && scoped() && ORGANIZATION_ULID.test(options["--grant"] ?? "") && exact7([
44450
+ "--organization",
44451
+ "--project",
44452
+ "--environment",
44453
+ "--grant",
44454
+ "--provider-organization",
44455
+ "--team",
44456
+ "--connection",
44457
+ "--idempotency-key"
44458
+ ])) {
44459
+ const projectId = options["--project"], environmentId = options["--environment"], grantId = options["--grant"], idempotencyKey = options["--idempotency-key"];
44460
+ const providerOrganizationId = Number(options["--provider-organization"]), teamId = Number(options["--team"]), connectionId = Number(options["--connection"]);
44461
+ if (!projectId || !environmentId || !grantId || !idempotencyKey || [providerOrganizationId, teamId, connectionId].some((n) => !Number.isSafeInteger(n) || n < 1))
44462
+ throw new InvalidCommandError();
44463
+ return {
44464
+ kind: "connection-import",
44465
+ organizationId: org,
44466
+ projectId,
44467
+ environmentId,
44468
+ grantId,
44469
+ providerOrganizationId,
44470
+ teamId,
44471
+ connectionId,
44472
+ idempotencyKey,
44473
+ credentialStore
44474
+ };
44475
+ }
44476
+ if (operation === "discover" && (!options["--project"] && !options["--environment"] || scoped()) && ORGANIZATION_ULID.test(options["--grant"] ?? "") && Object.keys(options).every((k) => [
44450
44477
  "--organization",
44451
44478
  "--project",
44452
44479
  "--environment",
@@ -44461,8 +44488,7 @@ var parseProductCliCommand = (argv) => {
44461
44488
  return {
44462
44489
  kind: "connection-discover",
44463
44490
  organizationId: org,
44464
- projectId: options["--project"] ?? "",
44465
- environmentId: options["--environment"] ?? "",
44491
+ ...options["--project"] ? { projectId: options["--project"], environmentId: options["--environment"] } : {},
44466
44492
  grantId: options["--grant"] ?? "",
44467
44493
  ...providerOrganizationId ? { providerOrganizationId } : {},
44468
44494
  ...teamId ? { teamId } : {},
@@ -46494,7 +46520,7 @@ function exact4(v, keys) {
46494
46520
  // apps/product-cli/package.json
46495
46521
  var package_default = {
46496
46522
  name: "@ohmyhost/product-cli",
46497
- version: "0.1.62",
46523
+ version: "0.1.64",
46498
46524
  private: true,
46499
46525
  ohmyhost: {
46500
46526
  deployment: "production",
@@ -46809,10 +46835,11 @@ var HELP_USAGE = Object.freeze({
46809
46835
  logout: "ohmyhost logout [--profile-name NAME] [--revoke] --json (removes only the selected saved login)",
46810
46836
  whoami: "ohmyhost whoami [--profile-name NAME] --json (the effective user, organization and saved login)",
46811
46837
  "profile list": "ohmyhost profile list --json (saved logins on this computer: name, user and organization, never a token; pass --profile-name NAME or set OHMYHOST_PROFILE to choose one)",
46812
- "connection begin": "ohmyhost connection begin --organization ULID --project ULID --environment ULID --idempotency-key KEY --json",
46838
+ "connection begin": "ohmyhost connection begin --organization ULID [--project ULID --environment ULID] --idempotency-key KEY --json",
46813
46839
  "connection list": "ohmyhost connection list --organization ULID --json",
46814
46840
  "connection status": "ohmyhost connection status --organization ULID --request HASH --json",
46815
- "connection discover": "ohmyhost connection discover --organization ULID --project ULID --environment ULID --grant ULID [--provider-organization ID] [--team ID] --json",
46841
+ "connection discover": "ohmyhost connection discover --organization ULID [--project ULID --environment ULID] --grant ULID [--provider-organization ID] [--team ID] --json",
46842
+ "connection import": "ohmyhost connection import --organization ULID --grant ULID --project ULID --environment ULID --provider-organization ID --team ID --connection ID --idempotency-key KEY --json",
46816
46843
  "connection disconnect": "ohmyhost connection disconnect --organization ULID --grant ULID --idempotency-key KEY --yes --json",
46817
46844
  "github connect": "ohmyhost github connect --organization ULID --idempotency-key KEY --json (connect once, then link covered repositories without another browser consent)",
46818
46845
  "github status": "ohmyhost github status --organization ULID --json",
@@ -47113,7 +47140,7 @@ var ProductCli = class {
47113
47140
  ...github.status === "connected" ? {} : { next_action: this.githubConnectAction(command.organizationId) }
47114
47141
  });
47115
47142
  }
47116
- if (command.kind === "connection-begin" || command.kind === "connection-list" || command.kind === "connection-status" || command.kind === "connection-discover" || command.kind === "connection-disconnect") {
47143
+ if (command.kind === "connection-begin" || command.kind === "connection-list" || command.kind === "connection-status" || command.kind === "connection-discover" || command.kind === "connection-import" || command.kind === "connection-disconnect") {
47117
47144
  const api = await this.authenticatedApi(command.credentialStore, signal);
47118
47145
  if (!api.connection)
47119
47146
  throw new ResponseContractError();
@@ -49146,6 +49173,8 @@ var parsedCommandName = (command) => {
49146
49173
  return "connection status";
49147
49174
  if (command.kind === "connection-discover")
49148
49175
  return "connection discover";
49176
+ if (command.kind === "connection-import")
49177
+ return "connection import";
49149
49178
  if (command.kind === "connection-disconnect")
49150
49179
  return "connection disconnect";
49151
49180
  if (command.kind === "organization-mcp-connections-list")
@@ -50306,7 +50335,8 @@ var listConnections = (parameters, options) => {
50306
50335
  {
50307
50336
  args: [
50308
50337
  { in: "headers", key: "X-Request-Id" },
50309
- { in: "path", key: "organization_id" }
50338
+ { in: "path", key: "organization_id" },
50339
+ { in: "query", key: "scope" }
50310
50340
  ]
50311
50341
  }
50312
50342
  ]);
@@ -50382,6 +50412,31 @@ var discoverConnection = (parameters, options) => {
50382
50412
  ...params
50383
50413
  });
50384
50414
  };
50415
+ var importConnection = (parameters, options) => {
50416
+ const params = buildClientParams([parameters], [
50417
+ {
50418
+ args: [
50419
+ { in: "headers", key: "X-Request-Id" },
50420
+ { in: "headers", key: "Idempotency-Key" },
50421
+ { in: "path", key: "organization_id" },
50422
+ { in: "path", key: "grant_id" },
50423
+ { key: "connectionImportRequest", map: "body" }
50424
+ ]
50425
+ }
50426
+ ]);
50427
+ return (options?.client ?? client).post({
50428
+ responseStyle: "data",
50429
+ security: [{ scheme: "bearer", type: "http" }],
50430
+ url: "/v1/organizations/{organization_id}/connections/{grant_id}/imports",
50431
+ ...options,
50432
+ ...params,
50433
+ headers: {
50434
+ "Content-Type": "application/json",
50435
+ ...options?.headers,
50436
+ ...params.headers
50437
+ }
50438
+ });
50439
+ };
50385
50440
  var disconnectConnection = (parameters, options) => {
50386
50441
  const params = buildClientParams([parameters], [
50387
50442
  {
@@ -54293,6 +54348,22 @@ function parseConnectionResponse(kind, raw, expectedOrigin) {
54293
54348
  const v = record8(raw, ["state"]);
54294
54349
  if (!["disconnected", "revocation_pending"].includes(String(v["state"])))
54295
54350
  throw new TypeError("Invalid connection response");
54351
+ } else if (kind === "connection-import") {
54352
+ const v = record8(raw, [
54353
+ "id",
54354
+ "grant_id",
54355
+ "project_id",
54356
+ "environment_id",
54357
+ "provider_organization_id",
54358
+ "team_id",
54359
+ "connection_id"
54360
+ ]);
54361
+ for (const key of ["id", "grant_id", "project_id", "environment_id"])
54362
+ if (typeof v[key] !== "string" || !ulid5.test(v[key]))
54363
+ throw new TypeError("Invalid connection response");
54364
+ for (const key of ["provider_organization_id", "team_id", "connection_id"])
54365
+ if (!Number.isSafeInteger(v[key]) || Number(v[key]) < 1)
54366
+ throw new TypeError("Invalid connection response");
54296
54367
  } else if (kind === "connection-discover") {
54297
54368
  const v = record8(raw, ["organizations", "teams", "connections"]);
54298
54369
  items(v["organizations"]);
@@ -55126,6 +55197,8 @@ function hasExactKeys(value, keys) {
55126
55197
  }
55127
55198
  async function executeConnectionCommand(client2, origin, command) {
55128
55199
  const organization_id = command.organizationId;
55200
+ if ((command.kind === "connection-begin" || command.kind === "connection-discover") && command.projectId === void 0 !== (command.environmentId === void 0))
55201
+ throw new TypeError("Invalid connection scope");
55129
55202
  let result;
55130
55203
  switch (command.kind) {
55131
55204
  case "connection-begin":
@@ -55134,13 +55207,12 @@ async function executeConnectionCommand(client2, origin, command) {
55134
55207
  "Idempotency-Key": command.idempotencyKey,
55135
55208
  connectionBegin: {
55136
55209
  provider: "make",
55137
- project_id: command.projectId,
55138
- environment_id: command.environmentId
55210
+ ...command.projectId ? { project_id: command.projectId, environment_id: command.environmentId } : {}
55139
55211
  }
55140
55212
  }, { client: client2 });
55141
55213
  break;
55142
55214
  case "connection-list":
55143
- result = await listConnections({ organization_id }, { client: client2 });
55215
+ result = await listConnections({ organization_id, scope: "workspace" }, { client: client2 });
55144
55216
  break;
55145
55217
  case "connection-status":
55146
55218
  result = await getConnectionRequest({ organization_id, request_id: command.requestId }, { client: client2 });
@@ -55149,12 +55221,25 @@ async function executeConnectionCommand(client2, origin, command) {
55149
55221
  result = await discoverConnection({
55150
55222
  organization_id,
55151
55223
  grant_id: command.grantId,
55152
- project_id: command.projectId,
55153
- environment_id: command.environmentId,
55224
+ ...command.projectId ? { project_id: command.projectId, environment_id: command.environmentId } : {},
55154
55225
  ...command.providerOrganizationId === void 0 ? {} : { provider_organization_id: command.providerOrganizationId },
55155
55226
  ...command.teamId === void 0 ? {} : { team_id: command.teamId }
55156
55227
  }, { client: client2 });
55157
55228
  break;
55229
+ case "connection-import":
55230
+ result = await importConnection({
55231
+ organization_id,
55232
+ grant_id: command.grantId,
55233
+ "Idempotency-Key": command.idempotencyKey,
55234
+ connectionImportRequest: {
55235
+ project_id: command.projectId,
55236
+ environment_id: command.environmentId,
55237
+ provider_organization_id: command.providerOrganizationId,
55238
+ team_id: command.teamId,
55239
+ connection_id: command.connectionId
55240
+ }
55241
+ }, { client: client2 });
55242
+ break;
55158
55243
  case "connection-disconnect":
55159
55244
  result = await disconnectConnection({ organization_id, grant_id: command.grantId, "Idempotency-Key": command.idempotencyKey }, { client: client2 });
55160
55245
  break;
package/dist/index.js CHANGED
@@ -107,7 +107,7 @@ import {
107
107
  selectWorkspace,
108
108
  verifiedUserId,
109
109
  workspaceOf
110
- } from "./chunk-WER7CYZD.js";
110
+ } from "./chunk-RW66TG5O.js";
111
111
  import {
112
112
  CredentialStoreIntegrityError,
113
113
  CredentialStoreUnavailableError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amerged/ohmyhost-cli",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohmyhost/product-cli",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "private": true,
5
5
  "ohmyhost": {
6
6
  "deployment": "production",
@@ -359,11 +359,13 @@ const HELP_USAGE = Object.freeze({
359
359
  "profile list":
360
360
  "ohmyhost profile list --json (saved logins on this computer: name, user and organization, never a token; pass --profile-name NAME or set OHMYHOST_PROFILE to choose one)",
361
361
  "connection begin":
362
- "ohmyhost connection begin --organization ULID --project ULID --environment ULID --idempotency-key KEY --json",
362
+ "ohmyhost connection begin --organization ULID [--project ULID --environment ULID] --idempotency-key KEY --json",
363
363
  "connection list": "ohmyhost connection list --organization ULID --json",
364
364
  "connection status": "ohmyhost connection status --organization ULID --request HASH --json",
365
365
  "connection discover":
366
- "ohmyhost connection discover --organization ULID --project ULID --environment ULID --grant ULID [--provider-organization ID] [--team ID] --json",
366
+ "ohmyhost connection discover --organization ULID [--project ULID --environment ULID] --grant ULID [--provider-organization ID] [--team ID] --json",
367
+ "connection import":
368
+ "ohmyhost connection import --organization ULID --grant ULID --project ULID --environment ULID --provider-organization ID --team ID --connection ID --idempotency-key KEY --json",
367
369
  "connection disconnect":
368
370
  "ohmyhost connection disconnect --organization ULID --grant ULID --idempotency-key KEY --yes --json",
369
371
  "github connect":
@@ -924,6 +926,7 @@ export class ProductCli {
924
926
  command.kind === "connection-list" ||
925
927
  command.kind === "connection-status" ||
926
928
  command.kind === "connection-discover" ||
929
+ command.kind === "connection-import" ||
927
930
  command.kind === "connection-disconnect"
928
931
  ) {
929
932
  const api = await this.authenticatedApi(command.credentialStore, signal);
@@ -3945,6 +3948,7 @@ const parsedCommandName = (command: ProductCliCommand): CommandLabel => {
3945
3948
  if (command.kind === "connection-list") return "connection list";
3946
3949
  if (command.kind === "connection-status") return "connection status";
3947
3950
  if (command.kind === "connection-discover") return "connection discover";
3951
+ if (command.kind === "connection-import") return "connection import";
3948
3952
  if (command.kind === "connection-disconnect") return "connection disconnect";
3949
3953
  if (command.kind === "organization-mcp-connections-list")
3950
3954
  return "organization mcp-connections list";
@@ -134,8 +134,8 @@ export type ProductCliCommand =
134
134
  | {
135
135
  readonly kind: "connection-begin";
136
136
  readonly organizationId: string;
137
- readonly projectId: string;
138
- readonly environmentId: string;
137
+ readonly projectId?: string;
138
+ readonly environmentId?: string;
139
139
  readonly idempotencyKey: string;
140
140
  readonly credentialStore: "native";
141
141
  }
@@ -153,13 +153,25 @@ export type ProductCliCommand =
153
153
  | {
154
154
  readonly kind: "connection-discover";
155
155
  readonly organizationId: string;
156
- readonly projectId: string;
157
- readonly environmentId: string;
156
+ readonly projectId?: string;
157
+ readonly environmentId?: string;
158
158
  readonly grantId: string;
159
159
  readonly providerOrganizationId?: number;
160
160
  readonly teamId?: number;
161
161
  readonly credentialStore: "native";
162
162
  }
163
+ | {
164
+ readonly kind: "connection-import";
165
+ readonly organizationId: string;
166
+ readonly projectId: string;
167
+ readonly environmentId: string;
168
+ readonly grantId: string;
169
+ readonly providerOrganizationId: number;
170
+ readonly teamId: number;
171
+ readonly connectionId: number;
172
+ readonly idempotencyKey: string;
173
+ readonly credentialStore: "native";
174
+ }
163
175
  | {
164
176
  readonly kind: "connection-disconnect";
165
177
  readonly organizationId: string;
@@ -1176,6 +1188,7 @@ export type RecognizedCommandLabel =
1176
1188
  | "connection list"
1177
1189
  | "connection status"
1178
1190
  | "connection discover"
1191
+ | "connection import"
1179
1192
  | "connection disconnect"
1180
1193
  | "github connect"
1181
1194
  | "github status"
@@ -1313,7 +1326,7 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
1313
1326
  if (value === "profile" && values[0] === "list") return "profile list";
1314
1327
  if (
1315
1328
  value === "connection" &&
1316
- ["begin", "list", "status", "discover", "disconnect"].includes(values[0] ?? "")
1329
+ ["begin", "list", "status", "discover", "import", "disconnect"].includes(values[0] ?? "")
1317
1330
  )
1318
1331
  return `connection ${values[0]}` as RecognizedCommandLabel;
1319
1332
  if (value === "github" && values[0] === "connect") return "github connect";
@@ -2166,6 +2179,7 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
2166
2179
  "--idempotency-key",
2167
2180
  "--provider-organization",
2168
2181
  "--team",
2182
+ "--connection",
2169
2183
  ] as const);
2170
2184
  const org = options["--organization"];
2171
2185
  if (!org || !ORGANIZATION_ULID.test(org)) throw new InvalidCommandError();
@@ -2181,14 +2195,15 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
2181
2195
  return { kind: "connection-list", organizationId: org, credentialStore };
2182
2196
  if (
2183
2197
  operation === "begin" &&
2184
- scoped() &&
2185
- exact(["--organization", "--project", "--environment", "--idempotency-key"])
2198
+ (exact(["--organization", "--idempotency-key"]) ||
2199
+ (scoped() && exact(["--organization", "--project", "--environment", "--idempotency-key"])))
2186
2200
  )
2187
2201
  return {
2188
2202
  kind: "connection-begin",
2189
2203
  organizationId: org,
2190
- projectId: options["--project"] ?? "",
2191
- environmentId: options["--environment"] ?? "",
2204
+ ...(options["--project"]
2205
+ ? { projectId: options["--project"], environmentId: options["--environment"] }
2206
+ : {}),
2192
2207
  idempotencyKey: options["--idempotency-key"] ?? "",
2193
2208
  credentialStore,
2194
2209
  };
@@ -2217,9 +2232,54 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
2217
2232
  credentialStore,
2218
2233
  };
2219
2234
  if (
2220
- operation === "discover" &&
2235
+ operation === "import" &&
2221
2236
  scoped() &&
2222
2237
  ORGANIZATION_ULID.test(options["--grant"] ?? "") &&
2238
+ exact([
2239
+ "--organization",
2240
+ "--project",
2241
+ "--environment",
2242
+ "--grant",
2243
+ "--provider-organization",
2244
+ "--team",
2245
+ "--connection",
2246
+ "--idempotency-key",
2247
+ ])
2248
+ ) {
2249
+ const projectId = options["--project"],
2250
+ environmentId = options["--environment"],
2251
+ grantId = options["--grant"],
2252
+ idempotencyKey = options["--idempotency-key"];
2253
+ const providerOrganizationId = Number(options["--provider-organization"]),
2254
+ teamId = Number(options["--team"]),
2255
+ connectionId = Number(options["--connection"]);
2256
+ if (
2257
+ !projectId ||
2258
+ !environmentId ||
2259
+ !grantId ||
2260
+ !idempotencyKey ||
2261
+ [providerOrganizationId, teamId, connectionId].some(
2262
+ (n) => !Number.isSafeInteger(n) || n < 1,
2263
+ )
2264
+ )
2265
+ throw new InvalidCommandError();
2266
+ return {
2267
+ kind: "connection-import",
2268
+ organizationId: org,
2269
+ projectId,
2270
+ environmentId,
2271
+ grantId,
2272
+ providerOrganizationId,
2273
+ teamId,
2274
+ connectionId,
2275
+ idempotencyKey,
2276
+ credentialStore,
2277
+ };
2278
+ }
2279
+ if (
2280
+ operation === "discover" &&
2281
+ ((!options["--project"] && !options["--environment"]) || scoped()) &&
2282
+ ORGANIZATION_ULID.test(options["--grant"] ?? "") &&
2223
2283
  Object.keys(options).every((k) =>
2224
2284
  [
2225
2285
  "--organization",
@@ -2245,8 +2305,9 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
2245
2305
  return {
2246
2306
  kind: "connection-discover",
2247
2307
  organizationId: org,
2248
- projectId: options["--project"] ?? "",
2249
- environmentId: options["--environment"] ?? "",
2308
+ ...(options["--project"]
2309
+ ? { projectId: options["--project"], environmentId: options["--environment"] }
2310
+ : {}),
2250
2311
  grantId: options["--grant"] ?? "",
2251
2312
  ...(providerOrganizationId ? { providerOrganizationId } : {}),
2252
2313
  ...(teamId ? { teamId } : {}),
@@ -1,6 +1,7 @@
1
1
  import { parseConnectionResponse } from "@ohmyhost/contracts/connection-management";
2
2
  import {
3
3
  beginConnection,
4
+ importConnection,
4
5
  listConnections,
5
6
  getConnectionRequest,
6
7
  discoverConnection,
@@ -307,7 +308,8 @@ export type ConnectionCommand = Extract<
307
308
  | "connection-list"
308
309
  | "connection-status"
309
310
  | "connection-discover"
310
- | "connection-disconnect";
311
+ | "connection-disconnect"
312
+ | "connection-import";
311
313
  }
312
314
  >;
313
315
  export interface ProductApi {
@@ -789,6 +791,11 @@ export async function executeConnectionCommand(
789
791
  command: ConnectionCommand,
790
792
  ): Promise<unknown> {
791
793
  const organization_id = command.organizationId;
794
+ if (
795
+ (command.kind === "connection-begin" || command.kind === "connection-discover") &&
796
+ (command.projectId === undefined) !== (command.environmentId === undefined)
797
+ )
798
+ throw new TypeError("Invalid connection scope");
792
799
  let result: unknown;
793
800
  switch (command.kind) {
794
801
  case "connection-begin":
@@ -798,15 +805,16 @@ export async function executeConnectionCommand(
798
805
  "Idempotency-Key": command.idempotencyKey,
799
806
  connectionBegin: {
800
807
  provider: "make",
801
- project_id: command.projectId,
802
- environment_id: command.environmentId,
808
+ ...(command.projectId
809
+ ? { project_id: command.projectId, environment_id: command.environmentId }
810
+ : {}),
803
811
  },
804
812
  },
805
813
  { client: client },
806
814
  );
807
815
  break;
808
816
  case "connection-list":
809
- result = await listConnections({ organization_id }, { client: client });
817
+ result = await listConnections({ organization_id, scope: "workspace" }, { client: client });
810
818
  break;
811
819
  case "connection-status":
812
820
  result = await getConnectionRequest(
@@ -819,8 +827,9 @@ export async function executeConnectionCommand(
819
827
  {
820
828
  organization_id,
821
829
  grant_id: command.grantId,
822
- project_id: command.projectId,
823
- environment_id: command.environmentId,
830
+ ...(command.projectId
831
+ ? { project_id: command.projectId, environment_id: command.environmentId }
832
+ : {}),
824
833
  ...(command.providerOrganizationId === undefined
825
834
  ? {}
826
835
  : { provider_organization_id: command.providerOrganizationId }),
@@ -829,6 +838,23 @@ export async function executeConnectionCommand(
829
838
  { client: client },
830
839
  );
831
840
  break;
841
+ case "connection-import":
842
+ result = await importConnection(
843
+ {
844
+ organization_id,
845
+ grant_id: command.grantId,
846
+ "Idempotency-Key": command.idempotencyKey,
847
+ connectionImportRequest: {
848
+ project_id: command.projectId,
849
+ environment_id: command.environmentId,
850
+ provider_organization_id: command.providerOrganizationId,
851
+ team_id: command.teamId,
852
+ connection_id: command.connectionId,
853
+ },
854
+ },
855
+ { client },
856
+ );
857
+ break;
832
858
  case "connection-disconnect":
833
859
  result = await disconnectConnection(
834
860
  { organization_id, grant_id: command.grantId, "Idempotency-Key": command.idempotencyKey },
@@ -31,7 +31,8 @@ export function parseConnectionResponse(
31
31
  | "connection-list"
32
32
  | "connection-status"
33
33
  | "connection-discover"
34
- | "connection-disconnect",
34
+ | "connection-disconnect"
35
+ | "connection-import",
35
36
  raw: unknown,
36
37
  expectedOrigin?: string,
37
38
  ): unknown {
@@ -63,6 +64,22 @@ export function parseConnectionResponse(
63
64
  const v = record(raw, ["state"]);
64
65
  if (!["disconnected", "revocation_pending"].includes(String(v["state"])))
65
66
  throw new TypeError("Invalid connection response");
67
+ } else if (kind === "connection-import") {
68
+ const v = record(raw, [
69
+ "id",
70
+ "grant_id",
71
+ "project_id",
72
+ "environment_id",
73
+ "provider_organization_id",
74
+ "team_id",
75
+ "connection_id",
76
+ ]);
77
+ for (const key of ["id", "grant_id", "project_id", "environment_id"])
78
+ if (typeof v[key] !== "string" || !ulid.test(v[key] as string))
79
+ throw new TypeError("Invalid connection response");
80
+ for (const key of ["provider_organization_id", "team_id", "connection_id"])
81
+ if (!Number.isSafeInteger(v[key]) || Number(v[key]) < 1)
82
+ throw new TypeError("Invalid connection response");
66
83
  } else if (kind === "connection-discover") {
67
84
  const v = record(raw, ["organizations", "teams", "connections"]);
68
85
  items(v["organizations"]);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohmyhost/sdk-ts",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -98,6 +98,7 @@ export {
98
98
  getPublicDeploymentStats,
99
99
  getWorkspaceMailDomain,
100
100
  getWorkspaceMailDomainDnsAuthorization,
101
+ importConnection,
101
102
  initializeManagedSource,
102
103
  linkProjectSource,
103
104
  listAuditEvents,
@@ -289,6 +290,8 @@ export type {
289
290
  ConnectionGrant,
290
291
  ConnectionGrantList,
291
292
  ConnectionHandoff,
293
+ ConnectionImport,
294
+ ConnectionImportRequest,
292
295
  ConnectionProviders,
293
296
  ConnectionRequestStatus,
294
297
  CostEstimate,
@@ -782,6 +785,11 @@ export type {
782
785
  IdempotencyConflictProblem,
783
786
  IdempotencyKey,
784
787
  IfMatch,
788
+ ImportConnectionData,
789
+ ImportConnectionError,
790
+ ImportConnectionErrors,
791
+ ImportConnectionResponse,
792
+ ImportConnectionResponses,
785
793
  InitializeManagedSourceData,
786
794
  InitializeManagedSourceError,
787
795
  InitializeManagedSourceErrors,
@@ -50,6 +50,7 @@ import type {
50
50
  ConnectGithubOrganizationRequest,
51
51
  ConnectGithubOrganizationResponses,
52
52
  ConnectionBegin,
53
+ ConnectionImportRequest,
53
54
  CreateBillingCheckoutErrors,
54
55
  CreateBillingCheckoutResponses,
55
56
  CreateBillingPortalErrors,
@@ -220,6 +221,8 @@ import type {
220
221
  GetWorkspaceMailDomainDnsAuthorizationResponses,
221
222
  GetWorkspaceMailDomainErrors,
222
223
  GetWorkspaceMailDomainResponses,
224
+ ImportConnectionErrors,
225
+ ImportConnectionResponses,
223
226
  InitializeManagedSourceErrors,
224
227
  InitializeManagedSourceResponses,
225
228
  LinkProjectSourceErrors,
@@ -597,6 +600,7 @@ export const listConnections = <ThrowOnError extends boolean = true>(
597
600
  parameters: {
598
601
  "X-Request-Id"?: string;
599
602
  organization_id: Ulid;
603
+ scope?: "workspace";
600
604
  },
601
605
  options?: Options<never, ThrowOnError>,
602
606
  ): RequestResult<ListConnectionsResponses, ListConnectionsErrors, ThrowOnError, "data"> => {
@@ -607,6 +611,7 @@ export const listConnections = <ThrowOnError extends boolean = true>(
607
611
  args: [
608
612
  { in: "headers", key: "X-Request-Id" },
609
613
  { in: "path", key: "organization_id" },
614
+ { in: "query", key: "scope" },
610
615
  ],
611
616
  },
612
617
  ],
@@ -759,8 +764,8 @@ export const discoverConnection = <ThrowOnError extends boolean = true>(
759
764
  "X-Request-Id"?: string;
760
765
  organization_id: Ulid;
761
766
  grant_id: string;
762
- project_id: Ulid;
763
- environment_id: Ulid;
767
+ project_id?: Ulid;
768
+ environment_id?: Ulid;
764
769
  provider_organization_id?: number;
765
770
  team_id?: number;
766
771
  },
@@ -796,6 +801,52 @@ export const discoverConnection = <ThrowOnError extends boolean = true>(
796
801
  });
797
802
  };
798
803
 
804
+ /**
805
+ * Import a Make connection into a project environment
806
+ */
807
+ export const importConnection = <ThrowOnError extends boolean = true>(
808
+ parameters: {
809
+ "X-Request-Id"?: string;
810
+ "Idempotency-Key": string;
811
+ organization_id: Ulid;
812
+ grant_id: string;
813
+ connectionImportRequest: ConnectionImportRequest;
814
+ },
815
+ options?: Options<never, ThrowOnError>,
816
+ ): RequestResult<ImportConnectionResponses, ImportConnectionErrors, ThrowOnError, "data"> => {
817
+ const params = buildClientParams(
818
+ [parameters],
819
+ [
820
+ {
821
+ args: [
822
+ { in: "headers", key: "X-Request-Id" },
823
+ { in: "headers", key: "Idempotency-Key" },
824
+ { in: "path", key: "organization_id" },
825
+ { in: "path", key: "grant_id" },
826
+ { key: "connectionImportRequest", map: "body" },
827
+ ],
828
+ },
829
+ ],
830
+ );
831
+ return (options?.client ?? client).post<
832
+ ImportConnectionResponses,
833
+ ImportConnectionErrors,
834
+ ThrowOnError,
835
+ "data"
836
+ >({
837
+ responseStyle: "data",
838
+ security: [{ scheme: "bearer", type: "http" }],
839
+ url: "/v1/organizations/{organization_id}/connections/{grant_id}/imports",
840
+ ...options,
841
+ ...params,
842
+ headers: {
843
+ "Content-Type": "application/json",
844
+ ...options?.headers,
845
+ ...params.headers,
846
+ },
847
+ });
848
+ };
849
+
799
850
  /**
800
851
  * Disconnect a connection grant
801
852
  */
@@ -21,8 +21,26 @@ export type Preview = {
21
21
 
22
22
  export type ConnectionBegin = {
23
23
  provider: "make";
24
+ project_id?: Ulid;
25
+ environment_id?: Ulid;
26
+ };
27
+
28
+ export type ConnectionImportRequest = {
29
+ project_id: Ulid;
30
+ environment_id: Ulid;
31
+ provider_organization_id: number;
32
+ team_id: number;
33
+ connection_id: number;
34
+ };
35
+
36
+ export type ConnectionImport = {
37
+ id: Ulid;
38
+ grant_id: Ulid;
24
39
  project_id: Ulid;
25
40
  environment_id: Ulid;
41
+ provider_organization_id: number;
42
+ team_id: number;
43
+ connection_id: number;
26
44
  };
27
45
 
28
46
  export type ConnectionHandoff = {
@@ -2775,7 +2793,12 @@ export type ListConnectionsData = {
2775
2793
  path: {
2776
2794
  organization_id: Ulid;
2777
2795
  };
2778
- query?: never;
2796
+ query?: {
2797
+ /**
2798
+ * Select workspace grants; omit for the legacy unfiltered list.
2799
+ */
2800
+ scope?: "workspace";
2801
+ };
2779
2802
  url: "/v1/organizations/{organization_id}/connections";
2780
2803
  };
2781
2804
 
@@ -2985,9 +3008,15 @@ export type DiscoverConnectionData = {
2985
3008
  organization_id: Ulid;
2986
3009
  grant_id: string;
2987
3010
  };
2988
- query: {
2989
- project_id: Ulid;
2990
- environment_id: Ulid;
3011
+ query?: {
3012
+ /**
3013
+ * Supply together with environment_id only for a legacy project-bound grant.
3014
+ */
3015
+ project_id?: Ulid;
3016
+ /**
3017
+ * Supply together with project_id only for a legacy project-bound grant.
3018
+ */
3019
+ environment_id?: Ulid;
2991
3020
  provider_organization_id?: number;
2992
3021
  team_id?: number;
2993
3022
  };
@@ -3029,6 +3058,64 @@ export type DiscoverConnectionResponses = {
3029
3058
  export type DiscoverConnectionResponse =
3030
3059
  DiscoverConnectionResponses[keyof DiscoverConnectionResponses];
3031
3060
 
3061
+ export type ImportConnectionData = {
3062
+ body: ConnectionImportRequest;
3063
+ headers: {
3064
+ /**
3065
+ * Optional caller-provided correlation identifier.
3066
+ */
3067
+ "X-Request-Id"?: string;
3068
+ /**
3069
+ * Identifies one mutation and its canonical request payload.
3070
+ */
3071
+ "Idempotency-Key": string;
3072
+ };
3073
+ path: {
3074
+ organization_id: Ulid;
3075
+ grant_id: string;
3076
+ };
3077
+ query?: never;
3078
+ url: "/v1/organizations/{organization_id}/connections/{grant_id}/imports";
3079
+ };
3080
+
3081
+ export type ImportConnectionErrors = {
3082
+ /**
3083
+ * The request failed.
3084
+ */
3085
+ 400: ProblemDetails;
3086
+ /**
3087
+ * The request failed.
3088
+ */
3089
+ 401: ProblemDetails;
3090
+ /**
3091
+ * The resource does not exist or is not visible to the authenticated principal.
3092
+ */
3093
+ 404: ProblemDetails;
3094
+ /**
3095
+ * The request failed.
3096
+ */
3097
+ 409: ProblemDetails;
3098
+ /**
3099
+ * The request failed.
3100
+ */
3101
+ 429: ProblemDetails;
3102
+ /**
3103
+ * The request failed.
3104
+ */
3105
+ 503: ProblemDetails;
3106
+ };
3107
+
3108
+ export type ImportConnectionError = ImportConnectionErrors[keyof ImportConnectionErrors];
3109
+
3110
+ export type ImportConnectionResponses = {
3111
+ /**
3112
+ * Imported project connection reference.
3113
+ */
3114
+ 201: ConnectionImport;
3115
+ };
3116
+
3117
+ export type ImportConnectionResponse = ImportConnectionResponses[keyof ImportConnectionResponses];
3118
+
3032
3119
  export type DisconnectConnectionData = {
3033
3120
  body?: never;
3034
3121
  headers: {