@celonis/content-cli 0.5.0 → 0.5.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/content-cli.js CHANGED
@@ -5,7 +5,7 @@
5
5
  if (v !== undefined) module.exports = v;
6
6
  }
7
7
  else if (typeof define === "function" && define.amd) {
8
- define(["require", "exports", "./util/logger", "semver/functions/satisfies", "commander"], factory);
8
+ define(["require", "exports", "./util/logger", "semver/functions/satisfies", "commander", "./util/version"], factory);
9
9
  }
10
10
  })(function (require, exports) {
11
11
  "use strict";
@@ -13,8 +13,7 @@
13
13
  const logger_1 = require("./util/logger");
14
14
  const semverSatisfies = require("semver/functions/satisfies");
15
15
  const program = require("commander");
16
- // tslint:disable-next-line:no-var-requires
17
- const { version } = require("./package.json");
16
+ const version_1 = require("./util/version");
18
17
  const requiredVersion = ">=10.10.0";
19
18
  if (!semverSatisfies(process.version, requiredVersion)) {
20
19
  logger_1.logger.error(`Node version ${process.version} not supported. Please upgrade your node version to ${requiredVersion}`);
@@ -27,7 +26,7 @@
27
26
  program.command("push", "Commands to push content.");
28
27
  program.command("update", "Commands to update content.");
29
28
  program.command("list", "Commands to list content.").alias("ls");
30
- program.version(version);
29
+ program.version(version_1.VersionUtils.getCurrentCliVersion());
31
30
  program.parse(process.argv);
32
31
  if (!process.argv.slice(2).length) {
33
32
  program.outputHelp();
@@ -13,6 +13,7 @@ declare class HttpClientServiceV2 {
13
13
  private handleBadRequest;
14
14
  private makeOptions;
15
15
  private makeOptionsJson;
16
+ private buildHeaders;
16
17
  private buildAuthorizationHeaders;
17
18
  }
18
19
  export declare const httpClientV2: HttpClientServiceV2;
@@ -0,0 +1,7 @@
1
+ export declare class TracingUtils {
2
+ static getTracingHeaders(): {
3
+ [key: string]: string;
4
+ };
5
+ private static getTraceId;
6
+ private static generateId;
7
+ }
@@ -0,0 +1,3 @@
1
+ export declare class VersionUtils {
2
+ static getCurrentCliVersion(): string;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celonis/content-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "CLI Tool to help manage content in Celonis EMS",
5
5
  "main": "content-cli.js",
6
6
  "bin": {
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  if (v !== undefined) module.exports = v;
14
14
  }
15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "../interfaces/profile.interface", "request", "./context.service", "../util/logger", "querystring"], factory);
16
+ define(["require", "exports", "../interfaces/profile.interface", "request", "./context.service", "../util/logger", "querystring", "../util/tracing", "../util/version"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -23,6 +23,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  const context_service_1 = require("./context.service");
24
24
  const logger_1 = require("../util/logger");
25
25
  const querystring = require("querystring");
26
+ const tracing_1 = require("../util/tracing");
27
+ const version_1 = require("../util/version");
26
28
  class HttpClientServiceV2 {
27
29
  get(url) {
28
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -115,7 +117,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
115
117
  }
116
118
  makeFileDownloadOptions(profile) {
117
119
  return {
118
- headers: this.buildAuthorizationHeaders(profile),
120
+ headers: this.buildHeaders(profile),
119
121
  responseType: "binary",
120
122
  };
121
123
  }
@@ -150,16 +152,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
150
152
  }
151
153
  makeOptions(profile, body = {}) {
152
154
  const options = {
153
- headers: this.buildAuthorizationHeaders(profile),
155
+ headers: this.buildHeaders(profile),
154
156
  };
155
157
  return Object.assign(options, body);
156
158
  }
157
159
  makeOptionsJson(profile, body, contentType) {
158
160
  return {
159
- headers: this.buildAuthorizationHeaders(profile, contentType),
161
+ headers: this.buildHeaders(profile, contentType),
160
162
  body: body,
161
163
  };
162
164
  }
165
+ buildHeaders(profile, contentType) {
166
+ return Object.assign(Object.assign(Object.assign({}, this.buildAuthorizationHeaders(profile, contentType)), tracing_1.TracingUtils.getTracingHeaders()), { "User-Agent": "content-cli v" + version_1.VersionUtils.getCurrentCliVersion() });
167
+ }
163
168
  buildAuthorizationHeaders(profile, contentType) {
164
169
  const authenticationType = profile.authenticationType || profile_interface_1.AuthenticationType.BEARER;
165
170
  return {
@@ -0,0 +1,28 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "crypto"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const crypto = require("crypto");
13
+ class TracingUtils {
14
+ static getTracingHeaders() {
15
+ return {
16
+ "x-datadog-trace-id": this.getTraceId(),
17
+ "x-datadog-sampling-priority": "1",
18
+ };
19
+ }
20
+ static getTraceId() {
21
+ return process.env.TRACE_ID || this.generateId();
22
+ }
23
+ static generateId() {
24
+ return crypto.randomBytes(8).toString("hex");
25
+ }
26
+ }
27
+ exports.TracingUtils = TracingUtils;
28
+ });
@@ -0,0 +1,20 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ // tslint:disable-next-line:no-var-requires
13
+ const { version } = require("./../package.json");
14
+ class VersionUtils {
15
+ static getCurrentCliVersion() {
16
+ return version;
17
+ }
18
+ }
19
+ exports.VersionUtils = VersionUtils;
20
+ });