@piyushdoorwar/yamlet 1.1.2 → 1.1.3

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.
Files changed (2) hide show
  1. package/dist/yamlet.js +11 -4
  2. package/package.json +1 -1
package/dist/yamlet.js CHANGED
@@ -283,7 +283,13 @@ function newCollection(partial = {}) {
283
283
  function newEnvironment(partial = {}) {
284
284
  return { id: newId(), name: "New Environment", variables: [], ...partial };
285
285
  }
286
- var YAMLET_USER_AGENT = "Yamlet/1.0.0";
286
+ var yamletVersion = "dev";
287
+ function setYamletVersion(version) {
288
+ yamletVersion = version.trim().replace(/^v(?=\d)/, "") || "dev";
289
+ }
290
+ function yamletUserAgent() {
291
+ return `Yamlet/${yamletVersion}`;
292
+ }
287
293
 
288
294
  // core/src/oauth2.ts
289
295
  import { request } from "undici";
@@ -762,7 +768,7 @@ function buildRequest(request3, opts) {
762
768
  );
763
769
  const query = (request3.queryParams ?? []).filter((p) => p.enabled !== false && p.key?.trim()).map((p) => ({ key: r(p.key), value: r(p.value) }));
764
770
  url = appendQuery(url, query);
765
- const headers = [{ key: "User-Agent", value: YAMLET_USER_AGENT, enabled: true }];
771
+ const headers = [{ key: "User-Agent", value: yamletUserAgent(), enabled: true }];
766
772
  for (const h of request3.headers ?? []) {
767
773
  if (h.enabled === false || !h.key?.trim()) continue;
768
774
  const key = r(h.key).trim();
@@ -1683,7 +1689,7 @@ function errorResponse(base, message) {
1683
1689
  async function scriptSend(spec, input, dispatcher) {
1684
1690
  const base = emptyResponse(spec.method, spec.url);
1685
1691
  try {
1686
- const headers = spec.headers.some((h) => h.key.toLowerCase() === "user-agent") ? spec.headers : [{ key: "User-Agent", value: YAMLET_USER_AGENT, enabled: true }, ...spec.headers];
1692
+ const headers = spec.headers.some((h) => h.key.toLowerCase() === "user-agent") ? spec.headers : [{ key: "User-Agent", value: yamletUserAgent(), enabled: true }, ...spec.headers];
1687
1693
  const ex = await exchange({ url: spec.url, method: spec.method, headers, body: spec.body, dispatcher, signal: input.signal, followRedirects: true, jar: input.cookieJar });
1688
1694
  const contentType = headerValue(ex.headers, "content-type") ?? "";
1689
1695
  const textual = isTextual(contentType, ex.bytes);
@@ -3351,7 +3357,8 @@ function ensureUniqueIds(ws, rel) {
3351
3357
  }
3352
3358
 
3353
3359
  // cli/src/index.ts
3354
- var VERSION = true ? "0.0.0-dev" : "0.0.0-dev";
3360
+ var VERSION = true ? "1.1.3" : "0.0.0-dev";
3361
+ setYamletVersion(VERSION);
3355
3362
  var CliError = class extends Error {
3356
3363
  };
3357
3364
  var USAGE = `Yamlet CLI: run Yamlet API collections headlessly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piyushdoorwar/yamlet",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Run Yamlet API collections (Git-friendly YAML) from the command line or CI.",
5
5
  "type": "module",
6
6
  "bin": {