@constructor-io/constructorio-connect-cli 1.9.0 → 1.9.2

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.
@@ -4,18 +4,18 @@
4
4
  "description": "🔧 Repository to interface with the Constructor Connect ecosystem.",
5
5
  "scripts": {
6
6
  "test": "TZ=UTC node --trace-warnings node_modules/.bin/jest --runInBand --config=jest.config.js",
7
- "lint": "eslint",
8
- "lint:fix": "eslint --fix",
7
+ "lint": "eslint .",
8
+ "lint:fix": "eslint . --fix",
9
9
  "execute": "constructorio-connect-cli execute",
10
10
  "deploy": "constructorio-connect-cli deploy",
11
11
  "generate-fixture": "constructorio-connect-cli generate-fixture",
12
12
  "trigger-catalog-sync": "constructorio-connect-cli trigger-catalog-sync"
13
13
  },
14
14
  "devDependencies": {
15
- "@babel/preset-env": "^7.24.8",
16
- "@stylistic/eslint-plugin-js": "^2.4.0",
17
- "@types/jest": "^29.5.12",
18
- "eslint": "^8.47.0",
15
+ "@babel/preset-env": "^7.26.7",
16
+ "@stylistic/eslint-plugin-js": "^2.13.0",
17
+ "@types/jest": "^29.5.14",
18
+ "eslint": "^9.19.0",
19
19
  "jest": "^29.7.0"
20
20
  },
21
21
  "keywords": [],
@@ -2,4 +2,5 @@
2
2
  * This template allows you to customize your item data.
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-template-types-transformation-templates#item-template
4
4
  */
5
- {}
5
+
6
+ {}
@@ -26,6 +26,10 @@ export declare class Execute extends Command {
26
26
  static examples: string[];
27
27
  input: ExecuteInputFlags;
28
28
  run(): Promise<void>;
29
+ /**
30
+ * Returns the template type, which is always equal to the folder name of the template path.
31
+ */
32
+ private getTemplateType;
29
33
  private parseFlags;
30
34
  private getTemplateExecInput;
31
35
  private calculateConnectionId;
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,E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"use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Execute = exports.executePromptMessages = void 0;
7
+ const os_1 = __importDefault(require("os"));
4
8
  const core_1 = require("@oclif/core");
5
9
  const errors_1 = require("@oclif/core/lib/errors");
6
10
  const file_loaders_1 = require("../helpers/file-loaders");
@@ -55,7 +59,6 @@ class Execute extends core_1.Command {
55
59
  const config = await (0, ux_action_1.uxAction)("📡 Reading your config", async () => {
56
60
  return await (0, config_1.getRepositoryConfigFile)();
57
61
  })();
58
- core_1.ux.log("\n");
59
62
  result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
60
63
  template: (0, file_loaders_1.getJSONataTemplate)(templateInput.templatePath).toString(),
61
64
  helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
@@ -64,8 +67,8 @@ class Execute extends core_1.Command {
64
67
  ? (0, file_loaders_1.getExternalDataFixture)(templateInput.externalDataPath)
65
68
  : {},
66
69
  connectionId: templateInput.connectionId,
70
+ templateType: this.getTemplateType(templateInput.templatePath),
67
71
  });
68
- core_1.ux.log("\n");
69
72
  (0, render_template_result_1.renderTemplateResult)(result);
70
73
  if (!result?.success) {
71
74
  this.exit(1);
@@ -75,6 +78,13 @@ class Execute extends core_1.Command {
75
78
  (0, render_repeat_input_1.renderRepeatInput)(this, this.input);
76
79
  }
77
80
  }
81
+ /**
82
+ * Returns the template type, which is always equal to the folder name of the template path.
83
+ */
84
+ getTemplateType(templatePath) {
85
+ const platformFileDelimiter = os_1.default.platform() === "win32" ? "\\" : "/";
86
+ return templatePath.split(platformFileDelimiter)?.[0];
87
+ }
78
88
  async parseFlags() {
79
89
  const { flags } = await this.parse(Execute);
80
90
  if (flags["template-path"]) {
@@ -1 +1 @@
1
- {"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,YAAY,qEAMf,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAoBjE"}
1
+ {"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,YAAY,qEAMf,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAqBjE"}
@@ -39,6 +39,7 @@ async function executeTemplate(options) {
39
39
  template: (0, file_loaders_1.getJSONataTemplate)(name).toString(),
40
40
  helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
41
41
  connectionId: connection.id,
42
+ templateType: options.type,
42
43
  targetData: fixture,
43
44
  showLogs: false,
44
45
  externalData,
@@ -1 +1 @@
1
- {"version":3,"file":"ux-action.d.ts","sourceRoot":"","sources":["../../src/helpers/ux-action.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,aAEmB,UAAU,CAAC,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CAAC,CAyBxD"}
1
+ {"version":3,"file":"ux-action.d.ts","sourceRoot":"","sources":["../../src/helpers/ux-action.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,aAEmB,UAAU,CAAC,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CAAC,CA0BxD"}
@@ -9,9 +9,9 @@ function uxAction(title, func) {
9
9
  try {
10
10
  result = func(...args);
11
11
  }
12
- catch (e) {
12
+ catch (error) {
13
13
  spinner.error({ text: title, mark: "❌" });
14
- throw e;
14
+ throw error;
15
15
  }
16
16
  if (result?.then) {
17
17
  result
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/http/http-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAuB,MAAM,OAAO,CAAC;AA0B5C;;GAEG;AACH,wBAAsB,aAAa,iCAwDlC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,WAK7C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,cAQjE"}
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/http/http-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAuB,MAAM,OAAO,CAAC;AA6B5C;;GAEG;AACH,wBAAsB,aAAa,iCAwDlC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,WAK7C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,cAcjE"}
@@ -43,6 +43,7 @@ const errors_1 = require("@oclif/core/lib/errors");
43
43
  const axios_1 = __importStar(require("axios"));
44
44
  const axios_retry_1 = __importDefault(require("axios-retry"));
45
45
  const get_connect_token_1 = require("../customer/get-connect-token");
46
+ const render_tip_1 = require("../rendering/render-tip");
46
47
  const version_1 = __importDefault(require("../version"));
47
48
  const RETRY_IGNORED_HTTP_STATUS_CODES = [
48
49
  /**
@@ -61,6 +62,7 @@ const RETRY_IGNORED_HTTP_STATUS_CODES = [
61
62
  */
62
63
  403,
63
64
  ];
65
+ const MAX_RETRIES = 3;
64
66
  /**
65
67
  * @returns An axios instance with the correct base URL and auth token.
66
68
  */
@@ -75,7 +77,7 @@ async function getHttpClient() {
75
77
  },
76
78
  });
77
79
  (0, axios_retry_1.default)(instance, {
78
- retries: 3,
80
+ retries: MAX_RETRIES,
79
81
  /**
80
82
  * Avoid retrying requests that failed because of an authentication error.
81
83
  */
@@ -120,6 +122,11 @@ function checkRetryCondition(error) {
120
122
  */
121
123
  function calculateRetryDelay(retryCount, error) {
122
124
  const retryAfterMs = error?.response?.status === 429 ? 2000 : 500;
123
- console.log(`🧐 Retrying request after ${retryAfterMs}ms. Currently on retry number ${retryCount}.`);
125
+ (0, render_tip_1.renderTip)([
126
+ `Retrying request after ${retryAfterMs}ms, currently on retry number ${retryCount}/${MAX_RETRIES}.`,
127
+ ], {
128
+ breakFirstLine: true,
129
+ emoji: "🤔",
130
+ });
124
131
  return retryAfterMs;
125
132
  }
@@ -1,11 +1,12 @@
1
1
  import { type TemplateExecutionSuccessResponse, type TemplateExecutionErrorResponse } from "../types";
2
- export declare function sendTemplateExecuteRequest({ template, helpers, targetData, externalData, connectionId, showLogs, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
2
+ export declare function sendTemplateExecuteRequest({ template, helpers, targetData, externalData, connectionId, templateType, showLogs, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
3
3
  interface Args {
4
4
  template: string;
5
5
  helpers: string;
6
6
  targetData: any;
7
7
  externalData: any;
8
8
  connectionId: string;
9
+ templateType: string;
9
10
  showLogs?: boolean;
10
11
  }
11
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"send-template-execute-request.d.ts","sourceRoot":"","sources":["../../src/http/send-template-execute-request.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACpC,MAAM,UAAU,CAAC;AAIlB,wBAAsB,0BAA0B,CAAC,EAC/C,QAAQ,EACR,OAAO,EACP,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,QAAe,GAChB,EAAE,IAAI,GAAG,OAAO,CACf,gCAAgC,GAAG,8BAA8B,CAClE,CA6BA;AAED,UAAU,IAAI;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,GAAG,CAAC;IAChB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"send-template-execute-request.d.ts","sourceRoot":"","sources":["../../src/http/send-template-execute-request.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACpC,MAAM,UAAU,CAAC;AAIlB,wBAAsB,0BAA0B,CAAC,EAC/C,QAAQ,EACR,OAAO,EACP,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,QAAe,GAChB,EAAE,IAAI,GAAG,OAAO,CACf,gCAAgC,GAAG,8BAA8B,CAClE,CA8BA;AAED,UAAU,IAAI;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,GAAG,CAAC;IAChB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -5,15 +5,16 @@ const axios_1 = require("axios");
5
5
  const errors_1 = require("@oclif/core/lib/errors");
6
6
  const ux_action_1 = require("../helpers/ux-action");
7
7
  const http_client_1 = require("./http-client");
8
- async function sendTemplateExecuteRequest({ template, helpers, targetData, externalData, connectionId, showLogs = true, }) {
8
+ async function sendTemplateExecuteRequest({ template, helpers, targetData, externalData, connectionId, templateType, showLogs = true, }) {
9
9
  const client = await (0, http_client_1.getHttpClient)();
10
10
  const httpRequest = async () => {
11
11
  return (await client.patch("templates/standalone/execute", {
12
- raw_template: template,
13
12
  helpers,
13
+ raw_template: template,
14
14
  target_data: targetData,
15
15
  external_data: externalData,
16
16
  connection_id: connectionId,
17
+ template_type: templateType,
17
18
  })).data;
18
19
  };
19
20
  try {
@@ -20,7 +20,7 @@ function isTemplateFailure(result) {
20
20
  return !!result.error;
21
21
  }
22
22
  function renderTemplateSuccess(result) {
23
- core_1.ux.log(kleur_1.default.bold(kleur_1.default.green("🏁 Template executed successfully! 🏁 ") + "⬇️ Result ⬇️") + `\n\n${(0, cli_highlight_1.default)((0, json_stringify_pretty_compact_1.default)(result.data), { language: "json" })}\n`);
23
+ core_1.ux.log(kleur_1.default.bold(kleur_1.default.green("🏁 Template executed successfully! 🏁 ") + "⬇️ Result ⬇️") + `\n\n${(0, cli_highlight_1.default)((0, json_stringify_pretty_compact_1.default)(result.data), { language: "json" })}`);
24
24
  }
25
25
  function renderTemplateError(result) {
26
26
  core_1.ux.log(kleur_1.default.bold(kleur_1.default.red("💥 Error while executing your template: ") + "⬇️ Error ⬇️"));
@@ -2,5 +2,10 @@
2
2
  * Prints a tip to the user to provide helpful information.
3
3
  * It'll automatically insert the tip emoji (💡) and auto align the lines on the terminal.
4
4
  */
5
- export declare function renderTip(lines: string[]): void;
5
+ export declare function renderTip(lines: string[], { breakFirstLine, emoji }?: Options): void;
6
+ interface Options {
7
+ emoji?: string;
8
+ breakFirstLine?: boolean;
9
+ }
10
+ export {};
6
11
  //# sourceMappingURL=render-tip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-tip.d.ts","sourceRoot":"","sources":["../../src/rendering/render-tip.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAMxC"}
1
+ {"version":3,"file":"render-tip.d.ts","sourceRoot":"","sources":["../../src/rendering/render-tip.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EAAE,EACf,EAAE,cAAsB,EAAE,KAAY,EAAE,GAAE,OAAY,QAavD;AAED,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
@@ -10,12 +10,20 @@ const kleur_1 = __importDefault(require("kleur"));
10
10
  * New line character with the necessary spacing to align the text on the terminal.
11
11
  */
12
12
  const NEW_LINE_WITH_SPACING = "\n ";
13
+ /**
14
+ * New line character with spacing to align on the terminal, when breaking the first line.
15
+ */
16
+ const FIRST_LINE_WITH_SPACING = "\n ";
13
17
  /**
14
18
  * Prints a tip to the user to provide helpful information.
15
19
  * It'll automatically insert the tip emoji (💡) and auto align the lines on the terminal.
16
20
  */
17
- function renderTip(lines) {
18
- lines[0] = `💡 ${lines[0]}`;
19
- const message = lines.join(NEW_LINE_WITH_SPACING);
21
+ function renderTip(lines, { breakFirstLine = false, emoji = "💡" } = {}) {
22
+ lines[0] = `${emoji} ${lines[0]}`;
23
+ let message = "";
24
+ if (breakFirstLine) {
25
+ message += FIRST_LINE_WITH_SPACING;
26
+ }
27
+ message += lines.join(NEW_LINE_WITH_SPACING);
20
28
  core_1.ux.log(kleur_1.default.gray(message));
21
29
  }
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.9.0";
1
+ declare const _default: "1.9.2";
2
2
  export default _default;
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.9.0';
3
+ exports.default = '1.9.2';
@@ -171,5 +171,5 @@
171
171
  ]
172
172
  }
173
173
  },
174
- "version": "1.9.0"
174
+ "version": "1.9.2"
175
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "CLI tool to enable users to interface with the Constructor Connect Ecosystem",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -82,7 +82,7 @@
82
82
  "@types/mock-fs": "^4.13.4",
83
83
  "cross-env": "^7.0.3",
84
84
  "eslint": "^8.57.0",
85
- "eslint-config-prettier": "^9.1.0",
85
+ "eslint-config-prettier": "^10.0.1",
86
86
  "eslint-config-standard-with-typescript": "^43.0.1",
87
87
  "eslint-plugin-import": "^2.29.1",
88
88
  "eslint-plugin-prettier": "^5.1.3",