@constructor-io/constructorio-connect-cli 1.5.3 → 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.
- package/boilerplate-repo/src/templates/helpers.jsonata +4 -3
- package/boilerplate-repo/src/templates/item/item.jsonata +4 -26
- package/boilerplate-repo/src/templates/item_group/item_group.jsonata +4 -3
- package/boilerplate-repo/src/templates/mapping/mapping.jsonata +2 -32
- package/boilerplate-repo/src/templates/variation/variation.jsonata +4 -26
- package/boilerplate-repo/test/templates/item/item.spec.mjs +6 -82
- package/boilerplate-repo/test/templates/item_group/item_group.spec.mjs +6 -19
- package/boilerplate-repo/test/templates/mapping/mapping.spec.mjs +6 -74
- package/boilerplate-repo/test/templates/variation/variation.spec.mjs +6 -33
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +13 -4
- package/dist/helpers/build-config-file.d.ts +1 -1
- package/dist/helpers/build-config-file.d.ts.map +1 -1
- package/dist/helpers/build-config-file.js +6 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/boilerplate-repo/src/fixtures/item/item.json +0 -39
- package/boilerplate-repo/src/fixtures/item_group/item_group.json +0 -22
- package/boilerplate-repo/src/fixtures/mapping/mapping.json +0 -26
- package/boilerplate-repo/src/fixtures/variation/variation.json +0 -11
- package/boilerplate-repo/src/templates/grouping/grouping.jsonata +0 -37
- package/boilerplate-repo/test/templates/grouping/grouping.spec.mjs +0 -26
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
8
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
8
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
8
|
-
|
|
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/commands/init.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export default class Init extends Command {
|
|
|
10
10
|
private initGitRepoAndCommit;
|
|
11
11
|
private updateRepo;
|
|
12
12
|
private generateRepositoryFiles;
|
|
13
|
-
static createNewRepository(newDir: string): void;
|
|
13
|
+
static createNewRepository(newDir: string, shouldCreateMappingTemplates: boolean): void;
|
|
14
14
|
private static replacePackageName;
|
|
15
15
|
private static replaceConfigValues;
|
|
16
16
|
private printSuccessfulInitMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AAyBhD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA4D;IAE9E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA+BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AAyBhD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA4D;IAE9E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA+BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WA+BvB,mBAAmB,CAC/B,MAAM,EAAE,MAAM,EACd,4BAA4B,EAAE,OAAO,GACpC,IAAI;IAcP,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAWjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAuBlC,OAAO,CAAC,0BAA0B;CA4BnC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -129,10 +129,11 @@ class Init extends core_1.Command {
|
|
|
129
129
|
async generateRepositoryFiles(args) {
|
|
130
130
|
core_1.ux.log("\n");
|
|
131
131
|
const connections = await (0, get_connections_request_1.getConnections)({ showLogs: true });
|
|
132
|
+
const shouldCreateMappingTemplates = connections.some((connection) => connection.partner === "omni");
|
|
132
133
|
const connectionsDict = (0, build_config_file_1.buildConnectionsDictFromList)(connections);
|
|
133
|
-
const config = (0, build_config_file_1.buildConfigFromConnections)(connections);
|
|
134
|
+
const config = (0, build_config_file_1.buildConfigFromConnections)(connections, shouldCreateMappingTemplates);
|
|
134
135
|
(0, ux_action_1.uxAction)("🚀 Creating new Constructor.io Connect CLI repository", () => {
|
|
135
|
-
Init.createNewRepository(args.repoPath);
|
|
136
|
+
Init.createNewRepository(args.repoPath, shouldCreateMappingTemplates);
|
|
136
137
|
Init.replacePackageName(args.repoName, args.repoPath);
|
|
137
138
|
})();
|
|
138
139
|
(0, ux_action_1.uxAction)("📦 Installing dependencies", () => {
|
|
@@ -142,9 +143,17 @@ class Init extends core_1.Command {
|
|
|
142
143
|
})();
|
|
143
144
|
Init.replaceConfigValues(config, connectionsDict, args.repoPath);
|
|
144
145
|
}
|
|
145
|
-
static createNewRepository(newDir) {
|
|
146
|
+
static createNewRepository(newDir, shouldCreateMappingTemplates) {
|
|
146
147
|
const repoDir = path.join(__dirname, BOILERPLATE_REPO_PATH);
|
|
147
|
-
fs_extra_1.default.copySync(repoDir, newDir
|
|
148
|
+
fs_extra_1.default.copySync(repoDir, newDir, {
|
|
149
|
+
filter: (file) => {
|
|
150
|
+
if (shouldCreateMappingTemplates) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
// Exclude mapping templates if the user doesn't have an Omni connector connection
|
|
154
|
+
return !file.includes("mapping");
|
|
155
|
+
},
|
|
156
|
+
});
|
|
148
157
|
}
|
|
149
158
|
static replacePackageName(name, repoPath) {
|
|
150
159
|
const packageJsonPath = path.join(repoPath, "package.json");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ConnectionResponseDto } from "../http/get-connections-request";
|
|
2
2
|
import { type Config, type ConnectionConfigDict } from "../types";
|
|
3
|
-
export declare function buildConfigFromConnections(connections: ConnectionResponseDto[]): Config;
|
|
3
|
+
export declare function buildConfigFromConnections(connections: ConnectionResponseDto[], shouldCreateMappingTemplates: boolean): Config;
|
|
4
4
|
export declare function buildConnectionsDictFromList(connections: ConnectionResponseDto[]): ConnectionConfigDict;
|
|
5
5
|
export declare function buildConfigString(config: Config, connections: ConnectionConfigDict): string;
|
|
6
6
|
//# sourceMappingURL=build-config-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-config-file.d.ts","sourceRoot":"","sources":["../../src/helpers/build-config-file.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"build-config-file.d.ts","sourceRoot":"","sources":["../../src/helpers/build-config-file.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,qBAAqB,EAAE,EACpC,4BAA4B,EAAE,OAAO,GACpC,MAAM,CAYR;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,qBAAqB,EAAE,wBAYrC;AAmDD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,oBAAoB,GAChC,MAAM,CAmBR"}
|
|
@@ -14,12 +14,12 @@ exports.buildConfigString = buildConfigString;
|
|
|
14
14
|
* 4. Map each object in the environments array to expand out
|
|
15
15
|
*/
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
function buildConfigFromConnections(connections) {
|
|
17
|
+
function buildConfigFromConnections(connections, shouldCreateMappingTemplates) {
|
|
18
18
|
const environments = getUniqueConnectionEnvs(connections);
|
|
19
19
|
return {
|
|
20
20
|
template_repository_version: "1.0.0",
|
|
21
21
|
helpers: path_1.default.join("src", "templates", "helpers.jsonata"),
|
|
22
|
-
environments: buildTemplateEnvironments(environments, connections),
|
|
22
|
+
environments: buildTemplateEnvironments(environments, connections, shouldCreateMappingTemplates),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function buildConnectionsDictFromList(connections) {
|
|
@@ -41,7 +41,7 @@ function getUniqueConnectionEnvs(connections) {
|
|
|
41
41
|
return envs;
|
|
42
42
|
}, []);
|
|
43
43
|
}
|
|
44
|
-
function buildTemplateEnvironments(environments, connections) {
|
|
44
|
+
function buildTemplateEnvironments(environments, connections, shouldCreateMappingTemplates) {
|
|
45
45
|
return environments.map((env) => {
|
|
46
46
|
return {
|
|
47
47
|
environment: env,
|
|
@@ -54,8 +54,9 @@ function buildTemplateEnvironments(environments, connections) {
|
|
|
54
54
|
item: path_1.default.join("src", "templates", "item", "item.jsonata"),
|
|
55
55
|
variation: path_1.default.join("src", "templates", "variation", "variation.jsonata"),
|
|
56
56
|
item_group: path_1.default.join("src", "templates", "item_group", "item_group.jsonata"),
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
...(shouldCreateMappingTemplates && {
|
|
58
|
+
mapping: path_1.default.join("src", "templates", "mapping", "mapping.jsonata"),
|
|
59
|
+
}),
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
],
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -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,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,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
This template enables you to group variations together as items.
|
|
3
|
-
It'll use the variation data and expect you to return the item structure, just like in the item template.
|
|
4
|
-
|
|
5
|
-
When you use this template, a new item will be created for each unique ID that you return from this template,
|
|
6
|
-
but any additional items returned with the same ID will be ignored.
|
|
7
|
-
|
|
8
|
-
When creating new items, the base item information of the variation will be merged with the template result,
|
|
9
|
-
effectively filling in fields that you don't return from the template.
|
|
10
|
-
|
|
11
|
-
For example, suppose that you use the following logic to calculate the ID:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
{
|
|
15
|
-
"id": $join([targetData.product_id, targetData.color])
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Let's assume that you have an item with 3 variations, containing the respective data:
|
|
20
|
-
|
|
21
|
-
1. product_id: 1, color: red, size: S
|
|
22
|
-
2. product_id: 1, color: red, size: M
|
|
23
|
-
3. product_id: 1, color: blue, size: S
|
|
24
|
-
|
|
25
|
-
The template will create 2 items:
|
|
26
|
-
|
|
27
|
-
1. id: 1-red
|
|
28
|
-
2. id: 1-blue
|
|
29
|
-
|
|
30
|
-
And you can return any extra item field on the template to customize the item structure,
|
|
31
|
-
allowing you to add any other pieces of information to the newly created items.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
"id": targetData.id,
|
|
36
|
-
"item_name": targetData.name
|
|
37
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
executeTemplate,
|
|
3
|
-
buildFixture,
|
|
4
|
-
} from "@constructor-io/constructorio-connect-cli";
|
|
5
|
-
|
|
6
|
-
describe("grouping", () => {
|
|
7
|
-
it("should match inline snapshot", async () => {
|
|
8
|
-
const result = await executeTemplate({
|
|
9
|
-
type: "grouping",
|
|
10
|
-
name: "grouping.jsonata",
|
|
11
|
-
fixture: buildFixture("variation", "variation.json", {
|
|
12
|
-
name: "New Variation Name",
|
|
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
|
-
"id": "42-red",
|
|
22
|
-
"item_name": "New Variation Name",
|
|
23
|
-
}
|
|
24
|
-
`);
|
|
25
|
-
});
|
|
26
|
-
});
|