@objectstack/runtime 7.1.0 → 7.2.1

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/dist/index.d.cts CHANGED
@@ -12,6 +12,7 @@ export { CapturedError, ErrorReporter, InMemoryErrorReporter, InMemoryMetricsReg
12
12
  import { MiddlewareConfig, MiddlewareType } from '@objectstack/spec/system';
13
13
  import { EnvironmentArtifact } from '@objectstack/spec/cloud';
14
14
  export { RestApiPluginConfig, RestServer, RouteEntry, RouteGroupBuilder, RouteManager, createRestApiPlugin } from '@objectstack/rest';
15
+ export { _resetEnvDeprecationWarnings, readEnvWithDeprecation } from '@objectstack/types';
15
16
 
16
17
  interface RuntimeConfig {
17
18
  /**
@@ -1940,11 +1941,21 @@ interface MarketplaceProxyPluginConfig {
1940
1941
  * Override the LRU upper bound. Defaults to 200 entries.
1941
1942
  */
1942
1943
  cacheMaxEntries?: number;
1944
+ /**
1945
+ * Public R2 base URL for marketplace snapshots. When set, GETs for
1946
+ * snapshot-backed paths (`/packages`, `/packages/:id`,
1947
+ * `/packages/:id/versions/:vid/manifest`) are fetched directly from
1948
+ * R2 (CF edge) — bypassing the cloud control plane entirely.
1949
+ * Defaults to the value of OS_MARKETPLACE_PUBLIC_BASE_URL. Empty
1950
+ * string disables the public fast-path (legacy cloud-proxy only).
1951
+ */
1952
+ publicMarketplaceBaseUrl?: string;
1943
1953
  }
1944
1954
  declare class MarketplaceProxyPlugin implements Plugin {
1945
1955
  readonly name = "com.objectstack.runtime.marketplace-proxy";
1946
- readonly version = "1.0.0";
1956
+ readonly version = "1.1.0";
1947
1957
  private readonly cloudUrl;
1958
+ private readonly publicBaseUrl;
1948
1959
  private readonly cache;
1949
1960
  constructor(config?: MarketplaceProxyPluginConfig);
1950
1961
  init: (_ctx: PluginContext) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { CapturedError, ErrorReporter, InMemoryErrorReporter, InMemoryMetricsReg
12
12
  import { MiddlewareConfig, MiddlewareType } from '@objectstack/spec/system';
13
13
  import { EnvironmentArtifact } from '@objectstack/spec/cloud';
14
14
  export { RestApiPluginConfig, RestServer, RouteEntry, RouteGroupBuilder, RouteManager, createRestApiPlugin } from '@objectstack/rest';
15
+ export { _resetEnvDeprecationWarnings, readEnvWithDeprecation } from '@objectstack/types';
15
16
 
16
17
  interface RuntimeConfig {
17
18
  /**
@@ -1940,11 +1941,21 @@ interface MarketplaceProxyPluginConfig {
1940
1941
  * Override the LRU upper bound. Defaults to 200 entries.
1941
1942
  */
1942
1943
  cacheMaxEntries?: number;
1944
+ /**
1945
+ * Public R2 base URL for marketplace snapshots. When set, GETs for
1946
+ * snapshot-backed paths (`/packages`, `/packages/:id`,
1947
+ * `/packages/:id/versions/:vid/manifest`) are fetched directly from
1948
+ * R2 (CF edge) — bypassing the cloud control plane entirely.
1949
+ * Defaults to the value of OS_MARKETPLACE_PUBLIC_BASE_URL. Empty
1950
+ * string disables the public fast-path (legacy cloud-proxy only).
1951
+ */
1952
+ publicMarketplaceBaseUrl?: string;
1943
1953
  }
1944
1954
  declare class MarketplaceProxyPlugin implements Plugin {
1945
1955
  readonly name = "com.objectstack.runtime.marketplace-proxy";
1946
- readonly version = "1.0.0";
1956
+ readonly version = "1.1.0";
1947
1957
  private readonly cloudUrl;
1958
+ private readonly publicBaseUrl;
1948
1959
  private readonly cache;
1949
1960
  constructor(config?: MarketplaceProxyPluginConfig);
1950
1961
  init: (_ctx: PluginContext) => Promise<void>;
package/dist/index.js CHANGED
@@ -1202,6 +1202,7 @@ __export(app_plugin_exports, {
1202
1202
  collectBundleFunctions: () => collectBundleFunctions,
1203
1203
  collectBundleHooks: () => collectBundleHooks
1204
1204
  });
1205
+ import { readEnvWithDeprecation } from "@objectstack/types";
1205
1206
  function collectBundleHooks(bundle) {
1206
1207
  const out = [];
1207
1208
  const seen = /* @__PURE__ */ new Set();
@@ -1591,7 +1592,7 @@ var init_app_plugin = __esm({
1591
1592
  } catch (e) {
1592
1593
  ctx.logger.warn("[Seeder] Failed to register seed-datasets/seed-replayer service", { error: e?.message });
1593
1594
  }
1594
- const multiTenant = String(process.env.OS_MULTI_TENANT ?? "false").toLowerCase() !== "false";
1595
+ const multiTenant = String(readEnvWithDeprecation("OS_MULTI_ORG_ENABLED", "OS_MULTI_TENANT") ?? "false").toLowerCase() !== "false";
1595
1596
  if (multiTenant) {
1596
1597
  ctx.logger.info("[Seeder] multi-tenant mode \u2014 skipping inline seed; per-org replay will run on sys_organization insert");
1597
1598
  } else {
@@ -2245,6 +2246,7 @@ import { resolve as resolvePath2 } from "path";
2245
2246
  import { mkdirSync } from "fs";
2246
2247
  import { homedir } from "os";
2247
2248
  import { z } from "zod";
2249
+ import { readEnvWithDeprecation as readEnvWithDeprecation2 } from "@objectstack/types";
2248
2250
  function resolveObjectStackHome() {
2249
2251
  const raw = process.env.OS_HOME?.trim();
2250
2252
  if (raw && raw.length > 0) {
@@ -2294,7 +2296,7 @@ async function createStandaloneStack(config) {
2294
2296
  const environmentId = cfg.environmentId ?? process.env.OS_ENVIRONMENT_ID ?? "proj_local";
2295
2297
  const artifactPathInput = cfg.artifactPath ?? process.env.OS_ARTIFACT_PATH ?? resolvePath2(cwd, "dist/objectstack.json");
2296
2298
  const artifactPath = isHttpUrl(artifactPathInput) ? artifactPathInput : artifactPathInput.startsWith("/") ? artifactPathInput : resolvePath2(cwd, artifactPathInput);
2297
- const dbUrl = cfg.databaseUrl ?? process.env.OS_DATABASE_URL?.trim() ?? process.env.TURSO_DATABASE_URL?.trim() ?? (process.env.OS_HOME?.trim() ? `file:${resolvePath2(resolveObjectStackHome(), "data/standalone.db")}` : cfg.projectRoot ? `file:${resolvePath2(cfg.projectRoot, ".objectstack/data/standalone.db")}` : `file:${resolvePath2(resolveObjectStackHome(), "data/standalone.db")}`);
2299
+ const dbUrl = cfg.databaseUrl ?? readEnvWithDeprecation2("OS_DATABASE_URL", "DATABASE_URL")?.trim() ?? process.env.TURSO_DATABASE_URL?.trim() ?? (process.env.OS_HOME?.trim() ? `file:${resolvePath2(resolveObjectStackHome(), "data/standalone.db")}` : cfg.projectRoot ? `file:${resolvePath2(cfg.projectRoot, ".objectstack/data/standalone.db")}` : `file:${resolvePath2(resolveObjectStackHome(), "data/standalone.db")}`);
2298
2300
  const explicitDriver = cfg.databaseDriver ?? process.env.OS_DATABASE_DRIVER?.trim();
2299
2301
  const dbDriver = explicitDriver ?? detectDriverFromUrl(dbUrl);
2300
2302
  let driverPlugin;
@@ -2457,6 +2459,7 @@ init_seed_loader();
2457
2459
 
2458
2460
  // src/http-dispatcher.ts
2459
2461
  import { getEnv, resolveLocale } from "@objectstack/core";
2462
+ import { readEnvWithDeprecation as readEnvWithDeprecation3 } from "@objectstack/types";
2460
2463
  import { CoreServiceName } from "@objectstack/spec/system";
2461
2464
  import { pluralToSingular } from "@objectstack/spec/shared";
2462
2465
 
@@ -3947,7 +3950,7 @@ var _HttpDispatcher = class _HttpDispatcher {
3947
3950
  }
3948
3951
  }
3949
3952
  if (parts.length === 3 && parts[0] === "admin" && parts[1] === "platform-sso" && parts[2] === "backfill" && m === "POST") {
3950
- const baseSecret = (process.env.OS_AUTH_SECRET ?? process.env.AUTH_SECRET ?? "").trim();
3953
+ const baseSecret = (readEnvWithDeprecation3("OS_AUTH_SECRET", ["AUTH_SECRET", "BETTER_AUTH_SECRET"]) ?? "").trim();
3951
3954
  if (!baseSecret) {
3952
3955
  return { handled: true, response: this.error("OS_AUTH_SECRET not configured on this worker", 503) };
3953
3956
  }
@@ -4137,7 +4140,7 @@ var _HttpDispatcher = class _HttpDispatcher {
4137
4140
  });
4138
4141
  try {
4139
4142
  const { seedPlatformSsoClient: seedPlatformSsoClient2 } = await Promise.resolve().then(() => (init_platform_sso(), platform_sso_exports));
4140
- const baseSecret = (process.env.OS_AUTH_SECRET ?? process.env.AUTH_SECRET ?? "").trim();
4143
+ const baseSecret = (readEnvWithDeprecation3("OS_AUTH_SECRET", ["AUTH_SECRET", "BETTER_AUTH_SECRET"]) ?? "").trim();
4141
4144
  if (baseSecret) {
4142
4145
  await seedPlatformSsoClient2({
4143
4146
  ql,
@@ -7607,6 +7610,7 @@ init_driver_plugin();
7607
7610
  init_app_plugin();
7608
7611
  import { createHmac as createHmac2 } from "crypto";
7609
7612
  import { ObjectKernel as ObjectKernel3 } from "@objectstack/core";
7613
+ import { readEnvWithDeprecation as readEnvWithDeprecation4 } from "@objectstack/types";
7610
7614
 
7611
7615
  // src/cloud/capability-loader.ts
7612
7616
  var CAPABILITY_PROVIDERS = {
@@ -7744,7 +7748,7 @@ var ArtifactKernelFactory = class {
7744
7748
  this.envRegistry = config.envRegistry;
7745
7749
  this.logger = config.logger ?? console;
7746
7750
  this.kernelConfig = config.kernelConfig;
7747
- this.authBaseSecret = (config.authBaseSecret ?? process.env.OS_AUTH_SECRET ?? process.env.AUTH_SECRET ?? "").trim();
7751
+ this.authBaseSecret = (config.authBaseSecret ?? readEnvWithDeprecation4("OS_AUTH_SECRET", ["AUTH_SECRET", "BETTER_AUTH_SECRET"]) ?? "").trim();
7748
7752
  }
7749
7753
  async create(environmentId) {
7750
7754
  let cached = this.envRegistry.peekById(environmentId);
@@ -7857,7 +7861,7 @@ var ArtifactKernelFactory = class {
7857
7861
  this.logger.warn?.("[ArtifactKernelFactory] OS_AUTH_SECRET not set \u2014 per-project AuthPlugin skipped (auth endpoints will return 404)", { environmentId });
7858
7862
  }
7859
7863
  try {
7860
- const multiTenant = String(process.env.OS_MULTI_TENANT ?? "false").toLowerCase() !== "false";
7864
+ const multiTenant = String(readEnvWithDeprecation4("OS_MULTI_ORG_ENABLED", "OS_MULTI_TENANT") ?? "false").toLowerCase() !== "false";
7861
7865
  if (multiTenant) {
7862
7866
  try {
7863
7867
  const { OrgScopingPlugin } = await import("@objectstack/plugin-org-scoping");
@@ -8394,6 +8398,36 @@ function resolveCloudUrl(explicit) {
8394
8398
  return picked.replace(/\/+$/, "");
8395
8399
  }
8396
8400
 
8401
+ // src/cloud/marketplace-public-url.ts
8402
+ function resolveMarketplacePublicBaseUrl(explicit) {
8403
+ const raw = (explicit ?? process.env.OS_MARKETPLACE_PUBLIC_BASE_URL ?? "").trim();
8404
+ const lower = raw.toLowerCase();
8405
+ if (!raw || lower === "off" || lower === "none" || lower === "disabled" || lower === "false") {
8406
+ return "";
8407
+ }
8408
+ return raw.replace(/\/+$/, "");
8409
+ }
8410
+ function publicMarketplaceKeyForApiPath(pathname) {
8411
+ const prefix = "/api/v1/marketplace/packages";
8412
+ if (pathname === prefix) return "packages.json";
8413
+ if (!pathname.startsWith(`${prefix}/`)) return null;
8414
+ const tail = pathname.slice(prefix.length + 1);
8415
+ if (!tail) return null;
8416
+ const parts = tail.split("/");
8417
+ if (parts.length === 1) {
8418
+ const id = decodeURIComponent(parts[0] ?? "");
8419
+ if (!id) return null;
8420
+ return `packages/${encodeURIComponent(id)}.json`;
8421
+ }
8422
+ if (parts.length === 4 && parts[1] === "versions" && parts[3] === "manifest") {
8423
+ const id = decodeURIComponent(parts[0] ?? "");
8424
+ const versionId = decodeURIComponent(parts[2] ?? "");
8425
+ if (!id || !versionId) return null;
8426
+ return `packages/${encodeURIComponent(id)}/versions/${encodeURIComponent(versionId)}/manifest.json`;
8427
+ }
8428
+ return null;
8429
+ }
8430
+
8397
8431
  // src/cloud/marketplace-proxy-plugin.ts
8398
8432
  var MARKETPLACE_PREFIX = "/api/v1/marketplace";
8399
8433
  var DEFAULT_LRU_MAX = 200;
@@ -8433,7 +8467,7 @@ var LruTtlCache = class {
8433
8467
  var MarketplaceProxyPlugin = class _MarketplaceProxyPlugin {
8434
8468
  constructor(config = {}) {
8435
8469
  this.name = "com.objectstack.runtime.marketplace-proxy";
8436
- this.version = "1.0.0";
8470
+ this.version = "1.1.0";
8437
8471
  this.init = async (_ctx) => {
8438
8472
  };
8439
8473
  this.start = async (ctx) => {
@@ -8451,7 +8485,11 @@ var MarketplaceProxyPlugin = class _MarketplaceProxyPlugin {
8451
8485
  }
8452
8486
  const rawApp = httpServer.getRawApp();
8453
8487
  const cloudUrl = this.cloudUrl;
8488
+ const publicBaseUrl = this.publicBaseUrl;
8454
8489
  const cache = this.cache;
8490
+ if (publicBaseUrl) {
8491
+ ctx.logger?.info?.(`[MarketplaceProxyPlugin] public R2 fast-path enabled \u2192 ${publicBaseUrl}`);
8492
+ }
8455
8493
  const handler = async (c, next) => {
8456
8494
  if (!cloudUrl) {
8457
8495
  return c.json({
@@ -8467,8 +8505,18 @@ var MarketplaceProxyPlugin = class _MarketplaceProxyPlugin {
8467
8505
  if (incomingUrl.pathname.startsWith(`${MARKETPLACE_PREFIX}/install-local`)) {
8468
8506
  return next();
8469
8507
  }
8470
- const target = `${cloudUrl}${incomingUrl.pathname}${incomingUrl.search}`;
8471
8508
  const method = String(c.req.method ?? "GET").toUpperCase();
8509
+ if (publicBaseUrl && (method === "GET" || method === "HEAD")) {
8510
+ const r2Resp = await tryPublicMarketplaceFetch(
8511
+ publicBaseUrl,
8512
+ incomingUrl,
8513
+ method,
8514
+ c.req.header("accept"),
8515
+ ctx.logger
8516
+ );
8517
+ if (r2Resp) return r2Resp;
8518
+ }
8519
+ const target = `${cloudUrl}${incomingUrl.pathname}${incomingUrl.search}`;
8472
8520
  if (method !== "GET" && method !== "HEAD") {
8473
8521
  return c.json({
8474
8522
  success: false,
@@ -8549,12 +8597,82 @@ var MarketplaceProxyPlugin = class _MarketplaceProxyPlugin {
8549
8597
  });
8550
8598
  };
8551
8599
  this.cloudUrl = resolveCloudUrl(config.controlPlaneUrl);
8600
+ this.publicBaseUrl = resolveMarketplacePublicBaseUrl(config.publicMarketplaceBaseUrl);
8552
8601
  const envFlag = (process.env.OS_MARKETPLACE_CACHE ?? "").trim().toLowerCase();
8553
8602
  const envDisabled = ["off", "false", "0", "no", "disable", "disabled"].includes(envFlag);
8554
8603
  const disabled = config.cacheDisabled ?? envDisabled;
8555
8604
  this.cache = disabled ? null : new LruTtlCache(Math.max(8, config.cacheMaxEntries ?? DEFAULT_LRU_MAX));
8556
8605
  }
8557
8606
  };
8607
+ async function tryPublicMarketplaceFetch(publicBaseUrl, incomingUrl, method, acceptHeader, logger) {
8608
+ const key = publicMarketplaceKeyForApiPath(incomingUrl.pathname);
8609
+ if (!key) return null;
8610
+ const target = `${publicBaseUrl}/${key}`;
8611
+ let resp;
8612
+ try {
8613
+ resp = await fetch(target, {
8614
+ method: "GET",
8615
+ headers: {
8616
+ "Accept": acceptHeader || "application/json",
8617
+ "User-Agent": `objectos-marketplace-proxy/public-r2`
8618
+ }
8619
+ });
8620
+ } catch (err) {
8621
+ logger?.warn?.(`[MarketplaceProxyPlugin] public R2 fetch failed (${target}): ${err?.message ?? err}`);
8622
+ return null;
8623
+ }
8624
+ if (resp.status === 404) return null;
8625
+ if (!resp.ok) {
8626
+ logger?.warn?.(`[MarketplaceProxyPlugin] public R2 ${target} returned ${resp.status} \u2014 falling back to cloud`);
8627
+ return null;
8628
+ }
8629
+ const isList = key === "packages.json";
8630
+ const hasFilters = isList && (incomingUrl.searchParams.has("q") || incomingUrl.searchParams.has("category") || incomingUrl.searchParams.has("limit") || incomingUrl.searchParams.has("offset"));
8631
+ if (!hasFilters) {
8632
+ const headers2 = new Headers();
8633
+ const ct = resp.headers.get("content-type") ?? "application/json; charset=utf-8";
8634
+ headers2.set("content-type", ct);
8635
+ const cc = resp.headers.get("cache-control");
8636
+ if (cc) headers2.set("cache-control", cc);
8637
+ const etag = resp.headers.get("etag");
8638
+ if (etag) headers2.set("etag", etag);
8639
+ headers2.set("x-cache", "PUBLIC-R2");
8640
+ const body2 = method === "HEAD" ? null : resp.body;
8641
+ return new Response(body2, { status: 200, headers: headers2 });
8642
+ }
8643
+ let snapshot;
8644
+ try {
8645
+ snapshot = await resp.json();
8646
+ } catch (err) {
8647
+ logger?.warn?.(`[MarketplaceProxyPlugin] public R2 list snapshot parse failed: ${err?.message ?? err}`);
8648
+ return null;
8649
+ }
8650
+ const items = Array.isArray(snapshot?.data?.items) ? snapshot.data.items : [];
8651
+ const q = (incomingUrl.searchParams.get("q") ?? "").trim().toLowerCase();
8652
+ const category = (incomingUrl.searchParams.get("category") ?? "").trim();
8653
+ const limit = Math.min(Math.max(Number(incomingUrl.searchParams.get("limit") ?? 50), 1), 100);
8654
+ const offset = Math.max(Number(incomingUrl.searchParams.get("offset") ?? 0), 0);
8655
+ let filtered = items;
8656
+ if (q) {
8657
+ filtered = filtered.filter((r) => {
8658
+ const dn = String(r?.display_name ?? "").toLowerCase();
8659
+ const mid = String(r?.manifest_id ?? "").toLowerCase();
8660
+ return dn.includes(q) || mid.includes(q);
8661
+ });
8662
+ }
8663
+ if (category) {
8664
+ filtered = filtered.filter((r) => String(r?.category ?? "") === category);
8665
+ }
8666
+ const total = filtered.length;
8667
+ const page = filtered.slice(offset, offset + limit);
8668
+ const body = JSON.stringify({ success: true, data: { items: page, total, limit, offset } });
8669
+ const headers = new Headers({
8670
+ "content-type": "application/json; charset=utf-8",
8671
+ "cache-control": "public, max-age=30",
8672
+ "x-cache": "PUBLIC-R2-FILTERED"
8673
+ });
8674
+ return new Response(method === "HEAD" ? null : body, { status: 200, headers });
8675
+ }
8558
8676
  var PASSTHROUGH_HEADERS = ["content-type", "cache-control", "etag", "last-modified", "vary"];
8559
8677
  function collectHeaders(src) {
8560
8678
  const out = {};
@@ -8946,6 +9064,7 @@ async function createObjectOSStack(config) {
8946
9064
  // src/cloud/marketplace-install-local-plugin.ts
8947
9065
  import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync, readdirSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
8948
9066
  import { join, resolve } from "path";
9067
+ import { readEnvWithDeprecation as readEnvWithDeprecation5 } from "@objectstack/types";
8949
9068
  var ROUTE_BASE = "/api/v1/marketplace/install-local";
8950
9069
  var DEFAULT_DIR = ".objectstack/installed-packages";
8951
9070
  function safeFilename(manifestId) {
@@ -9038,22 +9157,55 @@ var MarketplaceInstallLocalPlugin = class {
9038
9157
  return c.json({ success: false, error: { code: "bad_request", message: "packageId is required." } }, 400);
9039
9158
  }
9040
9159
  let payload;
9041
- try {
9042
- const url = `${this.cloudUrl}/api/v1/marketplace/packages/${encodeURIComponent(packageId)}/versions/${encodeURIComponent(versionId)}/manifest`;
9043
- const resp = await fetch(url, { headers: { "Accept": "application/json" } });
9044
- if (!resp.ok) {
9045
- const text = await resp.text().catch(() => "");
9160
+ const publicBase = resolveMarketplacePublicBaseUrl();
9161
+ const fetchAttempts = [];
9162
+ if (publicBase) {
9163
+ fetchAttempts.push({
9164
+ label: "public-r2",
9165
+ url: `${publicBase}/packages/${encodeURIComponent(packageId)}/versions/${encodeURIComponent(versionId)}/manifest.json`
9166
+ });
9167
+ }
9168
+ fetchAttempts.push({
9169
+ label: "cloud",
9170
+ url: `${this.cloudUrl}/api/v1/marketplace/packages/${encodeURIComponent(packageId)}/versions/${encodeURIComponent(versionId)}/manifest`
9171
+ });
9172
+ let lastErrStatus = 0;
9173
+ let lastErrText = "";
9174
+ for (const attempt of fetchAttempts) {
9175
+ try {
9176
+ const resp = await fetch(attempt.url, { headers: { "Accept": "application/json" } });
9177
+ if (!resp.ok) {
9178
+ lastErrStatus = resp.status;
9179
+ lastErrText = (await resp.text().catch(() => "")).slice(0, 200);
9180
+ if (attempt.label === "public-r2" && resp.status === 404) {
9181
+ ctx.logger?.info?.(`[MarketplaceInstallLocal] public-r2 miss for ${packageId}@${versionId}, falling back to cloud`);
9182
+ continue;
9183
+ }
9184
+ if (attempt.label === "public-r2" && resp.status >= 500) {
9185
+ ctx.logger?.warn?.(`[MarketplaceInstallLocal] public-r2 ${resp.status}, falling back to cloud`);
9186
+ continue;
9187
+ }
9188
+ break;
9189
+ }
9190
+ payload = await resp.json();
9191
+ lastErrStatus = 0;
9192
+ break;
9193
+ } catch (err) {
9194
+ if (attempt.label === "public-r2") {
9195
+ ctx.logger?.warn?.(`[MarketplaceInstallLocal] public-r2 fetch error: ${err?.message ?? err}, falling back to cloud`);
9196
+ continue;
9197
+ }
9046
9198
  return c.json({
9047
9199
  success: false,
9048
- error: { code: "cloud_fetch_failed", message: `Cloud returned ${resp.status}: ${text.slice(0, 200)}` }
9049
- }, resp.status === 404 ? 404 : 502);
9200
+ error: { code: "cloud_fetch_failed", message: err?.message ?? String(err) }
9201
+ }, 502);
9050
9202
  }
9051
- payload = await resp.json();
9052
- } catch (err) {
9203
+ }
9204
+ if (!payload) {
9053
9205
  return c.json({
9054
9206
  success: false,
9055
- error: { code: "cloud_fetch_failed", message: err?.message ?? String(err) }
9056
- }, 502);
9207
+ error: { code: "cloud_fetch_failed", message: `Cloud returned ${lastErrStatus}: ${lastErrText}` }
9208
+ }, lastErrStatus === 404 ? 404 : 502);
9057
9209
  }
9058
9210
  const data = payload?.data ?? payload;
9059
9211
  const manifest = data?.manifest;
@@ -9435,7 +9587,7 @@ var MarketplaceInstallLocalPlugin = class {
9435
9587
  }
9436
9588
  }
9437
9589
  if (opts.seedNow && datasets.length > 0) {
9438
- const multiTenant = String(process.env.OS_MULTI_TENANT ?? "false").toLowerCase() !== "false";
9590
+ const multiTenant = String(readEnvWithDeprecation5("OS_MULTI_ORG_ENABLED", "OS_MULTI_TENANT") ?? "false").toLowerCase() !== "false";
9439
9591
  try {
9440
9592
  const ql = ctx.getService("objectql");
9441
9593
  let metadata;
@@ -9586,6 +9738,7 @@ import {
9586
9738
  createRestApiPlugin
9587
9739
  } from "@objectstack/rest";
9588
9740
  export * from "@objectstack/core";
9741
+ import { readEnvWithDeprecation as readEnvWithDeprecation6, _resetEnvDeprecationWarnings } from "@objectstack/types";
9589
9742
  export {
9590
9743
  AppPlugin,
9591
9744
  ArtifactApiClient,
@@ -9623,6 +9776,7 @@ export {
9623
9776
  SandboxError,
9624
9777
  SeedLoaderService,
9625
9778
  UnimplementedScriptRunner,
9779
+ _resetEnvDeprecationWarnings,
9626
9780
  actionBodyRunnerFactory,
9627
9781
  backfillPlatformSsoClients,
9628
9782
  buildPlatformSsoRedirectUri,
@@ -9647,6 +9801,7 @@ export {
9647
9801
  mergeRuntimeModule,
9648
9802
  parseTraceparent,
9649
9803
  readArtifactSource,
9804
+ readEnvWithDeprecation6 as readEnvWithDeprecation,
9650
9805
  resolveCloudUrl,
9651
9806
  resolveDefaultArtifactPath,
9652
9807
  resolveErrorReporter,