@constructor-io/constructorio-connect-cli 1.13.3 → 1.14.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.
@@ -207,7 +207,7 @@ EXAMPLES
207
207
 
208
208
  To implement your very own transformers, you just need to edit the `.jsonata` files inside the `templates` folder.
209
209
 
210
- Keep in mind that the template will have access to `externalData` and `targetData`. You can use the `targetData` to access the data that is being ingested, and `externalData` to access the data available in the connector.
210
+ Keep in mind that the template will have access to `external` and `data`. You can use the `data` to access the data that is being ingested, and `external` to access the data available in the connector.
211
211
 
212
212
  Note that all template files must return the expected data types. To know which properties you can override inside `item`, `variation` or `item_group`, take a look into the type definitions:
213
213
 
@@ -227,7 +227,7 @@ We can make this happen returning `{ "remove": true }` whenever we find an item
227
227
  (
228
228
  /* item.jsonata */
229
229
 
230
- targetData.visible
230
+ data.visible
231
231
  ? { "active": true } /* Visible = true => we simply ingest it as an active item */
232
232
  : { "remove": true } /* Visible = false => we don't even ingest it */
233
233
  )
@@ -299,7 +299,7 @@ In the `templates/item.jsonata` file, you can customize how items are transforme
299
299
  "metadata": [
300
300
  {
301
301
  "key": 'id',
302
- "value": targetData.id
302
+ "value": data.id
303
303
  }
304
304
  ]
305
305
  }
@@ -351,8 +351,8 @@ In the `templates/grouping.jsonata` file, you can customize how item groups are
351
351
  ```js
352
352
  /* grouping.jsonata */
353
353
  (
354
- $color := targetData.color;
355
- $id := targetData.id;
354
+ $color := data.color;
355
+ $id := data.id;
356
356
 
357
357
  {
358
358
  "id": $join([$id, '-', $color]);
@@ -365,8 +365,8 @@ We also need to update variations to point to the correct item:
365
365
  ```js
366
366
  /* variation.jsonata */
367
367
  {
368
- $color := targetData.color;
369
- $parentId := targetData.parent.id;
368
+ $color := data.color;
369
+ $parentId := data.parent.id;
370
370
 
371
371
  {
372
372
  "item_id": $join([$parentId, '-', $color]);
@@ -2,7 +2,7 @@ import { RefreshConnectionsCommand } from "./refresh-connections-command";
2
2
  export declare const executePromptMessages: {
3
3
  readonly template: "Select a template to execute";
4
4
  readonly fixture: "Select a catalog fixture to run the template against";
5
- readonly externalData: "Select external data to run the template against";
5
+ readonly external: "Select external data to run the template against";
6
6
  readonly connection: "Select a connection to execute templates against";
7
7
  };
8
8
  /**
@@ -23,7 +23,7 @@ const refresh_connections_command_1 = require("./refresh-connections-command");
23
23
  exports.executePromptMessages = {
24
24
  template: "Select a template to execute",
25
25
  fixture: "Select a catalog fixture to run the template against",
26
- externalData: "Select external data to run the template against",
26
+ external: "Select external data to run the template against",
27
27
  connection: "Select a connection to execute templates against",
28
28
  };
29
29
  class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
@@ -60,9 +60,9 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
60
60
  const result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
61
61
  template: (0, file_loaders_1.getJSONataTemplate)(templateInput.templatePath).toString(),
62
62
  helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
63
- targetData: (0, file_loaders_1.getCatalogFixture)(templateInput.fixturePath),
64
- externalData: templateInput.externalDataPath
65
- ? (0, file_loaders_1.getExternalDataFixture)(templateInput.externalDataPath)
63
+ data: (0, file_loaders_1.getCatalogFixture)(templateInput.fixturePath),
64
+ external: templateInput.externalPath
65
+ ? (0, file_loaders_1.getExternalFixture)(templateInput.externalPath)
66
66
  : {},
67
67
  connectionId: templateInput.connectionId,
68
68
  templateType: (0, extract_template_type_1.extractTemplateType)(templateInput.templatePath),
@@ -116,11 +116,11 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
116
116
  });
117
117
  }
118
118
  if (!this.input["external-data-path"]) {
119
- const choices = (0, get_external_data_files_1.getExternalDataFiles)();
119
+ const choices = (0, get_external_data_files_1.getExternalFiles)();
120
120
  if (choices.length) {
121
121
  this.input["external-data-path"] = await (0, render_prompt_1.renderPrompt)({
122
122
  choices,
123
- promptMessage: exports.executePromptMessages.externalData,
123
+ promptMessage: exports.executePromptMessages.external,
124
124
  emptyMessage: "No external data found",
125
125
  });
126
126
  }
@@ -132,7 +132,7 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
132
132
  return {
133
133
  templatePath: this.input["template-path"],
134
134
  fixturePath: this.input["fixture-path"],
135
- externalDataPath: this.input["external-data-path"] ?? "",
135
+ externalPath: this.input["external-data-path"] ?? "",
136
136
  connectionId,
137
137
  };
138
138
  }
@@ -3,11 +3,11 @@ export interface ExecuteTemplateArgs {
3
3
  type: (typeof TYPE_OPTIONS)[number];
4
4
  name: string;
5
5
  fixture?: Record<string, unknown>;
6
- externalData?: Record<string, unknown>;
6
+ external?: Record<string, unknown>;
7
7
  connectionId?: string;
8
8
  }
9
9
  /**
10
- * This will execute a template with the given type, name, fixture, and externalData.
10
+ * This will execute a template with the given type, name, fixture, and external.
11
11
  * It returns an object with the result of the execution, or throws if there is an error.
12
12
  *
13
13
  * The template will be executed against the first connection found, or you can override
@@ -1 +1 @@
1
- {"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"AAWA,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,gCAuBjE"}
1
+ {"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"AAWA,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,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAuBjE"}
@@ -21,7 +21,7 @@ exports.TYPE_OPTIONS = [
21
21
  "grouping",
22
22
  ];
23
23
  /**
24
- * This will execute a template with the given type, name, fixture, and externalData.
24
+ * This will execute a template with the given type, name, fixture, and external.
25
25
  * It returns an object with the result of the execution, or throws if there is an error.
26
26
  *
27
27
  * The template will be executed against the first connection found, or you can override
@@ -33,7 +33,7 @@ exports.TYPE_OPTIONS = [
33
33
  * @returns Promise<Record<string, any>>
34
34
  */
35
35
  async function executeTemplate(options) {
36
- const { name, fixture, externalData } = initializeOptions(options);
36
+ const { name, fixture, external } = initializeOptions(options);
37
37
  const connection = await getConnection(options);
38
38
  const config = await (0, config_1.getRepositoryConfigFile)();
39
39
  const result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
@@ -41,9 +41,9 @@ async function executeTemplate(options) {
41
41
  helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
42
42
  connectionId: connection.id,
43
43
  templateType: options.type,
44
- targetData: fixture,
44
+ data: fixture,
45
45
  showLogs: false,
46
- externalData,
46
+ external,
47
47
  });
48
48
  if (!result.success) {
49
49
  throw new Error(`Error executing template: ${result.error.message}`);
@@ -73,8 +73,8 @@ function initializeOptions(options) {
73
73
  if (!options.fixture) {
74
74
  options.fixture = {};
75
75
  }
76
- if (!options.externalData) {
77
- options.externalData = {};
76
+ if (!options.external) {
77
+ options.external = {};
78
78
  }
79
79
  return options;
80
80
  }
@@ -1,6 +1,6 @@
1
1
  import fs from "fs-extra";
2
2
  export declare const getCatalogFixture: (name: string, options?: fs.JsonReadOptions) => any;
3
- export declare const getExternalDataFixture: (name: string, options?: fs.JsonReadOptions) => any;
3
+ export declare const getExternalFixture: (name: string, options?: fs.JsonReadOptions) => any;
4
4
  export declare const getJSONataTemplate: (name: string, options?: BufferEncoding | (fs.ObjectEncodingOptions & {
5
5
  flag?: string | undefined;
6
6
  }) | null | undefined) => string | Buffer<ArrayBufferLike>;
@@ -1 +1 @@
1
- {"version":3,"file":"file-loaders.d.ts","sourceRoot":"","sources":["../../src/helpers/file-loaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,eAAO,MAAM,iBAAiB,SAqBP,MAAM,sCAjB3B,CAAC;AAEH,eAAO,MAAM,sBAAsB,SAeZ,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SASR,MAAM;;0DAN3B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,EACnD,MAAM,EACN,UAAU,EACV,WAAgB,GACjB,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAkB9C;AAED,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
1
+ {"version":3,"file":"file-loaders.d.ts","sourceRoot":"","sources":["../../src/helpers/file-loaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,eAAO,MAAM,iBAAiB,SAqBP,MAAM,sCAjB3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SAeR,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SASR,MAAM;;0DAN3B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,EACnD,MAAM,EACN,UAAU,EACV,WAAgB,GACjB,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAkB9C;AAED,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getJSONataTemplate = exports.getExternalDataFixture = exports.getCatalogFixture = void 0;
6
+ exports.getJSONataTemplate = exports.getExternalFixture = exports.getCatalogFixture = void 0;
7
7
  exports.createFileLoader = createFileLoader;
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const errors_1 = require("@oclif/core/errors");
@@ -14,7 +14,7 @@ exports.getCatalogFixture = createFileLoader({
14
14
  fileLoader: fs_extra_1.default.readJSONSync,
15
15
  suggestions: ["Ensure the file is a valid JSON file"],
16
16
  });
17
- exports.getExternalDataFixture = createFileLoader({
17
+ exports.getExternalFixture = createFileLoader({
18
18
  prefix: path_1.default.join("src", "fixtures", "external_data"),
19
19
  fileLoader: fs_extra_1.default.readJSONSync,
20
20
  suggestions: ["Ensure the file is a valid JSON file"],
@@ -1,10 +1,10 @@
1
1
  import { type TemplateExecutionSuccessResponse, type TemplateExecutionErrorResponse } from "../types";
2
- export declare function sendTemplateExecuteRequest({ template, helpers, targetData, externalData, connectionId, templateType, showLogs, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
2
+ export declare function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
3
3
  interface Args {
4
4
  template: string;
5
5
  helpers: string;
6
- targetData: any;
7
- externalData: any;
6
+ data: any;
7
+ external: any;
8
8
  connectionId: string;
9
9
  templateType: string;
10
10
  showLogs?: boolean;
@@ -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,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"}
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,IAAI,EACJ,QAAQ,EACR,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,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,GAAG,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -5,14 +5,14 @@ const axios_1 = require("axios");
5
5
  const errors_1 = require("@oclif/core/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, templateType, showLogs = true, }) {
8
+ async function sendTemplateExecuteRequest({ template, helpers, data, external, 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
12
  helpers,
13
13
  raw_template: template,
14
- target_data: targetData,
15
- external_data: externalData,
14
+ data,
15
+ external,
16
16
  connection_id: connectionId,
17
17
  template_type: templateType,
18
18
  })).data;
@@ -1,3 +1,3 @@
1
1
  import { type PromptChoices } from "../types";
2
- export declare function getExternalDataFiles(): PromptChoices<string>;
2
+ export declare function getExternalFiles(): PromptChoices<string>;
3
3
  //# sourceMappingURL=get-external-data-files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-external-data-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-external-data-files.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,IAAI,aAAa,CAAC,MAAM,CAAC,CAmB5D"}
1
+ {"version":3,"file":"get-external-data-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-external-data-files.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,gBAAgB,IAAI,aAAa,CAAC,MAAM,CAAC,CAmBxD"}
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getExternalDataFiles = getExternalDataFiles;
6
+ exports.getExternalFiles = getExternalFiles;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const find_deep_files_1 = require("../helpers/find-deep-files");
9
- function getExternalDataFiles() {
9
+ function getExternalFiles() {
10
10
  try {
11
11
  const filePath = path_1.default.join("src", "fixtures", "external_data");
12
12
  return (0, find_deep_files_1.findDeepFiles)(filePath)
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.13.3";
1
+ declare const _default: "1.14.0";
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.13.3';
3
+ exports.default = '1.14.0';
@@ -190,5 +190,5 @@
190
190
  ]
191
191
  }
192
192
  },
193
- "version": "1.13.3"
193
+ "version": "1.14.0"
194
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.13.3",
3
+ "version": "1.14.0",
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",
@@ -90,7 +90,7 @@
90
90
  "jest": "^29.7.0",
91
91
  "license-checker": "^25.0.1",
92
92
  "mock-fs": "^5.2.0",
93
- "nock": "14.0.4",
93
+ "nock": "14.0.5",
94
94
  "oclif": "^4.17.42",
95
95
  "prettier": "^3.2.5",
96
96
  "prettier-2": "npm:prettier@^2.8.8",