@constructor-io/constructorio-connect-cli 1.6.0 → 1.7.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
- $hello := function($name) {
2
- $join(["These are my ", $name, "!"])
3
- };
1
+ /*
2
+ * This is a file where you can define additional helper functions.
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-helper-functions
4
+ */
@@ -1,26 +1,4 @@
1
- (
2
- /* Import all helper functions defined in helpers.jsonata */
3
- {{helpers}}
4
-
5
- /* You can define variables and custom logic */
6
- $name := targetData.name;
7
-
8
- {
9
- /* Use the `hello` helper function */
10
- "item_name": $hello($name),
11
-
12
- "metadata": [
13
- {
14
- "key": "colors",
15
- "value": targetData.variations.attributes[name = "color"].value
16
- }
17
- ],
18
-
19
- "facets": [
20
- {
21
- "key": "price_average",
22
- "value": $average(targetData.variations.price)
23
- }
24
- ]
25
- }
26
- )
1
+ /*
2
+ * This template allows you to customize your item data.
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-template-types-transformation-templates#item-template
4
+ */
@@ -1,3 +1,4 @@
1
- {
2
- "name": $lowercase(targetData.name)
3
- }
1
+ /*
2
+ * This template allows you to customize your item group data.
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-template-types-transformation-templates#item-group-template
4
+ */
@@ -1,34 +1,4 @@
1
1
  /*
2
- The mapping template allows you to map the input data to any format you want before the
3
- actual transformations happen, using the transformation templates for each entity.
4
-
5
- In this template, you can return three arrays: `items`, `variations`, and `item_groups`.
6
- Each array can have any structure as defined by you, and you'll be able to use the
7
- very same structure defined here in the transformation templates.
8
-
9
- In the example defined below, we only care about mapping the items and item groups,
10
- since variations are already embedded into each item.
11
-
12
- If we wanted to ingest only variations (e.g. a partial sync), you'd return the
13
- `variations` array filled with data instead.
14
-
15
- Refer to the README for extended documentation on how to use the mapping template.
2
+ * Check out the documentation to see how to change and customize the connector data mapping:
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-template-types-mapping-template
16
4
  */
17
-
18
- (
19
- /* Import all helper functions defined in helpers.jsonata */
20
- {{helpers}}
21
-
22
- {
23
- "items": [
24
- $merge([
25
- targetData,
26
- { "__variations": targetData.colors.{ "color": $ } }
27
- ])
28
- ],
29
- "variations": [],
30
- "item_groups": [
31
- { "id": targetData.category }
32
- ]
33
- }
34
- )
@@ -1,26 +1,4 @@
1
- (
2
- /* Import all helper functions defined in helpers.jsonata */
3
- {{helpers}}
4
-
5
- /* You can define variables and custom logic */
6
- $name := targetData.name;
7
-
8
- {
9
- /* Use the `hello` helper function */
10
- "item_name": $hello($name),
11
-
12
- "metadata": [
13
- {
14
- "key": "color",
15
- "value": targetData.attributes[name = "color"].value
16
- }
17
- ],
18
-
19
- "facets": [
20
- {
21
- "key": "price",
22
- "value": targetData.price
23
- }
24
- ]
25
- }
26
- )
1
+ /*
2
+ * This template allows you to customize your variation data.
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-template-types-transformation-templates#variation-template
4
+ */
@@ -1,86 +1,10 @@
1
- import {
2
- executeTemplate,
3
- buildFixture,
4
- } from "@constructor-io/constructorio-connect-cli";
1
+ /**
2
+ * Check out the documentation to see how to write and maintain tests:
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
+ */
5
5
 
6
6
  describe("item", () => {
7
- it("should match inline snapshot", async () => {
8
- /**
9
- * Add a function `executeTemplate` which abstracts all the complexity from
10
- * running a template and gives you the result back.
11
- *
12
- * It will:
13
- * - Load the template.
14
- * - Receive the fixture + externalData (optional) as an object.
15
- * - Automatically load the first `connectionId` to send to the backend.
16
- * - Execute the template on the backend.
17
- * - Return an object.
18
- *
19
- * In failure:
20
- * - It will throw an error, not allowing the test to proceed.
21
- */
22
- const result = await executeTemplate({
23
- // Define the template type: item | variation | item_group | mapping | grouping
24
- type: "item",
25
-
26
- // Define the template file name, which will be used to load the test
27
- name: "item.jsonata",
28
-
29
- /**
30
- * Add a function `buildFixture` to load a fixture from a type and file name.
31
- * It can also receive a second param being an object, which will deep merge into
32
- * the fixture itself - similarly to how a factory pattern works. This way we can
33
- * have only one fixture with many tests :)
34
- */
35
- fixture: buildFixture("item", "item.json", {
36
- name: "other shoes!",
37
- variations: [
38
- {
39
- name: "other shoes (red)",
40
- price: 130,
41
- },
42
- {
43
- name: "other shoes (blue)",
44
- price: 200,
45
- },
46
- ],
47
- }),
48
- });
49
-
50
- // Alternatively, you can also store the snapshot in a file to reduce clutter.
51
- // expect(result).toMatchSnapshot();
52
-
53
- expect(result).toMatchInlineSnapshot(`
54
- {
55
- "facets": [
56
- {
57
- "key": "price_average",
58
- "value": 165,
59
- },
60
- ],
61
- "item_name": "These are my other shoes!!",
62
- "metadata": [
63
- {
64
- "key": "colors",
65
- },
66
- ],
67
- }
68
- `);
69
- });
70
-
71
- it("should compute the average price", async () => {
72
- const response = await executeTemplate({
73
- type: "item",
74
- name: "item.jsonata",
75
- fixture: buildFixture("item", "item.json", {
76
- variations: [{ price: 100 }, { price: 200 }],
77
- }),
78
- });
79
-
80
- const priceFacet = response.facets.find(
81
- (facet) => facet.key === "price_average",
82
- );
83
-
84
- expect(priceFacet.value).toBe(150);
7
+ it("should be defined", async () => {
8
+ expect(true).toBe(true);
85
9
  });
86
10
  });
@@ -1,23 +1,10 @@
1
- import {
2
- executeTemplate,
3
- buildFixture,
4
- } from "@constructor-io/constructorio-connect-cli";
1
+ /**
2
+ * Check out the documentation to see how to write and maintain tests:
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
+ */
5
5
 
6
6
  describe("item_group", () => {
7
- it("should match inline snapshot", async () => {
8
- const result = await executeTemplate({
9
- type: "item_group",
10
- name: "item_group.jsonata",
11
- fixture: buildFixture("item_group", "item_group.json", { other: "data" }),
12
- });
13
-
14
- // Alternatively, you can also store the snapshot in a file to reduce clutter.
15
- // expect(result).toMatchSnapshot();
16
-
17
- expect(result).toMatchInlineSnapshot(`
18
- {
19
- "name": "root",
20
- }
21
- `);
7
+ it("should be defined", async () => {
8
+ expect(true).toBe(true);
22
9
  });
23
10
  });
@@ -1,78 +1,10 @@
1
- import {
2
- executeTemplate,
3
- buildFixture,
4
- } from "@constructor-io/constructorio-connect-cli";
1
+ /**
2
+ * Check out the documentation to see how to write and maintain tests:
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
+ */
5
5
 
6
6
  describe("mapping", () => {
7
- it("should match inline snapshot", async () => {
8
- const result = await executeTemplate({
9
- type: "mapping",
10
- name: "mapping.jsonata",
11
- fixture: buildFixture("mapping", "mapping.json", {
12
- title: "New Title",
13
- }),
14
- });
15
-
16
- // Alternatively, you can also store the snapshot in a file to reduce clutter.
17
- // expect(result).toMatchSnapshot();
18
-
19
- expect(result).toMatchInlineSnapshot(`
20
- {
21
- "item_groups": [
22
- {
23
- "id": "smartphones",
24
- },
25
- ],
26
- "items": [
27
- {
28
- "__variations": [
29
- {
30
- "color": "midnight-black",
31
- },
32
- {
33
- "color": "fancy-silver",
34
- },
35
- {
36
- "color": "rich-gold",
37
- },
38
- {
39
- "color": "sky-blue",
40
- },
41
- {
42
- "color": "crimson-red",
43
- },
44
- {
45
- "color": "green-forest",
46
- },
47
- ],
48
- "brand": "Apple",
49
- "category": "smartphones",
50
- "colors": [
51
- "midnight-black",
52
- "fancy-silver",
53
- "rich-gold",
54
- "sky-blue",
55
- "crimson-red",
56
- "green-forest",
57
- ],
58
- "description": "SIM-Free, Model A19211 6.5-inch Super Retina HD display with OLED technology A12 Bionic chip with ...",
59
- "discountPercentage": 17.94,
60
- "id": "iphone-x",
61
- "images": [
62
- "https://cdn.dummyjson.com/product-images/2/1.jpg",
63
- "https://cdn.dummyjson.com/product-images/2/2.jpg",
64
- "https://cdn.dummyjson.com/product-images/2/3.jpg",
65
- "https://cdn.dummyjson.com/product-images/2/thumbnail.jpg",
66
- ],
67
- "price": 899,
68
- "rating": 4.44,
69
- "stock": 34,
70
- "thumbnail": "https://cdn.dummyjson.com/product-images/2/thumbnail.jpg",
71
- "title": "New Title",
72
- },
73
- ],
74
- "variations": [],
75
- }
76
- `);
7
+ it("should be defined", async () => {
8
+ expect(true).toBe(true);
77
9
  });
78
10
  });
@@ -1,37 +1,10 @@
1
- import {
2
- executeTemplate,
3
- buildFixture,
4
- } from "@constructor-io/constructorio-connect-cli";
1
+ /**
2
+ * Check out the documentation to see how to write and maintain tests:
3
+ * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
+ */
5
5
 
6
6
  describe("variation", () => {
7
- it("should match inline snapshot", async () => {
8
- const result = await executeTemplate({
9
- type: "variation",
10
- name: "variation.jsonata",
11
- fixture: buildFixture("variation", "variation.json", {
12
- name: "stylish boots",
13
- }),
14
- });
15
-
16
- // Alternatively, you can also store the snapshot in a file to reduce clutter.
17
- // expect(result).toMatchSnapshot();
18
-
19
- expect(result).toMatchInlineSnapshot(`
20
- {
21
- "facets": [
22
- {
23
- "key": "price",
24
- "value": 50,
25
- },
26
- ],
27
- "item_name": "These are my stylish boots!",
28
- "metadata": [
29
- {
30
- "key": "color",
31
- "value": "red",
32
- },
33
- ],
34
- }
35
- `);
7
+ it("should be defined", async () => {
8
+ expect(true).toBe(true);
36
9
  });
37
10
  });
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.6.0";
1
+ declare const _default: "1.7.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.6.0';
3
+ exports.default = '1.7.0';
@@ -148,5 +148,5 @@
148
148
  ]
149
149
  }
150
150
  },
151
- "version": "1.6.0"
151
+ "version": "1.7.0"
152
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.6.0",
3
+ "version": "1.7.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",
@@ -1,39 +0,0 @@
1
- {
2
- "id": 42,
3
- "name": "Super Shoes",
4
- "variations": [
5
- {
6
- "id": "42-red",
7
- "name": "Super Shoes (Red)",
8
- "price": 50,
9
- "attributes": [
10
- {
11
- "name": "color",
12
- "value": "red"
13
- }
14
- ]
15
- },
16
- {
17
- "id": "42-blue",
18
- "name": "Super Shoes (Blue)",
19
- "price": 100,
20
- "attributes": [
21
- {
22
- "name": "color",
23
- "value": "blue"
24
- }
25
- ]
26
- },
27
- {
28
- "id": "42-green",
29
- "name": "Super Shoes (Green)",
30
- "price": 75,
31
- "attributes": [
32
- {
33
- "name": "color",
34
- "value": "green"
35
- }
36
- ]
37
- }
38
- ]
39
- }
@@ -1,22 +0,0 @@
1
- {
2
- "id": 1,
3
- "name": "Root",
4
- "children": [
5
- {
6
- "id": 2,
7
- "name": "Clothing"
8
- },
9
- {
10
- "id": 3,
11
- "name": "Shoes"
12
- },
13
- {
14
- "id": 4,
15
- "name": "Accessories"
16
- },
17
- {
18
- "id": 5,
19
- "name": "Electronics"
20
- }
21
- ]
22
- }
@@ -1,26 +0,0 @@
1
- {
2
- "id": "iphone-x",
3
- "title": "iPhone X",
4
- "description": "SIM-Free, Model A19211 6.5-inch Super Retina HD display with OLED technology A12 Bionic chip with ...",
5
- "price": 899,
6
- "discountPercentage": 17.94,
7
- "rating": 4.44,
8
- "stock": 34,
9
- "brand": "Apple",
10
- "category": "smartphones",
11
- "thumbnail": "https://cdn.dummyjson.com/product-images/2/thumbnail.jpg",
12
- "images": [
13
- "https://cdn.dummyjson.com/product-images/2/1.jpg",
14
- "https://cdn.dummyjson.com/product-images/2/2.jpg",
15
- "https://cdn.dummyjson.com/product-images/2/3.jpg",
16
- "https://cdn.dummyjson.com/product-images/2/thumbnail.jpg"
17
- ],
18
- "colors": [
19
- "midnight-black",
20
- "fancy-silver",
21
- "rich-gold",
22
- "sky-blue",
23
- "crimson-red",
24
- "green-forest"
25
- ]
26
- }
@@ -1,11 +0,0 @@
1
- {
2
- "id": "42-red",
3
- "name": "Super Shoes (Red)",
4
- "price": 50,
5
- "attributes": [
6
- {
7
- "name": "color",
8
- "value": "red"
9
- }
10
- ]
11
- }