openship 0.1.10 → 0.1.11

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.
@@ -53,7 +53,7 @@ var init_types = __esm(() => {
53
53
  DEFAULT_RESOURCE_CONFIG = {
54
54
  cpuCores: 1,
55
55
  memoryMb: 512,
56
- diskMb: 4096
56
+ diskMb: 5120
57
57
  };
58
58
  DEFAULT_BUILD_RESOURCE_CONFIG = {
59
59
  cpuCores: 4,
@@ -62135,6 +62135,9 @@ class CloudComposeSupport {
62135
62135
  try {
62136
62136
  workspaceId = builtArtifact?.workspaceId ?? await this.createImageServiceWorkspace(config, log);
62137
62137
  const ws = this.deps.workspace(workspaceId);
62138
+ if (builtArtifact?.workspaceId) {
62139
+ await this.shrinkToRuntimeTier(ws, config, log);
62140
+ }
62138
62141
  await withCloudOperationTimeout(ws.lifecycle.makePermanent(), `Making cloud service "${config.serviceName}" permanent`).catch((err2) => {
62139
62142
  throw new Error(`Failed to make service workspace permanent: ${errorMessage(err2)}`);
62140
62143
  });
@@ -62270,6 +62273,21 @@ class CloudComposeSupport {
62270
62273
  throw err2;
62271
62274
  }
62272
62275
  }
62276
+ async shrinkToRuntimeTier(ws, config, log) {
62277
+ const cpus = config.resources?.cpuCores ?? DEFAULT_RESOURCE_CONFIG.cpuCores;
62278
+ const memory_mb = config.resources?.memoryMb ?? DEFAULT_RESOURCE_CONFIG.memoryMb;
62279
+ try {
62280
+ await withCloudOperationTimeout(ws.resources.update({ cpus, memory_mb, apply: true }), `Resizing service "${config.serviceName}" to its runtime tier`);
62281
+ } catch (err2) {
62282
+ throw new Error(`Failed to shrink service "${config.serviceName}" from the build tier to its runtime tier: ${errorMessage(err2)}`);
62283
+ }
62284
+ log({
62285
+ timestamp: now(),
62286
+ message: `Sized "${config.serviceName}" to its runtime tier (${cpus} vCPU · ${memory_mb} MB).
62287
+ `,
62288
+ level: "info"
62289
+ });
62290
+ }
62273
62291
  async createImageServiceWorkspace(config, onLog) {
62274
62292
  const resources = {
62275
62293
  cpuCores: config.resources?.cpuCores ?? DEFAULT_RESOURCE_CONFIG.cpuCores,
@@ -234876,34 +234894,6 @@ function cloudClient(scope) {
234876
234894
  }
234877
234895
  const body2 = await readCloudJson(res);
234878
234896
  return body2 ?? null;
234879
- },
234880
- async requestVerification(target) {
234881
- const res = await fetchScoped("/api/cloud/edge-proxy/verify-request", {
234882
- method: "POST",
234883
- body: JSON.stringify({ target })
234884
- });
234885
- if (!res)
234886
- return null;
234887
- if (!res.ok) {
234888
- const text3 = await res.text().catch(() => "");
234889
- throw new Error(`Edge verification request failed (${res.status}): ${text3}`);
234890
- }
234891
- const body2 = await readCloudJson(res);
234892
- return body2?.verification ?? null;
234893
- },
234894
- async checkVerification(id2) {
234895
- const res = await fetchScoped("/api/cloud/edge-proxy/verify-check", {
234896
- method: "POST",
234897
- body: JSON.stringify({ id: id2 })
234898
- });
234899
- if (!res)
234900
- return null;
234901
- if (!res.ok) {
234902
- const text3 = await res.text().catch(() => "");
234903
- throw new Error(`Edge verification check failed (${res.status}): ${text3}`);
234904
- }
234905
- const body2 = await readCloudJson(res);
234906
- return body2 ?? null;
234907
234897
  }
234908
234898
  },
234909
234899
  analytics: {
@@ -278842,31 +278832,6 @@ var init_controller_helpers = __esm(async () => {
278842
278832
  await init_src3();
278843
278833
  });
278844
278834
 
278845
- // ../api/src/lib/edge-challenge-store.ts
278846
- async function armEdgeChallenge(token) {
278847
- if (!token)
278848
- return;
278849
- const store2 = await cacheStore(NS, { maxSize: 512 });
278850
- await store2.set(token, true, TTL_SECONDS);
278851
- }
278852
- async function disarmEdgeChallenge(token) {
278853
- if (!token)
278854
- return;
278855
- const store2 = await cacheStore(NS, { maxSize: 512 });
278856
- await store2.delete(token);
278857
- }
278858
- async function isEdgeChallengeArmed(token) {
278859
- if (!token)
278860
- return false;
278861
- const store2 = await cacheStore(NS, { maxSize: 512 });
278862
- return await store2.get(token) === true;
278863
- }
278864
- var NS = "oblien-edge-challenge", TTL_SECONDS;
278865
- var init_edge_challenge_store = __esm(() => {
278866
- init_cache_store();
278867
- TTL_SECONDS = 10 * 60;
278868
- });
278869
-
278870
278835
  // ../api/src/middleware/internal-auth.ts
278871
278836
  import { timingSafeEqual as timingSafeEqual3 } from "node:crypto";
278872
278837
  async function internalAuth(c2, next) {
@@ -283704,23 +283669,6 @@ var init_server_target = __esm(async () => {
283704
283669
  });
283705
283670
 
283706
283671
  // ../api/src/lib/managed-edge-proxy.ts
283707
- function isTargetUnverified(err2) {
283708
- return err2 instanceof Error && /target_unverified|ownership is not verified/i.test(err2.message);
283709
- }
283710
- async function verifyEdgeTarget(edge, target) {
283711
- const challenge = await edge.requestVerification(target);
283712
- if (!challenge)
283713
- throw new Error(NO_CLOUD_MEMBER);
283714
- await armEdgeChallenge(challenge.token);
283715
- try {
283716
- const check4 = await edge.checkVerification(challenge.id);
283717
- if (!check4 || check4.status !== "verified") {
283718
- throw new Error(`Edge target ownership verification failed: ${check4?.error ?? check4?.status ?? "unknown"}`);
283719
- }
283720
- } finally {
283721
- await disarmEdgeChallenge(challenge.token);
283722
- }
283723
- }
283724
283672
  async function ensureManagedEdgeProxy(organizationId, slug, opts) {
283725
283673
  if (!slug.trim())
283726
283674
  return;
@@ -283728,20 +283676,9 @@ async function ensureManagedEdgeProxy(organizationId, slug, opts) {
283728
283676
  if (!target) {
283729
283677
  throw new Error("Cannot configure edge proxy: target host could not be resolved");
283730
283678
  }
283731
- const edge = cloudClient({ organizationId }).edgeProxy;
283732
- const sync = async () => {
283733
- const result = await edge.sync({ slug, target });
283734
- if (!result)
283735
- throw new Error(NO_CLOUD_MEMBER);
283736
- };
283737
- try {
283738
- await sync();
283739
- } catch (err2) {
283740
- if (!isTargetUnverified(err2))
283741
- throw err2;
283742
- await verifyEdgeTarget(edge, target);
283743
- await sync();
283744
- }
283679
+ const result = await cloudClient({ organizationId }).edgeProxy.sync({ slug, target });
283680
+ if (!result)
283681
+ throw new Error(NO_CLOUD_MEMBER);
283745
283682
  }
283746
283683
  async function syncManagedEdgeRoutes(targets, opts) {
283747
283684
  const failures = [];
@@ -283765,7 +283702,6 @@ function edgeUnsyncedWarning(failures, retryHint) {
283765
283702
  var NO_CLOUD_MEMBER = "Cannot sync edge proxy: no member of this organization has linked Openship Cloud";
283766
283703
  var init_managed_edge_proxy = __esm(async () => {
283767
283704
  init_src();
283768
- init_edge_challenge_store();
283769
283705
  await __promiseAll([
283770
283706
  init_client5(),
283771
283707
  init_server_target()
@@ -296459,21 +296395,8 @@ var init_rollback = __esm(async () => {
296459
296395
 
296460
296396
  // ../api/src/modules/deployments/build-pipeline.ts
296461
296397
  import { posix as pathPosix4 } from "node:path";
296462
- function buildScopedEnvVars(envVars, opts) {
296463
- const scoped = { ...envVars };
296464
- let ignoredNodeEnv;
296465
- if (opts?.forceProductionNodeEnv) {
296466
- ignoredNodeEnv = scoped.NODE_ENV;
296467
- delete scoped.NODE_ENV;
296468
- }
296469
- return {
296470
- envVars: {
296471
- ...BUILD_ENV_VARS,
296472
- ...scoped,
296473
- ...opts?.forceProductionNodeEnv ? { NODE_ENV: "production" } : {}
296474
- },
296475
- ignoredNodeEnv
296476
- };
296398
+ function buildScopedEnvVars(envVars) {
296399
+ return { envVars: { ...BUILD_ENV_VARS, ...envVars } };
296477
296400
  }
296478
296401
  function resolveStaticOutputDirectory(outputDirectory, targetPath) {
296479
296402
  const normalizedTargetPath = normalizeTargetPath(targetPath);
@@ -296669,13 +296592,7 @@ async function executeBuildAndDeploy(project2, dep, buildSessionId) {
296669
296592
  logger4.log(`⚠ ${failedEnvKeys.length} environment variable(s) could not be decrypted and were skipped: ${failedEnvKeys.join(", ")}. The encryption key likely changed since they were saved — ` + `re-enter them in the project's Environment settings and redeploy.`, "warn");
296670
296593
  }
296671
296594
  const buildStrategy = await resolveStrategy(snapshot.framework, snapshot.buildStrategy, { deployTarget: snapshot.deployTarget });
296672
- const isLocalBuild = buildStrategy === "local";
296673
- const buildEnv = buildScopedEnvVars(envMap, {
296674
- forceProductionNodeEnv: isLocalBuild
296675
- });
296676
- if (isLocalBuild && buildEnv.ignoredNodeEnv && buildEnv.ignoredNodeEnv !== "production") {
296677
- logger4.log(`Ignoring deployment NODE_ENV=${buildEnv.ignoredNodeEnv} during local build and forcing NODE_ENV=production.`, "warn");
296678
- }
296595
+ const buildEnv = buildScopedEnvVars(envMap);
296679
296596
  const orgOwner = await resolveOrgOwner(dep.organizationId).catch(() => null);
296680
296597
  const actorUserId = orgOwner?.userId ?? "";
296681
296598
  const useServicePipeline = (await resolveServicePipelineMode(project2, snapshot)).useServicePipeline;
@@ -300562,10 +300479,6 @@ var init_cloud_session_service = __esm(async () => {
300562
300479
  });
300563
300480
 
300564
300481
  // ../api/src/modules/cloud/cloud-edge-proxy.service.ts
300565
- function normalizeEdgeTarget(target) {
300566
- const hostPart = target.trim().replace(/^https?:\/\//i, "");
300567
- return `https://${hostPart}`;
300568
- }
300569
300482
  async function syncCloudEdgeProxy(organizationId, input) {
300570
300483
  const slug = input.slug.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
300571
300484
  if (!slug) {
@@ -300573,7 +300486,7 @@ async function syncCloudEdgeProxy(organizationId, input) {
300573
300486
  }
300574
300487
  const baseDomain = SYSTEM.DOMAINS.CLOUD_DOMAIN;
300575
300488
  const hostname7 = `${slug}.${baseDomain}`;
300576
- const target = normalizeEdgeTarget(input.target);
300489
+ const target = input.target.startsWith("http://") || input.target.startsWith("https://") ? input.target : `http://${input.target}`;
300577
300490
  const { client, namespace } = await getNamespaceClient(organizationId);
300578
300491
  const { proxies } = await client.edgeProxy.list();
300579
300492
  const existing = proxies.find((p4) => p4.slug === slug);
@@ -300589,17 +300502,6 @@ async function syncCloudEdgeProxy(organizationId, input) {
300589
300502
  }
300590
300503
  return { ok: true, hostname: hostname7 };
300591
300504
  }
300592
- async function requestTargetVerification(organizationId, rawTarget2) {
300593
- const target = normalizeEdgeTarget(rawTarget2);
300594
- const { client } = await getNamespaceClient(organizationId);
300595
- const { verification: verification2 } = await client.edgeProxy.requestVerification(target);
300596
- return { id: verification2.id, token: verification2.token, path: verification2.path, target };
300597
- }
300598
- async function checkTargetVerification(organizationId, verificationId) {
300599
- const { client } = await getNamespaceClient(organizationId);
300600
- const { verification: verification2 } = await client.edgeProxy.checkVerification(verificationId);
300601
- return { status: verification2.status, error: verification2.error };
300602
- }
300603
300505
  var init_cloud_edge_proxy_service = __esm(() => {
300604
300506
  init_src();
300605
300507
  init_openship_cloud();
@@ -301202,30 +301104,6 @@ async function syncEdgeProxy(c2) {
301202
301104
  return oblienErrorResponse(c2, err2, "Failed to sync edge proxy");
301203
301105
  }
301204
301106
  }
301205
- async function requestEdgeVerification(c2) {
301206
- const ctx2 = getRequestContext(c2);
301207
- const body2 = await c2.req.json();
301208
- if (!body2.target)
301209
- return c2.json({ error: "target is required" }, 400);
301210
- try {
301211
- const verification2 = await requestTargetVerification(ctx2.organizationId, body2.target);
301212
- return c2.json({ ok: true, verification: verification2 });
301213
- } catch (err2) {
301214
- return oblienErrorResponse(c2, err2, "Failed to request target verification");
301215
- }
301216
- }
301217
- async function checkEdgeVerification(c2) {
301218
- const ctx2 = getRequestContext(c2);
301219
- const body2 = await c2.req.json();
301220
- if (typeof body2.id !== "number")
301221
- return c2.json({ error: "id is required" }, 400);
301222
- try {
301223
- const result2 = await checkTargetVerification(ctx2.organizationId, body2.id);
301224
- return c2.json({ ok: true, ...result2 });
301225
- } catch (err2) {
301226
- return oblienErrorResponse(c2, err2, "Failed to check target verification");
301227
- }
301228
- }
301229
301107
  async function pagesProxy(c2) {
301230
301108
  const ctx2 = getRequestContext(c2);
301231
301109
  const body2 = await c2.req.json();
@@ -301568,10 +301446,6 @@ var init_cloud_saas_routes = __esm(async () => {
301568
301446
  r18.post("/preflight", { tag: "cloud:write" }, preflight2);
301569
301447
  r18.use("/edge-proxy", cloudSessionAuth);
301570
301448
  r18.post("/edge-proxy", { tag: "cloud:write" }, syncEdgeProxy);
301571
- r18.use("/edge-proxy/verify-request", cloudSessionAuth);
301572
- r18.post("/edge-proxy/verify-request", { tag: "cloud:write" }, requestEdgeVerification);
301573
- r18.use("/edge-proxy/verify-check", cloudSessionAuth);
301574
- r18.post("/edge-proxy/verify-check", { tag: "cloud:write" }, checkEdgeVerification);
301575
301449
  r18.use("/analytics", cloudSessionAuth);
301576
301450
  r18.post("/analytics", { tag: "cloud:write" }, analyticsProxy);
301577
301451
  r18.use("/pages", cloudSessionAuth);
@@ -309103,7 +308977,6 @@ async function forceMcpConsent(c2, next) {
309103
308977
  init_origin_guard();
309104
308978
  init_src2();
309105
308979
  init_request_store();
309106
- init_edge_challenge_store();
309107
308980
  await __promiseAll([
309108
308981
  init_migration_guard(),
309109
308982
  init_controller_helpers()
@@ -321961,7 +321834,7 @@ import { hostname as hostname6, userInfo } from "node:os";
321961
321834
  // ../api/package.json
321962
321835
  var package_default = {
321963
321836
  name: "@repo/api",
321964
- version: "0.1.10",
321837
+ version: "0.1.11",
321965
321838
  license: "Apache-2.0",
321966
321839
  private: true,
321967
321840
  type: "module",
@@ -326649,12 +326522,6 @@ app.route("/api/permissions", permissionsRoutes);
326649
326522
  app.route("/api/notifications", notificationsRoutes);
326650
326523
  app.get("/.well-known/oauth-authorization-server", (c2) => oauthAuthServerMetadata(c2.req.raw));
326651
326524
  app.get("/.well-known/oauth-protected-resource", (c2) => oauthProtectedResourceMetadata(c2.req.raw));
326652
- app.get("/.well-known/oblien-proxy-challenge/:token", async (c2) => {
326653
- const token = c2.req.param("token");
326654
- if (await isEdgeChallengeArmed(token))
326655
- return c2.text(token, 200);
326656
- return c2.text("not found", 404);
326657
- });
326658
326525
  var authCallbackHtml = `<!DOCTYPE html><html><head><title>Success</title></head><body><script>window.close();</script><p>Authentication successful. You can close this window.</p></body></html>`;
326659
326526
  app.get("/auth/callback/install", (c2) => {
326660
326527
  if (getGitHubAuthMode() === "app") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openship",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Openship CLI - deploy, manage, and open your Openship platform from the terminal",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {