@constructor-io/constructorio-connect-cli 1.5.2 → 1.6.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/dist/commands/execute.d.ts.map +1 -1
- package/dist/commands/generate-fixture.d.ts.map +1 -1
- package/dist/commands/generate-fixture.js +6 -2
- 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/customer/path.d.ts.map +1 -1
- package/dist/customer/path.js +17 -4
- package/dist/functions/build-fixture.d.ts.map +1 -1
- package/dist/functions/build-fixture.js +5 -1
- package/dist/functions/execute-template.d.ts.map +1 -1
- package/dist/functions/execute-template.js +8 -2
- package/dist/helpers/build-config-file.d.ts +1 -8
- package/dist/helpers/build-config-file.d.ts.map +1 -1
- package/dist/helpers/build-config-file.js +21 -9
- package/dist/helpers/file-loaders.js +3 -3
- package/dist/prompt-data/filter-connections-by-template.d.ts.map +1 -1
- package/dist/prompt-data/filter-connections-by-template.js +9 -3
- package/dist/prompt-data/get-candidate-fixtures.d.ts.map +1 -1
- package/dist/prompt-data/get-candidate-fixtures.js +3 -3
- package/dist/prompt-data/get-external-data-files.d.ts.map +1 -1
- package/dist/prompt-data/get-external-data-files.js +3 -2
- package/dist/prompt-data/get-template-files.d.ts.map +1 -1
- package/dist/prompt-data/get-template-files.js +9 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +7 -6
- package/boilerplate-repo/src/templates/grouping/grouping.jsonata +0 -37
- package/boilerplate-repo/test/templates/grouping/grouping.spec.mjs +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAM,MAAM,aAAa,CAAC;AA6BjD,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;;GAGG;AACH,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAYD,qBAAa,OAAQ,SAAQ,OAAO;IAClC,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAiCZ,UAAU;YAsBV,oBAAoB;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAM,MAAM,aAAa,CAAC;AA6BjD,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;;GAGG;AACH,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAYD,qBAAa,OAAQ,SAAQ,OAAO;IAClC,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAiCZ,UAAU;YAsBV,oBAAoB;YA+CpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-fixture.d.ts","sourceRoot":"","sources":["../../src/commands/generate-fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-fixture.d.ts","sourceRoot":"","sources":["../../src/commands/generate-fixture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAIhB;IAEF,MAAM,CAAC,QAAQ,WAA4C;IAErD,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IA6DzB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU9C"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"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 });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
3
7
|
const core_1 = require("@oclif/core");
|
|
4
8
|
const fs_extra_1 = require("fs-extra");
|
|
5
9
|
const prompts_1 = require("@inquirer/prompts");
|
|
@@ -10,7 +14,7 @@ const types_1 = require("../types");
|
|
|
10
14
|
const get_fixture_1 = require("../http/get-fixture");
|
|
11
15
|
const get_connections_request_1 = require("../http/get-connections-request");
|
|
12
16
|
const file_exists_1 = require("../helpers/file-exists");
|
|
13
|
-
const
|
|
17
|
+
const path_2 = require("../customer/path");
|
|
14
18
|
class GenerateFixture extends core_1.Command {
|
|
15
19
|
static args = {};
|
|
16
20
|
static description = `
|
|
@@ -71,7 +75,7 @@ Finally, if the file already exists you'll be prompted to overwrite it.
|
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
getFixturePath(type, filename) {
|
|
74
|
-
return (0,
|
|
78
|
+
return (0, path_2.getCustomerPath)(path_1.default.join("src", "fixtures", type, filename.replace(/\.[^/.]+$/, "") + ".json"));
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
exports.default = GenerateFixture;
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/customer/path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/customer/path.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,UAE3C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAI3D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAI1D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAI/D"}
|
package/dist/customer/path.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"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.getCustomerPath = getCustomerPath;
|
|
4
7
|
exports.cleanupTemplatePath = cleanupTemplatePath;
|
|
@@ -6,6 +9,7 @@ exports.cleanupFixturePath = cleanupFixturePath;
|
|
|
6
9
|
exports.cleanupExternalDataPath = cleanupExternalDataPath;
|
|
7
10
|
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
|
|
8
11
|
const path_1 = require("path");
|
|
12
|
+
const os_1 = __importDefault(require("os"));
|
|
9
13
|
/**
|
|
10
14
|
* @returns The provided path prepended with the root directory.
|
|
11
15
|
*/
|
|
@@ -19,7 +23,7 @@ function getCustomerPath(path) {
|
|
|
19
23
|
* be added later on when reading the files.
|
|
20
24
|
*/
|
|
21
25
|
function cleanupTemplatePath(path) {
|
|
22
|
-
return cleanupAbsolutePath(path).replace("
|
|
26
|
+
return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "templates"), ""));
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* Cleans up the fixture path, removing the root directory and the 'src/fixtures' prefix.
|
|
@@ -28,7 +32,7 @@ function cleanupTemplatePath(path) {
|
|
|
28
32
|
* be added later on when reading the files.
|
|
29
33
|
*/
|
|
30
34
|
function cleanupFixturePath(path) {
|
|
31
|
-
return cleanupAbsolutePath(path).replace("
|
|
35
|
+
return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "fixtures"), ""));
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Cleans up the external data path, removing the root directory and the 'src/external-data' prefix.
|
|
@@ -37,11 +41,20 @@ function cleanupFixturePath(path) {
|
|
|
37
41
|
* be added later on when reading the files.
|
|
38
42
|
*/
|
|
39
43
|
function cleanupExternalDataPath(path) {
|
|
40
|
-
return cleanupAbsolutePath(path).replace("
|
|
44
|
+
return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "external-data"), ""));
|
|
41
45
|
}
|
|
42
46
|
function cleanupAbsolutePath(path) {
|
|
43
47
|
if (!path) {
|
|
44
48
|
return "";
|
|
45
49
|
}
|
|
46
|
-
|
|
50
|
+
const replacedPath = path.replace(process.cwd(), "");
|
|
51
|
+
return cleanupDelimiters(replacedPath);
|
|
52
|
+
}
|
|
53
|
+
function cleanupDelimiters(path) {
|
|
54
|
+
const platformFileDelimiter = os_1.default.platform() === "win32" ? "\\" : "/";
|
|
55
|
+
let replacedPath = path.replace(process.cwd(), "");
|
|
56
|
+
if (replacedPath.startsWith(`${platformFileDelimiter}${platformFileDelimiter}`)) {
|
|
57
|
+
replacedPath = replacedPath.slice(2);
|
|
58
|
+
}
|
|
59
|
+
return replacedPath;
|
|
47
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,SACjB,MAAM,QACN,MAAM,iBACE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAKtC,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"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.buildFixture = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const remeda_1 = require("remeda");
|
|
5
9
|
const file_loaders_1 = require("../helpers/file-loaders");
|
|
6
10
|
/**
|
|
@@ -15,7 +19,7 @@ const file_loaders_1 = require("../helpers/file-loaders");
|
|
|
15
19
|
* @returns Record<string, unknown> The fixture data
|
|
16
20
|
*/
|
|
17
21
|
const buildFixture = (type, name, dataOverride = {}) => {
|
|
18
|
-
const data = (0, file_loaders_1.getCatalogFixture)(
|
|
22
|
+
const data = (0, file_loaders_1.getCatalogFixture)(path_1.default.join(type, name));
|
|
19
23
|
return (0, remeda_1.mergeDeep)(data, dataOverride);
|
|
20
24
|
};
|
|
21
25
|
exports.buildFixture = buildFixture;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"
|
|
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,7 +1,12 @@
|
|
|
1
1
|
"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.TYPE_OPTIONS = void 0;
|
|
4
7
|
exports.executeTemplate = executeTemplate;
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
5
10
|
const send_template_execute_request_1 = require("../http/send-template-execute-request");
|
|
6
11
|
const template_source_code_1 = require("../customer/template-source-code");
|
|
7
12
|
const file_loaders_1 = require("../helpers/file-loaders");
|
|
@@ -56,8 +61,9 @@ function initializeOptions(options) {
|
|
|
56
61
|
if (!options.name) {
|
|
57
62
|
throw new Error("No name provided");
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
const platformFileDelimiter = os_1.default.platform() === "win32" ? "\\" : "/";
|
|
65
|
+
if (!options.name.includes(platformFileDelimiter)) {
|
|
66
|
+
options.name = path_1.default.join(options.type, options.name);
|
|
61
67
|
}
|
|
62
68
|
if (!options.fixture) {
|
|
63
69
|
options.fixture = {};
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 1. Receive connections list, and transform it into the connections dictionary.
|
|
3
|
-
* - Store only connectionId, name, and slug.
|
|
4
|
-
* 2. Create the config object from a default config.
|
|
5
|
-
* 3. Create a connections environments array by making a filtered array of connections for each environment.
|
|
6
|
-
* 4. Map each object in the environments array to expand out
|
|
7
|
-
*/
|
|
8
1
|
import { type ConnectionResponseDto } from "../http/get-connections-request";
|
|
9
2
|
import { type Config, type ConnectionConfigDict } from "../types";
|
|
10
|
-
export declare function buildConfigFromConnections(connections: ConnectionResponseDto[]): Config;
|
|
3
|
+
export declare function buildConfigFromConnections(connections: ConnectionResponseDto[], shouldCreateMappingTemplates: boolean): Config;
|
|
11
4
|
export declare function buildConnectionsDictFromList(connections: ConnectionResponseDto[]): ConnectionConfigDict;
|
|
12
5
|
export declare function buildConfigString(config: Config, connections: ConnectionConfigDict): string;
|
|
13
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":"
|
|
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"}
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
"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.buildConfigFromConnections = buildConfigFromConnections;
|
|
4
7
|
exports.buildConnectionsDictFromList = buildConnectionsDictFromList;
|
|
5
8
|
exports.buildConfigString = buildConfigString;
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 1. Receive connections list, and transform it into the connections dictionary.
|
|
11
|
+
* - Store only connectionId, name, and slug.
|
|
12
|
+
* 2. Create the config object from a default config.
|
|
13
|
+
* 3. Create a connections environments array by making a filtered array of connections for each environment.
|
|
14
|
+
* 4. Map each object in the environments array to expand out
|
|
15
|
+
*/
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
function buildConfigFromConnections(connections, shouldCreateMappingTemplates) {
|
|
7
18
|
const environments = getUniqueConnectionEnvs(connections);
|
|
8
19
|
return {
|
|
9
20
|
template_repository_version: "1.0.0",
|
|
10
|
-
helpers: "src
|
|
11
|
-
environments: buildTemplateEnvironments(environments, connections),
|
|
21
|
+
helpers: path_1.default.join("src", "templates", "helpers.jsonata"),
|
|
22
|
+
environments: buildTemplateEnvironments(environments, connections, shouldCreateMappingTemplates),
|
|
12
23
|
};
|
|
13
24
|
}
|
|
14
25
|
function buildConnectionsDictFromList(connections) {
|
|
@@ -30,7 +41,7 @@ function getUniqueConnectionEnvs(connections) {
|
|
|
30
41
|
return envs;
|
|
31
42
|
}, []);
|
|
32
43
|
}
|
|
33
|
-
function buildTemplateEnvironments(environments, connections) {
|
|
44
|
+
function buildTemplateEnvironments(environments, connections, shouldCreateMappingTemplates) {
|
|
34
45
|
return environments.map((env) => {
|
|
35
46
|
return {
|
|
36
47
|
environment: env,
|
|
@@ -40,11 +51,12 @@ function buildTemplateEnvironments(environments, connections) {
|
|
|
40
51
|
.filter((conn) => conn.environment === env)
|
|
41
52
|
.map((conn) => conn.id),
|
|
42
53
|
paths: {
|
|
43
|
-
item: "src
|
|
44
|
-
variation: "src
|
|
45
|
-
item_group: "src
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
item: path_1.default.join("src", "templates", "item", "item.jsonata"),
|
|
55
|
+
variation: path_1.default.join("src", "templates", "variation", "variation.jsonata"),
|
|
56
|
+
item_group: path_1.default.join("src", "templates", "item_group", "item_group.jsonata"),
|
|
57
|
+
...(shouldCreateMappingTemplates && {
|
|
58
|
+
mapping: path_1.default.join("src", "templates", "mapping", "mapping.jsonata"),
|
|
59
|
+
}),
|
|
48
60
|
},
|
|
49
61
|
},
|
|
50
62
|
],
|
|
@@ -10,17 +10,17 @@ const errors_1 = require("@oclif/core/lib/errors");
|
|
|
10
10
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
11
11
|
const path_2 = require("../customer/path");
|
|
12
12
|
exports.getCatalogFixture = createFileLoader({
|
|
13
|
-
prefix: "src
|
|
13
|
+
prefix: path_1.default.join("src", "fixtures"),
|
|
14
14
|
fileLoader: fs_extra_1.default.readJSONSync,
|
|
15
15
|
suggestions: ["Ensure the file is a valid JSON file"],
|
|
16
16
|
});
|
|
17
17
|
exports.getExternalDataFixture = createFileLoader({
|
|
18
|
-
prefix: "src
|
|
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"],
|
|
21
21
|
});
|
|
22
22
|
exports.getJSONataTemplate = createFileLoader({
|
|
23
|
-
prefix: "src
|
|
23
|
+
prefix: path_1.default.join("src", "templates"),
|
|
24
24
|
fileLoader: fs_extra_1.default.readFileSync,
|
|
25
25
|
});
|
|
26
26
|
function createFileLoader({ prefix, fileLoader, suggestions = [], }) {
|
|
@@ -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;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,EAAE,GACnC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,
|
|
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,CA2C/C"}
|
|
@@ -12,13 +12,19 @@ const config_1 = require("../customer/config");
|
|
|
12
12
|
*/
|
|
13
13
|
async function filterConnectionsByTemplate(templatePath, connections) {
|
|
14
14
|
const config = await (0, config_1.getRepositoryConfigFile)();
|
|
15
|
-
const
|
|
15
|
+
const prefix = path_1.default.join("src", "templates");
|
|
16
|
+
let fullPath = templatePath;
|
|
17
|
+
if (!templatePath.startsWith(prefix)) {
|
|
18
|
+
fullPath = path_1.default.join(prefix, templatePath);
|
|
19
|
+
}
|
|
16
20
|
// All connection ids that references this template
|
|
17
21
|
const configConnectionIds = config.environments.reduce((connectionIds, environment) => {
|
|
18
22
|
for (const templateConfig of environment.templates) {
|
|
19
|
-
const templatePaths = Object.values(templateConfig.paths)
|
|
23
|
+
const templatePaths = Object.values(templateConfig.paths)
|
|
24
|
+
.map((filePath) => path_1.default.normalize(path_1.default.resolve(filePath)))
|
|
25
|
+
.map((filePath) => filePath.replace(/\\/g, "/")); // this is needed to check the path in all OS
|
|
20
26
|
// environment doesn't even target this template
|
|
21
|
-
if (!templatePaths.includes(fullPath)) {
|
|
27
|
+
if (!templatePaths.includes(path_1.default.resolve(fullPath).replace(/\\/g, "/"))) {
|
|
22
28
|
continue;
|
|
23
29
|
}
|
|
24
30
|
for (const id of templateConfig.connection_ids) {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAqDvB"}
|
|
@@ -25,7 +25,7 @@ function getCandidateFixtures(templatePath) {
|
|
|
25
25
|
: templateType;
|
|
26
26
|
let fixtureFullPaths;
|
|
27
27
|
try {
|
|
28
|
-
fixtureFullPaths = (0, find_deep_files_1.findDeepFiles)(
|
|
28
|
+
fixtureFullPaths = (0, find_deep_files_1.findDeepFiles)(path_1.default.join("src", "fixtures", fixtureType));
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
31
|
if (error instanceof Error && error.message.includes("ENOENT")) {
|
|
@@ -41,7 +41,7 @@ function getCandidateFixtures(templatePath) {
|
|
|
41
41
|
return fixtureFullPaths
|
|
42
42
|
.filter((fixturePath) => path_1.default.extname(fixturePath) === ".json")
|
|
43
43
|
.map((fixturePath) => {
|
|
44
|
-
const fixtureRelativePath = path_1.default.relative("src
|
|
44
|
+
const fixtureRelativePath = path_1.default.relative(path_1.default.join("src", "fixtures"), fixturePath);
|
|
45
45
|
return {
|
|
46
46
|
name: fixtureRelativePath,
|
|
47
47
|
value: fixtureRelativePath,
|
|
@@ -53,7 +53,7 @@ function getCandidateFixtures(templatePath) {
|
|
|
53
53
|
*/
|
|
54
54
|
function extractTemplateType(templatePath) {
|
|
55
55
|
for (const type of types_1.TemplateTypes) {
|
|
56
|
-
if (templatePath.includes(`${type}/`)) {
|
|
56
|
+
if (templatePath.includes(path_1.default.join(`${type}/`))) {
|
|
57
57
|
return type;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -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,
|
|
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"}
|
|
@@ -8,10 +8,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const find_deep_files_1 = require("../helpers/find-deep-files");
|
|
9
9
|
function getExternalDataFiles() {
|
|
10
10
|
try {
|
|
11
|
-
|
|
11
|
+
const filePath = path_1.default.join("src", "fixtures", "external_data");
|
|
12
|
+
return (0, find_deep_files_1.findDeepFiles)(filePath)
|
|
12
13
|
.filter((file) => path_1.default.extname(file) === ".json")
|
|
13
14
|
.map((file) => {
|
|
14
|
-
const relativePath = path_1.default.relative(
|
|
15
|
+
const relativePath = path_1.default.relative(filePath, file);
|
|
15
16
|
return {
|
|
16
17
|
name: relativePath,
|
|
17
18
|
value: relativePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"
|
|
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;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAavE"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
"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.getTemplateFiles = getTemplateFiles;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const find_deep_files_1 = require("../helpers/find-deep-files");
|
|
5
9
|
/**
|
|
6
10
|
* Get a prompt-ready list of template files in the user repository
|
|
7
11
|
*/
|
|
8
12
|
async function getTemplateFiles() {
|
|
9
|
-
const
|
|
13
|
+
const filePath = path_1.default.join("src", "templates");
|
|
14
|
+
const files = getTemplatePaths(filePath);
|
|
10
15
|
const filteredFiles = files.filter((file) => file.endsWith(".jsonata") && !file.includes("helpers"));
|
|
16
|
+
const filePathSlash = path_1.default.join(filePath, " ").trim(); // needed to add a space to the end to avoid removing the last slash
|
|
11
17
|
return filteredFiles.map((file) => ({
|
|
12
|
-
name: file.replace(
|
|
13
|
-
value: file.replace(
|
|
18
|
+
name: file.replace(filePathSlash, ""),
|
|
19
|
+
value: file.replace(filePathSlash, ""),
|
|
14
20
|
}));
|
|
15
21
|
}
|
|
16
22
|
/**
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-connect-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"build": "tsc --project tsconfig.production.json",
|
|
24
24
|
"prebuild": "shx rm -rf dist",
|
|
25
25
|
"type-check": "tsc --noemit",
|
|
26
|
-
"test": "TZ=UTC node --trace-warnings node_modules/.bin/jest",
|
|
27
|
-
"test:verbose": "TZ=UTC VERBOSE=true jest",
|
|
28
|
-
"test:debug": "TZ=UTC node --inspect-brk -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
29
|
-
"test:watch": "TZ=UTC jest --watch",
|
|
30
|
-
"test:cov": "TZ=UTC jest --coverage",
|
|
26
|
+
"test": "cross-env TZ=UTC node --trace-warnings node_modules/.bin/jest",
|
|
27
|
+
"test:verbose": "cross-env TZ=UTC VERBOSE=true jest",
|
|
28
|
+
"test:debug": "cross-env TZ=UTC node --inspect-brk -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
29
|
+
"test:watch": "cross-env TZ=UTC jest --watch",
|
|
30
|
+
"test:cov": "cross-env TZ=UTC jest --coverage",
|
|
31
31
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
|
|
32
32
|
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
33
33
|
"license-check": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;BSD-2-Clause;ISC;MIT;0BSD'",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"@types/fs-extra": "^11.0.4",
|
|
80
80
|
"@types/jest": "^29.5.12",
|
|
81
81
|
"@types/mock-fs": "^4.13.4",
|
|
82
|
+
"cross-env": "^7.0.3",
|
|
82
83
|
"eslint": "^8.57.0",
|
|
83
84
|
"eslint-config-prettier": "^9.1.0",
|
|
84
85
|
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
@@ -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
|
-
});
|