@withgateway/sdk 0.1.17 → 0.1.19

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.js CHANGED
@@ -339,7 +339,7 @@ function isIncludedInContentHash(relPath, includeAllRootFiles) {
339
339
  if (name.startsWith(".")) return false;
340
340
  if (parts.includes("__pycache__")) return false;
341
341
  if (dirParts.length === 0) {
342
- return includeAllRootFiles || name === "README.md" || name === "pyproject.toml" || name === "gateway-env.toml" || name.endsWith(".py");
342
+ return includeAllRootFiles || name === "README.md" || name === "pyproject.toml" || BROAD_ROOT_MARKERS.includes(name) || name.endsWith(".py");
343
343
  }
344
344
  return !dirParts.some(isExcludedDirComponent);
345
345
  }
@@ -350,7 +350,9 @@ function collectArchiveRelPaths(dir) {
350
350
  );
351
351
  }
352
352
  const out = [];
353
- const includeAllRootFiles = fs.existsSync(path.join(dir, "gateway-env.toml"));
353
+ const includeAllRootFiles = BROAD_ROOT_MARKERS.some(
354
+ (marker) => fs.existsSync(path.join(dir, marker))
355
+ );
354
356
  const walk = (rel) => {
355
357
  const abs = rel ? path.join(dir, rel) : dir;
356
358
  for (const entry of fs.readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
@@ -511,7 +513,7 @@ async function push(dir, opts = {}) {
511
513
  if (!fs.statSync(dir).isDirectory()) throw new Error(`Not a directory: ${dir}`);
512
514
  const localMeta = readLocalMeta(dir) ?? {};
513
515
  const branch = opts.branch ?? localMeta.branch ?? DEFAULT_BRANCH;
514
- const baseVersionId = localMeta.versionId ?? null;
516
+ const baseVersionId = opts.baseVersionId ?? localMeta.versionId ?? null;
515
517
  const contentHash = computeContentHash(dir);
516
518
  const pyproject = readPyproject(dir);
517
519
  const slug = opts.slug ?? pyproject.name ?? path.basename(path.resolve(dir));
@@ -664,7 +666,7 @@ async function createRef(slug, name, kind, versionId, options = {}) {
664
666
  ...versionId ? { versionId } : {}
665
667
  });
666
668
  }
667
- var import_node_crypto, import_node_zlib, fs, path, DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, ROOT_EXCLUDED_DIRS, sha256b64;
669
+ var import_node_crypto, import_node_zlib, fs, path, DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, ROOT_EXCLUDED_DIRS, BROAD_ROOT_MARKERS, sha256b64;
668
670
  var init_hub = __esm({
669
671
  "src/worlds/hub.ts"() {
670
672
  "use strict";
@@ -686,6 +688,7 @@ var init_hub = __esm({
686
688
  "outputs"
687
689
  ]);
688
690
  ROOT_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["dist", "build", "outputs", "__pycache__"]);
691
+ BROAD_ROOT_MARKERS = ["gateway-env.toml", "gateway-api-world.toml"];
689
692
  sha256b64 = (data) => (0, import_node_crypto.createHash)("sha256").update(data).digest("base64");
690
693
  }
691
694
  });
@@ -749,9 +752,24 @@ async function validateWorld(dir, opts) {
749
752
  "No branch to validate on: pass --branch or run inside a git checkout / GitHub Actions."
750
753
  );
751
754
  progress(`pushing ${dir} as ${opts.slug ?? "(pyproject name)"}@${branch}\u2026`);
755
+ let tipVersionId = null;
756
+ if (opts.slug) {
757
+ try {
758
+ const tip = await apiRequest(
759
+ options,
760
+ "POST",
761
+ "/api/public/benchmark-containers/resolve-version",
762
+ { slug: opts.slug, ref: branch }
763
+ );
764
+ tipVersionId = tip.versionId ?? null;
765
+ } catch {
766
+ tipVersionId = null;
767
+ }
768
+ }
752
769
  const pushed = await push(dir, {
753
770
  slug: opts.slug,
754
771
  branch,
772
+ baseVersionId: tipVersionId,
755
773
  message: `PR validation push (${provenance.commit?.slice(0, 12) ?? "local"})`,
756
774
  ...provenance.actor?.name ? { author: provenance.actor.name } : {},
757
775
  options
@@ -1108,7 +1126,7 @@ var require_package = __commonJS({
1108
1126
  "package.json"(exports2, module2) {
1109
1127
  module2.exports = {
1110
1128
  name: "@withgateway/sdk",
1111
- version: "0.1.17",
1129
+ version: "0.1.19",
1112
1130
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
1113
1131
  main: "./dist/index.js",
1114
1132
  module: "./dist/index.mjs",