@constructor-io/constructorio-connect-cli 1.4.5 → 1.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/README.md CHANGED
@@ -12,7 +12,7 @@ This package is a CLI tool that helps you **build, test and deploy your connecto
12
12
  ## 1. Review the Requirements
13
13
 
14
14
  Before you begin, note that this package is intended for use with partner connections. If you don't have a connector
15
- running yet, please take a look at [our documentation](https://docs-beta.constructor.io/docs/integrating-with-constructor-platform-connectors) to see how you can get started.
15
+ running yet, please take a look at [our documentation](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors) to see how you can get started.
16
16
 
17
17
  Finally, make sure you have your **connect auth token** available. If you don't have this yet, please get in touch with our team and we'll set this up.
18
18
 
@@ -26,7 +26,7 @@ npx @constructor-io/constructorio-connect-cli init my-repo
26
26
 
27
27
  Where `my-repo` is the name of the folder and repository you want to create.
28
28
 
29
- With the new repository initialized, you can start developing your catalog integration. Please refer to our [documentation](https://docs-beta.constructor.io/docs/integrating-with-constructor-platform-connectors) for more information on how to build your templates.
29
+ With the new repository initialized, you can start developing your catalog integration. Please refer to our [documentation](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors) for more information on how to build your templates.
30
30
 
31
31
  ## 3. Commands
32
32
 
@@ -194,11 +194,11 @@ Keep in mind that the template will have access to `externalData` and `targetDat
194
194
 
195
195
  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:
196
196
 
197
- - [Item](https://docs-beta.constructor.io/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-items-products)
198
- - [Variation](https://docs-beta.constructor.io/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-variations)
199
- - [Item Group](https://docs-beta.constructor.io/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-item-groups-categories)
197
+ - [Item](https://docs.constructor.com/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-items-products)
198
+ - [Variation](https://docs.constructor.com/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-variations)
199
+ - [Item Group](https://docs.constructor.com/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-item-groups-categories)
200
200
 
201
- You can also refer to the [Constructor API docs](https://docs-beta.constructor.io/reference/v1-catalog-create-or-replace-catalog) for more details.
201
+ You can also refer to the [Constructor API docs](https://docs.constructor.com/reference/v1-catalog-create-or-replace-catalog) for more details.
202
202
 
203
203
  ## 🗑️ Removing Entities
204
204
 
@@ -27,11 +27,11 @@ exports.TYPE_OPTIONS = [
27
27
  * @returns Promise<Record<string, any>>
28
28
  */
29
29
  async function executeTemplate(options) {
30
- const { type, name, fixture, externalData } = initializeOptions(options);
30
+ const { name, fixture, externalData } = initializeOptions(options);
31
31
  const connection = await getConnection(options);
32
32
  const config = await (0, config_1.getRepositoryConfigFile)();
33
33
  const result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
34
- template: (0, file_loaders_1.getJSONataTemplate)(`${type}/${name}`).toString(),
34
+ template: (0, file_loaders_1.getJSONataTemplate)(name).toString(),
35
35
  helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
36
36
  connectionId: connection.id,
37
37
  targetData: fixture,
@@ -56,6 +56,9 @@ function initializeOptions(options) {
56
56
  if (!options.name) {
57
57
  throw new Error("No name provided");
58
58
  }
59
+ if (!options.name.includes("/")) {
60
+ options.name = `${options.type}/${options.name}`;
61
+ }
59
62
  if (!options.fixture) {
60
63
  options.fixture = {};
61
64
  }
@@ -1,4 +1,8 @@
1
1
  import { type ConnectionResponseDto } from "../http/get-connections-request";
2
2
  import { type PromptChoices } from "../types";
3
+ /**
4
+ * Returns all connections that are associated with a template by checking
5
+ * the config file.
6
+ */
3
7
  export declare function filterConnectionsByTemplate(templatePath: string, connections: ConnectionResponseDto[]): Promise<PromptChoices<ConnectionResponseDto>>;
4
8
  //# sourceMappingURL=filter-connections-by-template.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-connections-by-template.d.ts","sourceRoot":"","sources":["../../src/prompt-data/filter-connections-by-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,EAAE,GACnC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CA4B/C"}
1
+ {"version":3,"file":"filter-connections-by-template.d.ts","sourceRoot":"","sources":["../../src/prompt-data/filter-connections-by-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,EAAE,GACnC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAmC/C"}
@@ -6,24 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.filterConnectionsByTemplate = filterConnectionsByTemplate;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const config_1 = require("../customer/config");
9
+ /**
10
+ * Returns all connections that are associated with a template by checking
11
+ * the config file.
12
+ */
9
13
  async function filterConnectionsByTemplate(templatePath, connections) {
10
14
  const config = await (0, config_1.getRepositoryConfigFile)();
11
15
  const fullPath = path_1.default.join("src/templates", templatePath);
12
- // Find the config mappings that have the template.
13
- const connectionIds = config.environments.reduce((connectionIds, env) => {
14
- env.templates.forEach((templateConfig) => {
16
+ // All connection ids that references this template
17
+ const configConnectionIds = config.environments.reduce((connectionIds, environment) => {
18
+ for (const templateConfig of environment.templates) {
15
19
  const templatePaths = Object.values(templateConfig.paths);
16
- if (templatePaths.includes(fullPath)) {
17
- templateConfig.connection_ids.forEach((id) => connectionIds.add(id));
20
+ // environment doesn't even target this template
21
+ if (!templatePaths.includes(fullPath)) {
22
+ continue;
18
23
  }
19
- });
24
+ for (const id of templateConfig.connection_ids) {
25
+ connectionIds.add(id);
26
+ }
27
+ }
20
28
  return connectionIds;
21
29
  }, new Set());
22
- const filteredConnections = connections.filter((c) => connectionIds.has(c.id));
23
- return filteredConnections.map((c) => {
30
+ const filteredConnections = connections.filter((connection) => configConnectionIds.has(connection.id));
31
+ return filteredConnections.map((connection) => {
24
32
  return {
25
- name: c.name,
26
- value: c,
33
+ name: connection.name,
34
+ value: connection,
27
35
  };
28
36
  });
29
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,MAAM,CAAC,CA+CvB"}
1
+ {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEhF,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,MAAM,CAAC,CAkDvB"}
@@ -7,7 +7,7 @@ exports.getCandidateFixtures = getCandidateFixtures;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const errors_1 = require("@oclif/core/lib/errors");
9
9
  const find_deep_files_1 = require("../helpers/find-deep-files");
10
- const get_template_files_1 = require("./get-template-files");
10
+ const types_1 = require("../types");
11
11
  function getCandidateFixtures(templatePath) {
12
12
  const templateType = extractTemplateType(templatePath);
13
13
  if (!templateType) {
@@ -16,11 +16,13 @@ function getCandidateFixtures(templatePath) {
16
16
  "Check that the template file path is correct",
17
17
  "Check that your templates are in the correctly named directory for their type (e.g. 'item.jsonata' in the 'templates/item' directory",
18
18
  "Check that you are using a valid template type: " +
19
- get_template_files_1.templateTypes.join(", "),
19
+ types_1.TemplateTypes.join(", "),
20
20
  ],
21
21
  });
22
22
  }
23
- const fixtureType = templateType === "grouping" ? "variation" : templateType;
23
+ const fixtureType = templateType === "grouping"
24
+ ? "variation" //
25
+ : templateType;
24
26
  let fixtureFullPaths;
25
27
  try {
26
28
  fixtureFullPaths = (0, find_deep_files_1.findDeepFiles)(`src/fixtures/${fixtureType}`);
@@ -50,7 +52,7 @@ function getCandidateFixtures(templatePath) {
50
52
  * Checks for any nested folder that matches a known template type.
51
53
  */
52
54
  function extractTemplateType(templatePath) {
53
- for (const type of get_template_files_1.templateTypes) {
55
+ for (const type of types_1.TemplateTypes) {
54
56
  if (templatePath.includes(`${type}/`)) {
55
57
  return type;
56
58
  }
@@ -1,5 +1,4 @@
1
1
  import { type PromptChoices } from "../types";
2
- export declare const templateTypes: string[];
3
2
  /**
4
3
  * Get a prompt-ready list of template files in the user repository
5
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,aAAa,UAMzB,CAAC;AAEF;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAavE"}
1
+ {"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAWvE"}
@@ -1,28 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.templateTypes = void 0;
7
3
  exports.getTemplateFiles = getTemplateFiles;
8
- const path_1 = __importDefault(require("path"));
9
4
  const find_deep_files_1 = require("../helpers/find-deep-files");
10
- exports.templateTypes = [
11
- "item",
12
- "variation",
13
- "item_group",
14
- "grouping",
15
- "mapping",
16
- ];
17
5
  /**
18
6
  * Get a prompt-ready list of template files in the user repository
19
7
  */
20
8
  async function getTemplateFiles() {
21
- let files = [];
22
- for (const type of exports.templateTypes) {
23
- const typePath = path_1.default.join("src/templates", type);
24
- files = files.concat(getTemplatePaths(typePath));
25
- }
9
+ const files = getTemplatePaths("src/templates");
26
10
  const filteredFiles = files.filter((file) => file.endsWith(".jsonata") && !file.includes("helpers"));
27
11
  return filteredFiles.map((file) => ({
28
12
  name: file.replace("src/templates/", ""),
package/dist/types.d.ts CHANGED
@@ -4,13 +4,7 @@ export interface Config {
4
4
  environments: Array<{
5
5
  environment: string;
6
6
  templates: Array<{
7
- paths: {
8
- item?: string;
9
- variation?: string;
10
- item_group?: string;
11
- grouping?: string;
12
- mapping?: string;
13
- };
7
+ paths: Partial<Record<TemplateType, string>>;
14
8
  connection_ids: string[];
15
9
  }>;
16
10
  }>;
@@ -48,5 +42,7 @@ export declare enum CatalogFixtureType {
48
42
  EXTERNAL_DATA = "external_data",
49
43
  MAPPING = "mapping"
50
44
  }
45
+ export declare const TemplateTypes: readonly ["item", "variation", "item_group", "grouping", "mapping"];
46
+ export type TemplateType = (typeof TemplateTypes)[number];
51
47
  export {};
52
48
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,2BAA2B,EAAE,OAAO,CAAC;IACrC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,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AAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,aAAa,qEAMhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC"}
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatalogFixtureType = void 0;
3
+ exports.TemplateTypes = exports.CatalogFixtureType = void 0;
4
4
  var CatalogFixtureType;
5
5
  (function (CatalogFixtureType) {
6
6
  CatalogFixtureType["ITEM"] = "item";
@@ -9,3 +9,10 @@ var CatalogFixtureType;
9
9
  CatalogFixtureType["EXTERNAL_DATA"] = "external_data";
10
10
  CatalogFixtureType["MAPPING"] = "mapping";
11
11
  })(CatalogFixtureType || (exports.CatalogFixtureType = CatalogFixtureType = {}));
12
+ exports.TemplateTypes = [
13
+ "item",
14
+ "variation",
15
+ "item_group",
16
+ "grouping",
17
+ "mapping",
18
+ ];
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.4.5";
1
+ declare const _default: "1.5.1";
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.4.5';
3
+ exports.default = '1.5.1';
@@ -148,5 +148,5 @@
148
148
  ]
149
149
  }
150
150
  },
151
- "version": "1.4.5"
151
+ "version": "1.5.1"
152
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.4.5",
3
+ "version": "1.5.1",
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",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "homepage": "https://github.com/Constructor-io/constructorio-connect-cli#readme",
63
63
  "dependencies": {
64
- "@inquirer/prompts": "^6.0.1",
64
+ "@inquirer/prompts": "^7.0.1",
65
65
  "@oclif/core": "3.25.3",
66
66
  "@oclif/plugin-help": "^6.0.21",
67
67
  "axios": "^1.6.8",