@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.
- package/boilerplate-repo/README.md +7 -7
- package/dist/commands/execute.d.ts +1 -1
- package/dist/commands/execute.js +7 -7
- package/dist/functions/execute-template.d.ts +2 -2
- package/dist/functions/execute-template.d.ts.map +1 -1
- package/dist/functions/execute-template.js +6 -6
- package/dist/helpers/file-loaders.d.ts +1 -1
- package/dist/helpers/file-loaders.d.ts.map +1 -1
- package/dist/helpers/file-loaders.js +2 -2
- package/dist/http/send-template-execute-request.d.ts +3 -3
- package/dist/http/send-template-execute-request.d.ts.map +1 -1
- package/dist/http/send-template-execute-request.js +3 -3
- package/dist/prompt-data/get-external-data-files.d.ts +1 -1
- package/dist/prompt-data/get-external-data-files.d.ts.map +1 -1
- package/dist/prompt-data/get-external-data-files.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -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 `
|
|
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
|
-
|
|
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":
|
|
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 :=
|
|
355
|
-
$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 :=
|
|
369
|
-
$parentId :=
|
|
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
|
|
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
|
/**
|
package/dist/commands/execute.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
? (0, file_loaders_1.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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
|
-
|
|
44
|
+
data: fixture,
|
|
45
45
|
showLogs: false,
|
|
46
|
-
|
|
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.
|
|
77
|
-
options.
|
|
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
|
|
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,
|
|
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.
|
|
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.
|
|
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,
|
|
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
|
-
|
|
7
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
15
|
-
|
|
14
|
+
data,
|
|
15
|
+
external,
|
|
16
16
|
connection_id: connectionId,
|
|
17
17
|
template_type: templateType,
|
|
18
18
|
})).data;
|
|
@@ -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,
|
|
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.
|
|
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
|
|
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
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.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.
|
|
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",
|