@agilecustoms/envctl 1.8.0 → 1.9.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.
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from 'node:crypto';
1
2
  import { BusinessException, HttpException, NotFoundException } from '../exceptions.js';
2
3
  import { logger } from '../logger.js';
3
4
  const HOST = 'cli.maintenance.agilecustoms.com';
@@ -5,6 +6,7 @@ export function toUrl(path) {
5
6
  return `https://${HOST}/env-api${path}`;
6
7
  }
7
8
  export class HttpClient {
9
+ commandId = randomUUID();
8
10
  constructor() { }
9
11
  async post(path, body, options = {}) {
10
12
  options.method = 'POST';
@@ -20,10 +22,17 @@ export class HttpClient {
20
22
  }
21
23
  async fetch(path, options = {}) {
22
24
  const url = toUrl(path);
23
- if (!options.method) {
24
- options.method = 'GET';
25
- }
26
- logger.debug(`--> ${options.method} ${url} ${JSON.stringify(options)}`);
25
+ const headers = new Headers(options.headers);
26
+ headers.set('x-command-id', this.commandId);
27
+ const req = {
28
+ ...options,
29
+ method: options.method ?? 'GET',
30
+ headers,
31
+ };
32
+ logger.debug(`--> ${req.method} ${url} ${JSON.stringify({
33
+ ...req,
34
+ headers: Object.fromEntries(headers.entries()),
35
+ })}`);
27
36
  let response;
28
37
  try {
29
38
  response = await fetch(url, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilecustoms/envctl",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "node.js CLI client for manage environments",
5
5
  "keywords": [
6
6
  "terraform wrapper",