@schwabyio/gta 0.11.0 → 0.12.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/dist/SPEC.md CHANGED
@@ -1297,7 +1297,8 @@ global project's root.
1297
1297
 
1298
1298
  - A secret with no value anywhere fails the run, naming it. An empty credential is never
1299
1299
  sent.
1300
- - Reports replace a secret's value with `[secret: NAME]`, wherever it appears.
1300
+ - Reports replace a secret's value with `[secret: NAME]`, wherever it appears. So does
1301
+ the desktop app where it shows a request as sent.
1301
1302
  - `.env` holds `NAME=value` lines. `#` starts a comment line, `export ` before a name is
1302
1303
  allowed, and a value may be quoted. It must not be committed.
1303
1304
 
@@ -54864,6 +54864,35 @@ function placeholdersOf(pattern, url2) {
54864
54864
  return found;
54865
54865
  }
54866
54866
 
54867
+ // ../../packages/core/src/model/layers.ts
54868
+ var partsOf = (doc) => ({
54869
+ headers: doc?.headers,
54870
+ settings: doc?.settings,
54871
+ before: doc?.before,
54872
+ tests: doc?.tests
54873
+ });
54874
+ function requestLayers(sources) {
54875
+ const layers = [];
54876
+ if (sources.endpoint) {
54877
+ layers.push({ kind: "endpoint-file", ...partsOf(sources.endpoint.file) });
54878
+ layers.push({ kind: "endpoint", ...partsOf(sources.endpoint.step) });
54879
+ }
54880
+ if (sources.base) layers.push({ kind: "base", ...partsOf(sources.base) });
54881
+ layers.push({ kind: "collection", ...partsOf(sources.collection) });
54882
+ if (sources.set) layers.push({ kind: "set", ...partsOf(sources.set) });
54883
+ layers.push({ kind: "step", before: sources.step.before, tests: sources.step.tests });
54884
+ return layers;
54885
+ }
54886
+ function foldLayers(layers) {
54887
+ let headers;
54888
+ let settings = {};
54889
+ for (const layer of layers) {
54890
+ if (layer.headers) headers = mergeHeaders(headers, layer.headers);
54891
+ settings = { ...settings, ...layer.settings };
54892
+ }
54893
+ return { headers, settings };
54894
+ }
54895
+
54867
54896
  // ../../packages/core/src/paths.ts
54868
54897
  import fs from "node:fs/promises";
54869
54898
  import nodePath from "node:path";
@@ -56901,6 +56930,37 @@ async function readDotEnv(near) {
56901
56930
  }
56902
56931
  }
56903
56932
 
56933
+ // ../../packages/core/src/vars/secrets.ts
56934
+ async function secretValues(context) {
56935
+ if (!context.environmentName) return [];
56936
+ try {
56937
+ const layer = await environmentLayer(context, context.environmentName);
56938
+ return (layer.secrets ?? []).flatMap((name) => {
56939
+ const value = layer.vars[name];
56940
+ return value === void 0 || value === null || String(value) === "" ? [] : [[name, String(value)]];
56941
+ }).sort((a, b) => b[1].length - a[1].length);
56942
+ } catch {
56943
+ return [];
56944
+ }
56945
+ }
56946
+ function redact(value, secrets) {
56947
+ if (secrets.length === 0) return value;
56948
+ const walk = (node2) => {
56949
+ if (typeof node2 === "string") {
56950
+ return secrets.reduce(
56951
+ (text, [name, secret]) => text.split(secret).join(`[secret: ${name}]`),
56952
+ node2
56953
+ );
56954
+ }
56955
+ if (Array.isArray(node2)) return node2.map(walk);
56956
+ if (node2 !== null && typeof node2 === "object") {
56957
+ return Object.fromEntries(Object.entries(node2).map(([key, inner]) => [key, walk(inner)]));
56958
+ }
56959
+ return node2;
56960
+ };
56961
+ return walk(value);
56962
+ }
56963
+
56904
56964
  // ../../packages/core/src/http/client.ts
56905
56965
  var import_undici = __toESM(require_undici(), 1);
56906
56966
  import { Buffer as Buffer2 } from "node:buffer";
@@ -57058,7 +57118,7 @@ function statusTextFor(status) {
57058
57118
  // ../../packages/core/src/run/multipart.ts
57059
57119
  import { Buffer as Buffer3 } from "node:buffer";
57060
57120
  import { randomBytes } from "node:crypto";
57061
- function partsOf(multipart) {
57121
+ function partsOf2(multipart) {
57062
57122
  return Object.entries(multipart).flatMap(
57063
57123
  ([name, field]) => (Array.isArray(field) ? field : [field]).map((part) => [name, part])
57064
57124
  );
@@ -57178,7 +57238,7 @@ function toBody(body) {
57178
57238
  };
57179
57239
  }
57180
57240
  if (body.multipart !== void 0) {
57181
- const parts = partsOf(body.multipart).map(
57241
+ const parts = partsOf2(body.multipart).map(
57182
57242
  ([name, part]) => typeof part === "string" ? { name, value: part } : "file" in part ? {
57183
57243
  name,
57184
57244
  value: "",
@@ -57236,7 +57296,7 @@ async function prepareRequest(written, body, scope, files) {
57236
57296
  }
57237
57297
  if (body?.multipart !== void 0) {
57238
57298
  const parts = [];
57239
- for (const [field, part] of partsOf(body.multipart)) {
57299
+ for (const [field, part] of partsOf2(body.multipart)) {
57240
57300
  const name = resolve(field);
57241
57301
  if (typeof part === "string") {
57242
57302
  parts.push({ name, value: resolve(part) });
@@ -57289,7 +57349,7 @@ var withoutGlobal = (path11) => path11.startsWith(GLOBAL_FILE) ? path11.slice(GL
57289
57349
  function bodyFiles(body) {
57290
57350
  if (body?.file !== void 0) return [{ what: "body.file", written: body.file }];
57291
57351
  if (body?.multipart === void 0) return [];
57292
- return partsOf(body.multipart).flatMap(
57352
+ return partsOf2(body.multipart).flatMap(
57293
57353
  ([field, part]) => typeof part !== "string" && "file" in part ? [{ what: `multipart field ${field}`, written: part.file }] : []
57294
57354
  );
57295
57355
  }
@@ -58649,13 +58709,7 @@ async function missingFiles(planned, collectionPath) {
58649
58709
  // ../../packages/core/src/run/runRequest.ts
58650
58710
  var itemText = (value) => value === null || ["string", "number", "boolean"].includes(typeof value) ? value : JSON.stringify(value) ?? String(value);
58651
58711
  function folded(layers, collection) {
58652
- let headers;
58653
- let settings = {};
58654
- for (const layer of layers) {
58655
- if (layer.script === "step" || layer.script === "use") continue;
58656
- if (layer.headers) headers = mergeHeaders(headers, layer.headers);
58657
- settings = { ...settings, ...layer.settings };
58658
- }
58712
+ const { headers, settings } = foldLayers(layers);
58659
58713
  return {
58660
58714
  ...collection,
58661
58715
  steps: [],
@@ -58663,12 +58717,15 @@ function folded(layers, collection) {
58663
58717
  ...Object.keys(settings).length > 0 ? { settings } : {}
58664
58718
  };
58665
58719
  }
58666
- var partsOf2 = (doc) => ({
58667
- headers: doc?.headers,
58668
- settings: doc?.settings,
58669
- before: doc?.before,
58670
- tests: doc?.tests
58671
- });
58720
+ var ROLES = {
58721
+ // An endpoint base's checks are defaults: the step's own of the same thing replace them.
58722
+ "endpoint-file": { script: "endpoint", label: "endpoint file", defaults: true },
58723
+ endpoint: { script: "endpoint", label: "endpoint", defaults: true },
58724
+ base: { script: "base", label: "base" },
58725
+ collection: { script: "collection", label: "collection" },
58726
+ set: { script: "set", label: "set" },
58727
+ step: { script: "step", label: "" }
58728
+ };
58672
58729
  var needsLibrary = (input2) => input2.checks === void 0 || input2.endpoints === void 0 || input2.tls === void 0 || input2.base === void 0 && input2.collection?.extends !== void 0;
58673
58730
  function endpointFor(step, endpoints) {
58674
58731
  if (isUseStep(step) || endpoints.length === 0) return null;
@@ -58750,25 +58807,13 @@ async function runRequest(input2) {
58750
58807
  });
58751
58808
  const marked = set2 ? set2.doc.steps.findIndex((s) => s.useTests === true) : -1;
58752
58809
  const useChecksThis = set2 ? set2.child === (marked >= 0 ? marked : set2.of - 1) : false;
58753
- const layers = [];
58754
- if (endpoint) {
58755
- layers.push({
58756
- script: "endpoint",
58757
- label: "endpoint file",
58758
- defaults: true,
58759
- ...partsOf2(endpoint.file)
58760
- });
58761
- layers.push({
58762
- script: "endpoint",
58763
- label: "endpoint",
58764
- defaults: true,
58765
- ...partsOf2(endpoint.step)
58766
- });
58767
- }
58768
- if (base2) layers.push({ script: "base", label: "base", ...partsOf2(base2) });
58769
- layers.push({ script: "collection", label: "collection", ...partsOf2(input2.collection) });
58770
- if (set2) layers.push({ script: "set", label: "set", ...partsOf2(set2.doc) });
58771
- layers.push({ script: "step", label: "", before: step.before, tests: step.tests });
58810
+ const layers = requestLayers({
58811
+ endpoint,
58812
+ base: base2,
58813
+ collection: input2.collection,
58814
+ set: set2?.doc,
58815
+ step
58816
+ }).map(({ kind, ...parts }) => ({ ...ROLES[kind], ...parts }));
58772
58817
  if (useChecksThis && set2?.useTests)
58773
58818
  layers.push({ script: "use", label: "use", tests: set2.useTests });
58774
58819
  const collection = folded(layers, input2.collection);
@@ -59516,7 +59561,7 @@ async function runJob(job) {
59516
59561
  });
59517
59562
  return {
59518
59563
  ok: true,
59519
- summary: redact(summary, await secretsOf(context)),
59564
+ summary: redact(summary, await secretValues(context)),
59520
59565
  steps: refs,
59521
59566
  data: loaded.dataFile ? { file: `${COLLECTIONS_DIR}/${loaded.dataFile.relativePath}`, rows: loaded.dataFile.rows } : null
59522
59567
  };
@@ -59524,35 +59569,6 @@ async function runJob(job) {
59524
59569
  return { ok: false, message: cause instanceof Error ? cause.message : String(cause) };
59525
59570
  }
59526
59571
  }
59527
- async function secretsOf(context) {
59528
- if (!context.environmentName) return [];
59529
- try {
59530
- const layer = await environmentLayer(context, context.environmentName);
59531
- return (layer.secrets ?? []).flatMap((name) => {
59532
- const value = layer.vars[name];
59533
- return value === void 0 || value === null || String(value) === "" ? [] : [[name, String(value)]];
59534
- }).sort((a, b) => b[1].length - a[1].length);
59535
- } catch {
59536
- return [];
59537
- }
59538
- }
59539
- function redact(value, secrets) {
59540
- if (secrets.length === 0) return value;
59541
- const walk = (node2) => {
59542
- if (typeof node2 === "string") {
59543
- return secrets.reduce(
59544
- (text, [name, secret]) => text.split(secret).join(`[secret: ${name}]`),
59545
- node2
59546
- );
59547
- }
59548
- if (Array.isArray(node2)) return node2.map(walk);
59549
- if (node2 !== null && typeof node2 === "object") {
59550
- return Object.fromEntries(Object.entries(node2).map(([key, inner]) => [key, walk(inner)]));
59551
- }
59552
- return node2;
59553
- };
59554
- return walk(value);
59555
- }
59556
59572
  async function stepLines(file2) {
59557
59573
  const lines = { setup: [], steps: [], teardown: [] };
59558
59574
  try {
package/dist/gta.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  samePath,
29
29
  stepsForTags,
30
30
  unattempted
31
- } from "./chunks/chunk-OM3ZR56O.js";
31
+ } from "./chunks/chunk-3NSHWS24.js";
32
32
 
33
33
  // src/args.ts
34
34
  var UsageError = class extends Error {
@@ -1269,7 +1269,7 @@ function coerce(key, value, where) {
1269
1269
  }
1270
1270
 
1271
1271
  // src/main.ts
1272
- var VERSION = true ? "0.11.0" : "0.0.0-dev";
1272
+ var VERSION = true ? "0.12.0" : "0.0.0-dev";
1273
1273
  var JUNIT_DIR = "junit";
1274
1274
  var JUNIT_FILE = "junit.xml";
1275
1275
  var HTML_DIR = "html";
package/dist/worker.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire as __gtaCreateRequire } from 'node:module';
3
3
  const require = __gtaCreateRequire(import.meta.url);
4
4
  import {
5
5
  runJob
6
- } from "./chunks/chunk-OM3ZR56O.js";
6
+ } from "./chunks/chunk-3NSHWS24.js";
7
7
 
8
8
  // src/worker.ts
9
9
  import { parentPort, workerData } from "node:worker_threads";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schwabyio/gta",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "description": "gta, the Gravity Test Automation command-line runner: HTTP API tests written as YAML files, run from a terminal or CI.",
6
6
  "keywords": [