@sylphx/cli 0.8.0 → 0.9.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @sylphx/cli
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1019](https://github.com/SylphxAI/platform/pull/1019) [`7978a14`](https://github.com/SylphxAI/platform/commit/7978a140c6eaf146456a458aa89b943cd3989659) Thanks [@shtse8](https://github.com/shtse8)! - Fail closed when environment targeting is ambiguous across platform management APIs.
8
+
9
+ The contract, Management SDK, and CLI now preserve explicit `envId` targeting for env vars, domains, services, deployments, and logs instead of relying on `envType` defaults when a project has multiple matching environments.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies []:
14
+ - @sylphx/sdk@0.11.2
15
+
3
16
  ## 0.8.0
4
17
 
5
18
  ### Minor Changes
package/dist/main.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@sylphx/cli",
18
- version: "0.8.0",
18
+ version: "0.9.0",
19
19
  description: "Sylphx Platform CLI \u2014 deploy and manage your applications from the terminal. 63 commands across deployment, logs, env vars, domains, databases, storage, monitoring, self-service (user), admin (users/quotas/audit/invitations/jwt-keys/project-migrate), and more.",
20
20
  type: "module",
21
21
  homepage: "https://sylphx.com",
@@ -71,7 +71,7 @@ var init_package = __esm({
71
71
  "@effect/cli": "0.75.1",
72
72
  "@effect/platform": "0.96.0",
73
73
  "@effect/platform-bun": "0.89.0",
74
- "@sylphx/sdk": "0.11.1",
74
+ "@sylphx/sdk": "0.11.2",
75
75
  chalk: "^5.3.0",
76
76
  effect: "3.21.0",
77
77
  eventsource: "^2.0.2",
@@ -7388,7 +7388,8 @@ var init_domain = __esm({
7388
7388
  });
7389
7389
  CreateDomainInput = Schema54.Struct({
7390
7390
  apexDomain: Schema54.String,
7391
- envType: Schema54.optional(Schema54.String)
7391
+ envType: Schema54.optional(Schema54.String),
7392
+ envId: Schema54.optional(Schema54.String)
7392
7393
  });
7393
7394
  AddHostnameInput = Schema54.Struct({
7394
7395
  hostname: Schema54.String,
@@ -7401,7 +7402,7 @@ var init_domain = __esm({
7401
7402
 
7402
7403
  // ../contract/dist/endpoints/domains.js
7403
7404
  import { Schema as Schema55 } from "effect";
7404
- var ProjectPath, DomainPath, HostnamePath, EnvTypeQuery, domainsEndpoints;
7405
+ var ProjectPath, DomainPath, HostnamePath, EnvTargetQuery, domainsEndpoints;
7405
7406
  var init_domains = __esm({
7406
7407
  "../contract/dist/endpoints/domains.js"() {
7407
7408
  "use strict";
@@ -7414,13 +7415,16 @@ var init_domains = __esm({
7414
7415
  domainId: Schema55.String,
7415
7416
  hostnameId: Schema55.String
7416
7417
  });
7417
- EnvTypeQuery = Schema55.Struct({ envType: Schema55.optional(Schema55.String) });
7418
+ EnvTargetQuery = Schema55.Struct({
7419
+ envType: Schema55.optional(Schema55.String),
7420
+ envId: Schema55.optional(Schema55.String)
7421
+ });
7418
7422
  domainsEndpoints = {
7419
7423
  list: defineEndpoint({
7420
7424
  method: "GET",
7421
7425
  path: "/projects/:projectId/domains",
7422
7426
  params: ProjectPath,
7423
- query: EnvTypeQuery,
7427
+ query: EnvTargetQuery,
7424
7428
  response: Schema55.Array(Domain),
7425
7429
  summary: "List apex domains registered on a project",
7426
7430
  tags: ["domains"]
@@ -7457,7 +7461,7 @@ var init_domains = __esm({
7457
7461
  path: "/projects/:projectId/domains/:domainId/hostnames",
7458
7462
  success: { status: 201 },
7459
7463
  params: DomainPath,
7460
- query: EnvTypeQuery,
7464
+ query: EnvTargetQuery,
7461
7465
  body: AddHostnameInput,
7462
7466
  response: DomainHostname,
7463
7467
  summary: "Add a hostname under an apex domain",
@@ -15898,6 +15902,7 @@ var init_environments2 = __esm({
15898
15902
  "../management/dist/environments.js"() {
15899
15903
  "use strict";
15900
15904
  init_dist();
15905
+ init_errors2();
15901
15906
  init_http();
15902
15907
  orgHeaders2 = (options = {}) => ({
15903
15908
  ...options.orgId ? { "x-preferred-org-id": options.orgId } : {}
@@ -15913,11 +15918,17 @@ var init_environments2 = __esm({
15913
15918
  const byId = envs.find((e) => e.id === envType.trim());
15914
15919
  if (byId)
15915
15920
  return byId.id;
15916
- const byName = envs.find((e) => (e.name ?? "").toLowerCase() === needle);
15917
- if (byName)
15918
- return byName.id;
15919
- const byType = envs.find((e) => (e.envType ?? "").toLowerCase() === needle);
15920
- return byType?.id ?? null;
15921
+ const byName = envs.filter((e) => (e.name ?? "").toLowerCase() === needle);
15922
+ if (byName.length > 1) {
15923
+ throw new ApiError2(422, `Multiple active environments named '${envType}' exist for project '${projectId}'. Pass the environment id explicitly.`);
15924
+ }
15925
+ if (byName[0])
15926
+ return byName[0].id;
15927
+ const byType = envs.filter((e) => (e.envType ?? "").toLowerCase() === needle);
15928
+ if (byType.length > 1) {
15929
+ throw new ApiError2(422, `Multiple active ${envType} environments exist for project '${projectId}'. Pass the environment id explicitly.`);
15930
+ }
15931
+ return byType[0]?.id ?? null;
15921
15932
  };
15922
15933
  promote = (client, projectId, targetEnvId, sourceEnvId, options = {}) => {
15923
15934
  const { method, path: path6 } = environmentsEndpoints.promote;
@@ -16063,22 +16074,22 @@ var init_domains2 = __esm({
16063
16074
  list8 = (client, projectId, envType = "production", options = {}) => {
16064
16075
  const { method, path: path6 } = domainsEndpoints.list;
16065
16076
  return request(client, method, interpolatePath(path6, { projectId }), {
16066
- query: { envType },
16077
+ query: { envType, envId: options.envId },
16067
16078
  headers: orgHeaders3(options)
16068
16079
  });
16069
16080
  };
16070
16081
  create5 = (client, projectId, apexDomain, envType = "production", options = {}) => {
16071
16082
  const { method, path: path6 } = domainsEndpoints.create;
16072
16083
  return request(client, method, interpolatePath(path6, { projectId }), {
16073
- body: { apexDomain, envType },
16084
+ body: { apexDomain, envType, envId: options.envId },
16074
16085
  headers: orgHeaders3(options)
16075
16086
  });
16076
16087
  };
16077
16088
  addHostname = (client, projectId, domainId, hostname, opts, options = {}) => {
16078
16089
  const { method, path: path6 } = domainsEndpoints.addHostname;
16079
- const { envType = "production", ...body } = opts;
16090
+ const { envType = "production", envId, ...body } = opts;
16080
16091
  return request(client, method, interpolatePath(path6, { projectId, domainId }), {
16081
- query: { envType },
16092
+ query: { envType, envId },
16082
16093
  body: { hostname, ...body },
16083
16094
  headers: orgHeaders3(options)
16084
16095
  });
@@ -16211,7 +16222,7 @@ var init_envVars = __esm({
16211
16222
  });
16212
16223
  list9 = async (client, projectId, envType, options = {}) => {
16213
16224
  const { method, path: path6 } = envVarsEndpoints.list;
16214
- const res = await request(client, method, interpolatePath(path6, { id: projectId }), { query: { envType }, headers: orgHeaders4(options) });
16225
+ const res = await request(client, method, interpolatePath(path6, { id: projectId }), { query: { envType, envId: options.envId }, headers: orgHeaders4(options) });
16215
16226
  return Array.isArray(res) ? res : res.data ?? [];
16216
16227
  };
16217
16228
  set2 = (client, projectId, key, value, envType, secret, options = {}) => {
@@ -16219,6 +16230,7 @@ var init_envVars = __esm({
16219
16230
  return request(client, method, interpolatePath(path6, { id: projectId }), {
16220
16231
  body: {
16221
16232
  envType,
16233
+ envId: options.envId,
16222
16234
  vars: [{ key, value, secret: secret ?? false }]
16223
16235
  },
16224
16236
  headers: orgHeaders4(options)
@@ -16227,14 +16239,14 @@ var init_envVars = __esm({
16227
16239
  setMany = (client, projectId, vars, envType, options = {}) => {
16228
16240
  const { method, path: path6 } = envVarsEndpoints.set;
16229
16241
  return request(client, method, interpolatePath(path6, { id: projectId }), {
16230
- body: { envType, vars },
16242
+ body: { envType, envId: options.envId, vars },
16231
16243
  headers: orgHeaders4(options)
16232
16244
  });
16233
16245
  };
16234
16246
  _delete5 = (client, projectId, key, envType, options = {}) => {
16235
16247
  const { method, path: path6 } = envVarsEndpoints.delete;
16236
16248
  return request(client, method, interpolatePath(path6, { id: projectId, key }), {
16237
- query: { envType },
16249
+ query: { envType, envId: options.envId },
16238
16250
  headers: orgHeaders4(options)
16239
16251
  });
16240
16252
  };
@@ -16323,8 +16335,13 @@ var init_logs = __esm({
16323
16335
  orgHeaders5 = (options = {}) => ({
16324
16336
  ...options.orgId ? { "x-preferred-org-id": options.orgId } : {}
16325
16337
  });
16326
- stream = (client, projectId, envType) => {
16327
- const params = new URLSearchParams({ envType, stream: "true", limit: "200" });
16338
+ stream = (client, projectId, envType, options = {}) => {
16339
+ const params = new URLSearchParams({ stream: "true", limit: "200" });
16340
+ if (options.envId) {
16341
+ params.set("envId", options.envId);
16342
+ } else {
16343
+ params.set("envType", envType);
16344
+ }
16328
16345
  return {
16329
16346
  url: `${client.apiBase}/projects/${encodeURIComponent(projectId)}/logs?${params.toString()}`,
16330
16347
  token: client.token
@@ -17249,6 +17266,7 @@ var init_services = __esm({
17249
17266
  "../management/dist/services.js"() {
17250
17267
  "use strict";
17251
17268
  init_environments2();
17269
+ init_errors2();
17252
17270
  init_http();
17253
17271
  list22 = async (client, projectId, options = {}) => {
17254
17272
  const res = await request(client, "GET", `/projects/${encodeURIComponent(projectId)}/services`, { headers: { "x-preferred-org-id": options.orgId } });
@@ -17260,9 +17278,12 @@ var init_services = __esm({
17260
17278
  headers: { "x-preferred-org-id": options.orgId }
17261
17279
  });
17262
17280
  deploy = async (client, projectId, name, envType, options = {}) => {
17263
- const environmentId = await resolveId(client, projectId, envType, options);
17281
+ const environmentId = options.envId ?? await resolveId(client, projectId, envType, options);
17282
+ if (!environmentId) {
17283
+ throw new ApiError2(404, `Environment '${envType}' not found`);
17284
+ }
17264
17285
  return request(client, "POST", `/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(name)}/deploy`, {
17265
- body: environmentId ? { environmentId } : {},
17286
+ body: { environmentId },
17266
17287
  headers: { "x-preferred-org-id": options.orgId }
17267
17288
  });
17268
17289
  };
@@ -18613,14 +18634,14 @@ var init_api = __esm({
18613
18634
  )
18614
18635
  ),
18615
18636
  // ── Env vars ───────────────────────────────────────────────────────────
18616
- listEnvVars: (projectId, envType) => withClient((c2) => envVars_exports.list(c2, projectId, envType)),
18617
- setEnvVar: (projectId, key, value, envType, secret) => withClient((c2) => envVars_exports.set(c2, projectId, key, value, envType, secret)),
18618
- deleteEnvVar: (projectId, key, envType) => withClient((c2) => envVars_exports.delete(c2, projectId, key, envType)),
18619
- setEnvVars: (projectId, vars, envType) => withClient((c2) => envVars_exports.setMany(c2, projectId, vars, envType)),
18637
+ listEnvVars: (projectId, envType, options) => withClient((c2) => envVars_exports.list(c2, projectId, envType, options)),
18638
+ setEnvVar: (projectId, key, value, envType, secret, options) => withClient((c2) => envVars_exports.set(c2, projectId, key, value, envType, secret, options)),
18639
+ deleteEnvVar: (projectId, key, envType, options) => withClient((c2) => envVars_exports.delete(c2, projectId, key, envType, options)),
18640
+ setEnvVars: (projectId, vars, envType, options) => withClient((c2) => envVars_exports.setMany(c2, projectId, vars, envType, options)),
18620
18641
  // ── Domains ────────────────────────────────────────────────────────────
18621
- listDomains: (projectId, envType = "production") => withClient((c2) => domains_exports.list(c2, projectId, envType)),
18622
- createDomain: (projectId, apexDomain, envType = "production") => withClient((c2) => domains_exports.create(c2, projectId, apexDomain, envType)),
18623
- addHostname: (projectId, domainId, hostname, opts) => withClient((c2) => domains_exports.addHostname(c2, projectId, domainId, hostname, opts)),
18642
+ listDomains: (projectId, envType = "production", options) => withClient((c2) => domains_exports.list(c2, projectId, envType, options)),
18643
+ createDomain: (projectId, apexDomain, envType = "production", options) => withClient((c2) => domains_exports.create(c2, projectId, apexDomain, envType, options)),
18644
+ addHostname: (projectId, domainId, hostname, opts, options) => withClient((c2) => domains_exports.addHostname(c2, projectId, domainId, hostname, opts, options)),
18624
18645
  removeHostname: (projectId, domainId, hostnameId) => withClient((c2) => domains_exports.removeHostname(c2, projectId, domainId, hostnameId)),
18625
18646
  checkHostname: (projectId, domainId, hostnameId) => withClient((c2) => domains_exports.checkHostname(c2, projectId, domainId, hostnameId)),
18626
18647
  enableEmail: (projectId, domainId, opts) => withClient((c2) => domains_exports.enableEmail(c2, projectId, domainId, opts)),
@@ -18651,7 +18672,7 @@ var init_api = __esm({
18651
18672
  // ── Services ───────────────────────────────────────────────────────────
18652
18673
  listServices: (projectId) => withClient((c2) => services_exports.list(c2, projectId)),
18653
18674
  getService: (projectId, name) => withClient((c2) => services_exports.get(c2, projectId, name)),
18654
- deployService: (projectId, name, envType) => withClient((c2) => services_exports.deploy(c2, projectId, name, envType)),
18675
+ deployService: (projectId, name, envType, options) => withClient((c2) => services_exports.deploy(c2, projectId, name, envType, options)),
18655
18676
  deleteService: (projectId, name) => withClient((c2) => services_exports.delete(c2, projectId, name)),
18656
18677
  // ── Volumes ────────────────────────────────────────────────────────────
18657
18678
  listVolumes: (projectId) => withClient((c2) => volumes_exports.list(c2, projectId)),