@constructor-io/constructorio-connect-cli 1.15.7 → 1.16.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/README.md +18 -8
- package/boilerplate-repo/README.md +161 -86
- package/boilerplate-repo/gitignore +35 -0
- package/dist/commands/execute.d.ts +2 -0
- package/dist/commands/execute.d.ts.map +1 -1
- package/dist/commands/execute.js +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +6 -0
- package/dist/functions/execute-template.d.ts +1 -0
- package/dist/functions/execute-template.d.ts.map +1 -1
- package/dist/functions/execute-template.js +2 -1
- package/dist/http/send-template-execute-request.d.ts +2 -1
- package/dist/http/send-template-execute-request.d.ts.map +1 -1
- package/dist/http/send-template-execute-request.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/oclif.manifest.json +8 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -3,18 +3,25 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@constructor-io/constructorio-connect-cli)
|
|
4
4
|
[](https://github.com/Constructor-io/constructorio-connect-cli/blob/master/LICENSE)
|
|
5
5
|
|
|
6
|
-
Constructor.io is an e-commerce first product discovery service that optimizes results using artificial intelligence
|
|
6
|
+
Constructor.io is an e-commerce first product discovery service that optimizes results using artificial intelligence
|
|
7
|
+
(including natural language processing, re-ranking to optimize for business metrics, and end user personalization).
|
|
7
8
|
|
|
8
|
-
This package is a CLI tool that helps you **build, test and deploy your connector templates**.
|
|
9
|
+
This package is a CLI tool that helps you **build, test and deploy your connector templates**.
|
|
10
|
+
By using templates, you can customize your catalog integration to shape your data the way you want it.
|
|
9
11
|
|
|
10
|
-
> If you're looking for a package to consume our API, please use
|
|
12
|
+
> If you're looking for a package to consume our API, please use
|
|
13
|
+
> [@constructor-io/constructorio-node](https://github.com/Constructor-io/constructorio-node) instead.
|
|
14
|
+
> Alternatively, if you want a JavaScript client for client side (i.e. front end) integrations please use [@constructor-io/constructorio-client-javascript](https://github.com/Constructor-io/constructorio-client-javascript).
|
|
11
15
|
|
|
12
16
|
## 1. Review the Requirements
|
|
13
17
|
|
|
14
|
-
Before you begin, note that this package is intended for use with partner connections.
|
|
15
|
-
running yet, please take a look at
|
|
18
|
+
Before you begin, note that this package is intended for use with partner connections.
|
|
19
|
+
If you don't have a connector running yet, please take a look at
|
|
20
|
+
[our documentation](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors)
|
|
21
|
+
to see how you can get started.
|
|
16
22
|
|
|
17
|
-
Finally, make sure you have your **Index Key** and **API token** available.
|
|
23
|
+
Finally, make sure you have your **Index Key** and **API token** available.
|
|
24
|
+
If you don't have this yet, please get in touch with our team and we'll set this up.
|
|
18
25
|
|
|
19
26
|
## 2. Install
|
|
20
27
|
|
|
@@ -26,7 +33,9 @@ npx @constructor-io/constructorio-connect-cli init my-repo
|
|
|
26
33
|
|
|
27
34
|
Where `my-repo` is the name of the folder and repository you want to create.
|
|
28
35
|
|
|
29
|
-
With the new repository initialized, you can start developing your catalog integration.
|
|
36
|
+
With the new repository initialized, you can start developing your catalog integration.
|
|
37
|
+
Please refer to our [documentation](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors)
|
|
38
|
+
for more information on how to build your templates.
|
|
30
39
|
|
|
31
40
|
## 3. Commands
|
|
32
41
|
|
|
@@ -79,7 +88,7 @@ Execute a template against a connection and fixture to see the resulting transfo
|
|
|
79
88
|
```
|
|
80
89
|
USAGE
|
|
81
90
|
$ constructorio-connect-cli execute [--template-path <value>] [--fixture-path <value>]
|
|
82
|
-
[--external-data-path <value>] [--connection-id <value>]
|
|
91
|
+
[--external-data-path <value>] [--connection-id <value>] [--override-date <value>]
|
|
83
92
|
|
|
84
93
|
FLAGS
|
|
85
94
|
--connection-id=<value> The ID of the connection to execute the template against.
|
|
@@ -87,6 +96,7 @@ FLAGS
|
|
|
87
96
|
'src/fixtures/external_data' directory.
|
|
88
97
|
--fixture-path=<value> The path to the fixture to execute the template against. Must be in the 'src/fixtures'
|
|
89
98
|
directory.
|
|
99
|
+
--override-date=<value> Date with which to override $now and $millis in the template.
|
|
90
100
|
--template-path=<value> The path to the template to execute. Must be in the 'src/templates' directory.
|
|
91
101
|
|
|
92
102
|
DESCRIPTION
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Constructor.io Connect CLI Repository
|
|
2
2
|
|
|
3
|
-
This repository was created using the
|
|
3
|
+
This repository was created using the
|
|
4
|
+
[constructorio-connect-cli CLI](https://www.npmjs.com/package/@constructor-io/constructorio-connect-cli).
|
|
5
|
+
It is intended to be used as a workspace for developing custom templates for the Constructor Connect platform.
|
|
4
6
|
|
|
5
7
|
## Table of Contents
|
|
6
8
|
|
|
@@ -40,33 +42,46 @@ This repository was created using the [constructorio-connect-cli CLI](https://ww
|
|
|
40
42
|
- [Result](#result)
|
|
41
43
|
- [5️⃣ Sharing code across templates](#5️⃣-sharing-code-across-templates)
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
## Getting Started
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
### Configuring Authentication with the Connect API
|
|
46
48
|
|
|
47
|
-
Before you can deploy and test templates on the Constructor Connect platform, you'll need to setup your local environment.
|
|
48
|
-
to create a
|
|
49
|
+
Before you can deploy and test templates on the Constructor Connect platform, you'll need to setup your local environment.
|
|
50
|
+
Primarily, you will need to create a `.env` file with the contents of `.env.example` and fill in the
|
|
51
|
+
`CONNECT_AUTH_TOKEN` variable with your Constructor Connect Auth token.
|
|
52
|
+
This will be necessary to test templates against the Connect API and deploy them to the platform.
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
### Associating Templates with Connections
|
|
51
55
|
|
|
52
|
-
With that configured, visit the `connectrc.js` file.
|
|
56
|
+
With that configured, visit the `connectrc.js` file.
|
|
57
|
+
This is where you can describe the relationships between your templates and the connections you want to use them with.
|
|
58
|
+
Any arbitrary list of connections (identified by their ID) can be connected with any of your template files.
|
|
59
|
+
You can create as many of these relationships as you need, with the following restrictions:
|
|
53
60
|
|
|
54
61
|
- A connection can only be associated with one set of templates.
|
|
55
|
-
- The environment declared for each relationship must match the environment for all connections that belong to it
|
|
62
|
+
- The environment declared for each relationship must match the environment for all connections that belong to it
|
|
63
|
+
(e.g. only development connections may be listed in a relationship configured with `environment: "development"`)
|
|
56
64
|
|
|
57
|
-
An example with a single placeholder connection ID is provided in the `connectrc.js` by default.
|
|
65
|
+
An example with a single placeholder connection ID is provided in the `connectrc.js` by default.
|
|
66
|
+
Replacing the example with your connection ID(s) and adjusting the example template source code according to your needs
|
|
67
|
+
is the quickest way to get a set of working templates.
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
## Generate Fixture
|
|
60
70
|
|
|
61
|
-
Once you have written some templates and you would like to quickly test their output,
|
|
71
|
+
Once you have written some templates and you would like to quickly test their output,
|
|
72
|
+
you can use the `generate-fixture` command.
|
|
73
|
+
This command will create a new fixture file based in your connection and the type.
|
|
62
74
|
|
|
63
|
-
This file serves as an example of how the data would be passed to the connector when executing the templates.
|
|
75
|
+
This file serves as an example of how the data would be passed to the connector when executing the templates.
|
|
76
|
+
You're expected to customize this file to match the data you expect to cover in a template execution.
|
|
77
|
+
If the file already exists, you'll be prompted to overwrite it.
|
|
64
78
|
|
|
65
|
-
In summary, this command is a crucial part of testing your templates on the Constructor Connect platform.
|
|
79
|
+
In summary, this command is a crucial part of testing your templates on the Constructor Connect platform.
|
|
80
|
+
It allows you to generate test data, customize it to your needs, and see how your templates will handle it.
|
|
66
81
|
|
|
67
|
-
|
|
82
|
+
### `npm run generate-fixture`
|
|
68
83
|
|
|
69
|
-
```
|
|
84
|
+
```console
|
|
70
85
|
USAGE
|
|
71
86
|
$ constructorio-connect-cli generate-fixture
|
|
72
87
|
|
|
@@ -84,9 +99,9 @@ EXAMPLES
|
|
|
84
99
|
$ constructorio-connect-cli generate-fixture
|
|
85
100
|
```
|
|
86
101
|
|
|
87
|
-
|
|
102
|
+
### `npm run trigger-catalog-sync`
|
|
88
103
|
|
|
89
|
-
```
|
|
104
|
+
```console
|
|
90
105
|
USAGE
|
|
91
106
|
$ constructorio-connect-cli trigger-catalog-sync
|
|
92
107
|
|
|
@@ -101,17 +116,23 @@ EXAMPLES
|
|
|
101
116
|
$ constructorio-connect-cli trigger-catalog-sync
|
|
102
117
|
```
|
|
103
118
|
|
|
104
|
-
|
|
119
|
+
## Executing Templates
|
|
105
120
|
|
|
106
|
-
Once you have written some templates and you would like to quickly test their output, you can use the `execute` command.
|
|
121
|
+
Once you have written some templates and you would like to quickly test their output, you can use the `execute` command.
|
|
122
|
+
This command will allow you to see the result of executing your template against a specific fixture of JSON catalog data.
|
|
107
123
|
|
|
108
|
-
Based on the template you provide, the connections existing on your account, and the configuration in your
|
|
124
|
+
Based on the template you provide, the connections existing on your account, and the configuration in your
|
|
125
|
+
`connectrc.js` file, you will be prompted with choices of fixture files and connections to execute against.
|
|
126
|
+
Alternatively, you can provide all of these upfront as flags to the command (see below).
|
|
127
|
+
This is especially useful if you want to repeat execution on the same set of templates
|
|
128
|
+
and fixtures as you iterate without having to step through the prompts each time.
|
|
109
129
|
|
|
110
|
-
**💡 Tip:** this repo also provides a built in VSCode integration. If you have any template file open, just hit `F5`
|
|
130
|
+
**💡 Tip:** this repo also provides a built in VSCode integration. If you have any template file open, just hit `F5`
|
|
131
|
+
or launch it from the debugger menu to execute the template and see the results immediately.
|
|
111
132
|
|
|
112
|
-
|
|
133
|
+
### `npm run execute [FLAGS]`
|
|
113
134
|
|
|
114
|
-
```
|
|
135
|
+
```console
|
|
115
136
|
USAGE
|
|
116
137
|
$ npm run execute -- [--template-path <value>] [--fixture-path <value>] [--external-data-path <value>] [--connection-id <value>]
|
|
117
138
|
|
|
@@ -134,19 +155,24 @@ EXAMPLES
|
|
|
134
155
|
$ npm run execute -- --template-path=grouping/grouping.jsonata --connection-id=example-connection-id
|
|
135
156
|
```
|
|
136
157
|
|
|
137
|
-
|
|
158
|
+
## Testing templates
|
|
138
159
|
|
|
139
|
-
This project also includes a test suite that leverages Jest to run tests.
|
|
160
|
+
This project also includes a test suite that leverages Jest to run tests.
|
|
161
|
+
To test your templates, you can use the `npm run test` command.
|
|
140
162
|
|
|
141
|
-
By running `npm run test`, Jest will search for all files with the `.test.js` or `.spec.js` extension
|
|
163
|
+
By running `npm run test`, Jest will search for all files with the `.test.js` or `.spec.js` extension
|
|
164
|
+
in the project and execute the corresponding tests.
|
|
142
165
|
|
|
143
|
-
As a best practice, you should have at least one snapshot test to ensure the result of your template.
|
|
166
|
+
As a best practice, you should have at least one snapshot test to ensure the result of your template.
|
|
167
|
+
You cna also add any logical tests to cover any rules you add to your templates,
|
|
168
|
+
such as "calculating the average price of your variations".
|
|
169
|
+
If you need to, you can update your snapshots with the `--updateSnapshot` flag.
|
|
144
170
|
|
|
145
171
|
Finally, note that console logs are disabled during tests. To see all logs, you can use the `--verbose` flag.
|
|
146
172
|
|
|
147
|
-
|
|
173
|
+
### `npm run test [FLAGS]`
|
|
148
174
|
|
|
149
|
-
```
|
|
175
|
+
```console
|
|
150
176
|
USAGE
|
|
151
177
|
$ npm run test -- [FLAGS]
|
|
152
178
|
|
|
@@ -166,21 +192,23 @@ EXAMPLES
|
|
|
166
192
|
$ npm run test -- --updateSnapshot
|
|
167
193
|
```
|
|
168
194
|
|
|
169
|
-
|
|
195
|
+
## Deploying Templates
|
|
170
196
|
|
|
171
|
-
Once you have developed and tested your templates, you can deploy them to the Constructor Connect platform.
|
|
197
|
+
Once you have developed and tested your templates, you can deploy them to the Constructor Connect platform.
|
|
198
|
+
To do this, you can use the `deploy` command.
|
|
172
199
|
|
|
173
|
-
|
|
200
|
+
### Deploying via GitHub Actions
|
|
174
201
|
|
|
175
|
-
This repository is pre-configured to deploy templates to Constructor Connect using GitHub Actions.
|
|
202
|
+
This repository is pre-configured to deploy templates to Constructor Connect using GitHub Actions.
|
|
203
|
+
To do this, you will need to set up the following secrets in your GitHub repository:
|
|
176
204
|
|
|
177
205
|
- `CONNECT_AUTH_TOKEN`: Your Constructor Connect Auth token. It's the same used to initialize this repo.
|
|
178
206
|
|
|
179
207
|
After setting up the secrets, you can run the `Deploy` workflow from the Actions tab in your repository.
|
|
180
208
|
|
|
181
|
-
|
|
209
|
+
### `npm run deploy ENV`
|
|
182
210
|
|
|
183
|
-
```
|
|
211
|
+
```console
|
|
184
212
|
USAGE
|
|
185
213
|
$ npm run deploy ENV
|
|
186
214
|
|
|
@@ -201,25 +229,30 @@ EXAMPLES
|
|
|
201
229
|
$ npm run deploy production
|
|
202
230
|
```
|
|
203
231
|
|
|
204
|
-
|
|
232
|
+
## Developing Templates
|
|
205
233
|
|
|
206
|
-
|
|
234
|
+
### ➡️ Expected Transformer Implementation
|
|
207
235
|
|
|
208
236
|
To implement your very own transformers, you just need to edit the `.jsonata` files inside the `templates` folder.
|
|
209
237
|
|
|
210
|
-
Keep in mind that the template will have access to `external` and `data`.
|
|
238
|
+
Keep in mind that the template will have access to `external` and `data`.
|
|
239
|
+
You can use the `data` to access the data that is being ingested, and `external` to access the data available in the connector.
|
|
211
240
|
|
|
212
|
-
Note that all template files must return the expected data types.
|
|
241
|
+
Note that all template files must return the expected data types.
|
|
242
|
+
To know which properties you can override inside `item`, `variation` or `item_group`, take a look into the type definitions:
|
|
213
243
|
|
|
214
244
|
- [Item](https://docs.constructor.com/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-items-products)
|
|
215
245
|
- [Variation](https://docs.constructor.com/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-variations)
|
|
216
246
|
- [Item Group](https://docs.constructor.com/docs/integrating-with-constructor-product-catalog-csv-csv-feed-format-item-groups-categories)
|
|
217
247
|
|
|
218
|
-
You can also refer to the [Constructor API docs](https://docs.constructor.com/reference/v1-catalog-create-or-replace-catalog)
|
|
248
|
+
You can also refer to the [Constructor API docs](https://docs.constructor.com/reference/v1-catalog-create-or-replace-catalog)
|
|
249
|
+
for more details.
|
|
219
250
|
|
|
220
|
-
|
|
251
|
+
### 🗑️ Removing Entities
|
|
221
252
|
|
|
222
|
-
You can also remove any item, variation, or item group through our templates.
|
|
253
|
+
You can also remove any item, variation, or item group through our templates.
|
|
254
|
+
Suppose each product on your catalog has a `visible` boolean field.
|
|
255
|
+
It could make sense to not even ingest them into [Constructor.io](https://constructor.io/).
|
|
223
256
|
|
|
224
257
|
We can make this happen returning `{ "remove": true }` whenever we find an item we want to drop from the ingestion:
|
|
225
258
|
|
|
@@ -233,26 +266,39 @@ We can make this happen returning `{ "remove": true }` whenever we find an item
|
|
|
233
266
|
)
|
|
234
267
|
```
|
|
235
268
|
|
|
236
|
-
|
|
269
|
+
### 🍙 Grouping logic
|
|
237
270
|
|
|
238
|
-
You can use the `grouping.jsonata` template to group variations into the item level.
|
|
271
|
+
You can use the `grouping.jsonata` template to group variations into the item level.
|
|
272
|
+
This can be helpful, for example, if you want to ingest data while grouping your items with a specific criteria (e.g. color).
|
|
239
273
|
|
|
240
274
|
To do this, you need to define a grouping template with the `grouping` key.
|
|
241
275
|
|
|
242
276
|
Refer to the examples below for more information.
|
|
243
277
|
|
|
244
|
-
|
|
278
|
+
### 🗺️ Mapping logic
|
|
245
279
|
|
|
246
280
|
You can use the `mapping.jsonata` template to map your data before transforming it. This has a few use cases:
|
|
247
281
|
|
|
248
|
-
- **Ingesting data of any shape**: Say you're simply ingesting data from a JSON file.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
- **
|
|
252
|
-
|
|
282
|
+
- **Ingesting data of any shape**: Say you're simply ingesting data from a JSON file.
|
|
283
|
+
Since you don't have the base transformation layer that a partner connector would usually provide,
|
|
284
|
+
you need to map your data first.
|
|
285
|
+
- **Customizing the connector mappings**:
|
|
286
|
+
Say you're using a partner connector and you want to customize how the data is mapped.
|
|
287
|
+
For example, you want to ingest content, or you want to grab the categories that would normally be ingested
|
|
288
|
+
as `item_groups` and ingest those into a custom index section.
|
|
289
|
+
- **Filtering out data**: While you can filter out data during the transformations, it might be computationally expensive.
|
|
290
|
+
You can simply drop any data during the mapping phase.
|
|
291
|
+
- **Creating data**: Say you want to have a default variation in every item, or a new item group as parent of all others.
|
|
292
|
+
You can create data out of thin air during the mapping phase.
|
|
293
|
+
- **Grouping data**: When dealing with variation ingestions we may want to ingest partial data,
|
|
294
|
+
maybe some pricing or inventory delta updates.
|
|
295
|
+
Sometimes this data is not in the variation level yet,
|
|
296
|
+
we can solve this by using the `__group_by` custom fields to group all records into a specific variation identifier.
|
|
297
|
+
That way when transforming the data you'll have access to an array of all data points that should be ingested as variations.
|
|
253
298
|
- ⚠️ This is currently only supported when performing variation-only ingestions.
|
|
254
299
|
|
|
255
|
-
Essentially, mapping templates empower you to fully customize how the connector works.
|
|
300
|
+
Essentially, mapping templates empower you to fully customize how the connector works.
|
|
301
|
+
It's up to you to map and transform the data.
|
|
256
302
|
|
|
257
303
|
The mapping template can return three arrays:
|
|
258
304
|
|
|
@@ -260,27 +306,34 @@ The mapping template can return three arrays:
|
|
|
260
306
|
- `variations`: Variations to be ingested.
|
|
261
307
|
- `item_groups`: Item groups to be ingested.
|
|
262
308
|
|
|
263
|
-
All objects inside these arrays can have **any data structure**. In the transformation templates,
|
|
309
|
+
All objects inside these arrays can have **any data structure**. In the transformation templates,
|
|
310
|
+
you'll receive the same structure you defined here.
|
|
264
311
|
|
|
265
312
|
It's important to note that there are a few requirements and optional fields for each of these, as described below.
|
|
266
313
|
|
|
267
|
-
|
|
314
|
+
#### Mapping items
|
|
268
315
|
|
|
269
|
-
When you map items,
|
|
316
|
+
When you map items,
|
|
317
|
+
you can append a field named `__variations` in case you can easily map the variations from the input data.
|
|
318
|
+
This will automatically group the variations into the item level, and will heavily speed up the ingestion performance.
|
|
270
319
|
|
|
271
|
-
|
|
320
|
+
#### Mapping variations
|
|
272
321
|
|
|
273
|
-
When you map variations, you can optionally provide a `__parent_id` field to each variation.
|
|
322
|
+
When you map variations, you can optionally provide a `__parent_id` field to each variation.
|
|
323
|
+
If you do that and the item is also present in the ingestion,
|
|
324
|
+
you'll be able to access the variations under the `__variations` field during the item template transformations.
|
|
274
325
|
|
|
275
|
-
When no item is present you may also add a `__group_by` field to group all related data into a single variation.
|
|
326
|
+
When no item is present you may also add a `__group_by` field to group all related data into a single variation.
|
|
327
|
+
This is useful when you're ingesting partial data, like pricing or inventory updates.
|
|
276
328
|
|
|
277
|
-
|
|
329
|
+
#### Mapping item groups
|
|
278
330
|
|
|
279
|
-
Mapping item groups is simpler. Since they can be ingested separately,
|
|
331
|
+
Mapping item groups is simpler. Since they can be ingested separately,
|
|
332
|
+
you can define any shape you want and transform them later.
|
|
280
333
|
|
|
281
|
-
|
|
334
|
+
### 💡 Valid transformer examples
|
|
282
335
|
|
|
283
|
-
|
|
336
|
+
#### Item transformer
|
|
284
337
|
|
|
285
338
|
In the `templates/item.jsonata` file, you can customize how items are transformed:
|
|
286
339
|
|
|
@@ -306,7 +359,7 @@ In the `templates/item.jsonata` file, you can customize how items are transforme
|
|
|
306
359
|
)
|
|
307
360
|
```
|
|
308
361
|
|
|
309
|
-
|
|
362
|
+
#### Variation transformer
|
|
310
363
|
|
|
311
364
|
In the `templates/variation.jsonata` file, you can customize how variations are transformed:
|
|
312
365
|
|
|
@@ -328,7 +381,7 @@ In the `templates/variation.jsonata` file, you can customize how variations are
|
|
|
328
381
|
}
|
|
329
382
|
```
|
|
330
383
|
|
|
331
|
-
|
|
384
|
+
#### Item Group transformer
|
|
332
385
|
|
|
333
386
|
In the `templates/item_group.jsonata` file, you can customize how item groups are transformed:
|
|
334
387
|
|
|
@@ -338,13 +391,17 @@ In the `templates/item_group.jsonata` file, you can customize how item groups ar
|
|
|
338
391
|
}
|
|
339
392
|
```
|
|
340
393
|
|
|
341
|
-
|
|
394
|
+
#### Grouping transformer
|
|
342
395
|
|
|
343
|
-
The `grouping` template is expected to override the same keys as the item transformer,
|
|
396
|
+
The `grouping` template is expected to override the same keys as the item transformer,
|
|
397
|
+
and ideally it should override the `id` property.
|
|
344
398
|
|
|
345
|
-
In this example, we're assuming that the connector data has properties such as `color`, `id`,
|
|
399
|
+
In this example, we're assuming that the connector data has properties such as `color`, `id`,
|
|
400
|
+
and `parent` (in case of variations).
|
|
401
|
+
With the code below, if a product has the ID `foo` with the color `blue`, the new ID would become `foo-blue`.
|
|
346
402
|
|
|
347
|
-
Also note that in this scenario, you'll also need to update the `item_id` property in the variant level
|
|
403
|
+
Also note that in this scenario, you'll also need to update the `item_id` property in the variant level
|
|
404
|
+
to make sure it'll match the overridden item ids.
|
|
348
405
|
|
|
349
406
|
In the `templates/grouping.jsonata` file, you can customize how item groups are transformed:
|
|
350
407
|
|
|
@@ -383,19 +440,27 @@ Finally, we likely want to remove excess items so that only new, grouped items a
|
|
|
383
440
|
}
|
|
384
441
|
```
|
|
385
442
|
|
|
386
|
-
|
|
443
|
+
### ⚙️ Template Language
|
|
387
444
|
|
|
388
445
|
To power the catalog customizations, we use a template language that allows for mapping data.
|
|
389
446
|
|
|
390
|
-
To do this, we use [JSONata](https://jsonata.org/) templates to support customizing your catalog data.
|
|
447
|
+
To do this, we use [JSONata](https://jsonata.org/) templates to support customizing your catalog data.
|
|
448
|
+
JSONata provides a powerful template language with many built-in functions,
|
|
449
|
+
but we also provide additional helper functions to deal with the external data for each connector.
|
|
391
450
|
|
|
392
|
-
> JSONata is a lightweight query and transformation language for JSON data.
|
|
451
|
+
> JSONata is a lightweight query and transformation language for JSON data.
|
|
452
|
+
Inspired by the 'location path' semantics of XPath 3.1,
|
|
453
|
+
it allows sophisticated queries to be expressed in a compact and intuitive notation.
|
|
454
|
+
A rich complement of built in operators and functions is provided for manipulating and combining extracted data,
|
|
455
|
+
and the results of queries can be formatted into any JSON output structure using familiar JSON object and array syntax.
|
|
456
|
+
Coupled with the facility to create user defined functions,
|
|
457
|
+
advanced expressions can be built to tackle any JSON query and transformation task.
|
|
393
458
|
|
|
394
459
|
For more details, check out the [documentation 🔍](https://docs.jsonata.org/overview.html)
|
|
395
460
|
|
|
396
461
|
Here are some good examples of basic to complex scenarios:
|
|
397
462
|
|
|
398
|
-
|
|
463
|
+
#### 1️⃣ Adding a single facet
|
|
399
464
|
|
|
400
465
|
We want to map the variant sku to a specific metadata
|
|
401
466
|
|
|
@@ -458,7 +523,7 @@ We want to map the variant sku to a specific metadata
|
|
|
458
523
|
</tr>
|
|
459
524
|
</table>
|
|
460
525
|
|
|
461
|
-
|
|
526
|
+
#### 2️⃣ Using built in helper functions
|
|
462
527
|
|
|
463
528
|
JSONata already provides a powerful set of helper functions that can be used in the templates.
|
|
464
529
|
|
|
@@ -470,11 +535,14 @@ using just one field called `prices`.
|
|
|
470
535
|
[👉 Try it for yourself!](https://try.jsonata.org/b-ddoNC3p)
|
|
471
536
|
|
|
472
537
|
<table>
|
|
538
|
+
<thead>
|
|
473
539
|
<tr>
|
|
474
|
-
<
|
|
475
|
-
<
|
|
476
|
-
<
|
|
540
|
+
<th>Connector data</th>
|
|
541
|
+
<th>Template</th>
|
|
542
|
+
<th>Result</th>
|
|
477
543
|
</tr>
|
|
544
|
+
</thead>
|
|
545
|
+
<tbody>
|
|
478
546
|
<tr>
|
|
479
547
|
<td>
|
|
480
548
|
|
|
@@ -545,9 +613,10 @@ using just one field called `prices`.
|
|
|
545
613
|
|
|
546
614
|
</td>
|
|
547
615
|
</tr>
|
|
616
|
+
</tbody>
|
|
548
617
|
</table>
|
|
549
618
|
|
|
550
|
-
|
|
619
|
+
#### 3️⃣ Using helper functions provided by connectors
|
|
551
620
|
|
|
552
621
|
To make things even easier, our connectors provide helper functions that allow you to easily access
|
|
553
622
|
and parse the external data that comes from the partner.
|
|
@@ -560,7 +629,7 @@ translation, with a fallback to English if not found.
|
|
|
560
629
|
|
|
561
630
|
[👉 Try it for yourself!](https://try.jsonata.org/yfsTJnbkF)
|
|
562
631
|
|
|
563
|
-
|
|
632
|
+
##### Helper Function
|
|
564
633
|
|
|
565
634
|
As described before, each connector provides helper functions to make it easier to map your data.
|
|
566
635
|
|
|
@@ -578,11 +647,14 @@ function getProductDescriptionWithFallback(locale) {
|
|
|
578
647
|
```
|
|
579
648
|
|
|
580
649
|
<table>
|
|
650
|
+
<thead>
|
|
581
651
|
<tr>
|
|
582
|
-
<
|
|
583
|
-
<
|
|
584
|
-
<
|
|
652
|
+
<th>Connector data</th>
|
|
653
|
+
<th>Template</th>
|
|
654
|
+
<th>Result</th>
|
|
585
655
|
</tr>
|
|
656
|
+
</thead>
|
|
657
|
+
<tbody>
|
|
586
658
|
<tr>
|
|
587
659
|
<td>
|
|
588
660
|
|
|
@@ -653,9 +725,10 @@ function getProductDescriptionWithFallback(locale) {
|
|
|
653
725
|
|
|
654
726
|
</td>
|
|
655
727
|
</tr>
|
|
728
|
+
</tbody>
|
|
656
729
|
</table>
|
|
657
730
|
|
|
658
|
-
|
|
731
|
+
#### 4️⃣ Defining new functions and/or variables inside templates
|
|
659
732
|
|
|
660
733
|
Sometimes you want to do something really complex and the connector might not have a helper
|
|
661
734
|
function ready for this.
|
|
@@ -672,7 +745,7 @@ that will then be called to override the product id (resulting in `foobar`).
|
|
|
672
745
|
|
|
673
746
|
[👉 Try it for yourself!](https://try.jsonata.org/fYov5XxnY)
|
|
674
747
|
|
|
675
|
-
|
|
748
|
+
##### Connector data
|
|
676
749
|
|
|
677
750
|
```ts
|
|
678
751
|
{
|
|
@@ -682,7 +755,7 @@ that will then be called to override the product id (resulting in `foobar`).
|
|
|
682
755
|
}
|
|
683
756
|
```
|
|
684
757
|
|
|
685
|
-
|
|
758
|
+
##### Template
|
|
686
759
|
|
|
687
760
|
```js
|
|
688
761
|
(
|
|
@@ -700,7 +773,7 @@ that will then be called to override the product id (resulting in `foobar`).
|
|
|
700
773
|
)
|
|
701
774
|
```
|
|
702
775
|
|
|
703
|
-
|
|
776
|
+
##### Result
|
|
704
777
|
|
|
705
778
|
```ts
|
|
706
779
|
{
|
|
@@ -710,9 +783,11 @@ that will then be called to override the product id (resulting in `foobar`).
|
|
|
710
783
|
}
|
|
711
784
|
```
|
|
712
785
|
|
|
713
|
-
|
|
786
|
+
#### 5️⃣ Sharing code across templates
|
|
714
787
|
|
|
715
|
-
Sometimes is handy to move some duplicated code into a separate file and import it whenever needed.
|
|
788
|
+
Sometimes is handy to move some duplicated code into a separate file and import it whenever needed.
|
|
789
|
+
You can do this through our `helpers.jsonata` file.
|
|
790
|
+
And then, reuse it anywhere by simply importing it using the `{{helpers}}` syntax.
|
|
716
791
|
|
|
717
792
|
Note: This feature is implemented under our custom build process, so the JSONata exerciser will not parse this syntax correctly.
|
|
718
793
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# compiled output
|
|
2
|
+
/dist
|
|
3
|
+
/node_modules
|
|
4
|
+
# Logs
|
|
5
|
+
logs
|
|
6
|
+
*.log
|
|
7
|
+
npm-debug.log*
|
|
8
|
+
pnpm-debug.log*
|
|
9
|
+
yarn-debug.log*
|
|
10
|
+
yarn-error.log*
|
|
11
|
+
lerna-debug.log*
|
|
12
|
+
# OS
|
|
13
|
+
.DS_Store
|
|
14
|
+
# Tests
|
|
15
|
+
/coverage
|
|
16
|
+
/.nyc_output
|
|
17
|
+
# IDEs and editors
|
|
18
|
+
/.idea
|
|
19
|
+
.project
|
|
20
|
+
.classpath
|
|
21
|
+
.c9/
|
|
22
|
+
*.launch
|
|
23
|
+
.settings/
|
|
24
|
+
*.sublime-workspace
|
|
25
|
+
# IDE - VSCode
|
|
26
|
+
.vscode/*
|
|
27
|
+
*.code-workspace
|
|
28
|
+
!.vscode/settings.json
|
|
29
|
+
!.vscode/tasks.json
|
|
30
|
+
!.vscode/launch.json
|
|
31
|
+
!.vscode/extensions.json
|
|
32
|
+
# dotenv
|
|
33
|
+
.env
|
|
34
|
+
# npmrc should be ignored to avoid leaking credentials (e.g. AWS CodeArtifact)
|
|
35
|
+
.npmrc
|
|
@@ -14,6 +14,7 @@ interface ExecuteInputFlags {
|
|
|
14
14
|
"connection-id"?: string;
|
|
15
15
|
"fixture-path"?: string;
|
|
16
16
|
"external-data-path"?: string;
|
|
17
|
+
"override-date"?: Date;
|
|
17
18
|
}
|
|
18
19
|
export declare class Execute extends RefreshConnectionsCommand {
|
|
19
20
|
static flags: {
|
|
@@ -21,6 +22,7 @@ export declare class Execute extends RefreshConnectionsCommand {
|
|
|
21
22
|
"fixture-path": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
23
|
"external-data-path": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
24
|
"connection-id": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
"override-date": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
26
|
};
|
|
25
27
|
static description: string;
|
|
26
28
|
static examples: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,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;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,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;IAC9B,eAAe,CAAC,EAAE,IAAI,CAAC;CACxB;AAaD,qBAAa,OAAQ,SAAQ,yBAAyB;IACpD,MAAM,CAAC,KAAK;;;;;;MAoBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAmCnB,UAAU;YA0BV,oBAAoB;YAqDpB,wBAAwB;YA2BxB,wBAAwB;CAevC"}
|
package/dist/commands/execute.js
CHANGED
|
@@ -40,6 +40,9 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
40
40
|
"connection-id": core_1.Flags.string({
|
|
41
41
|
description: "The ID of the connection to execute the template against.",
|
|
42
42
|
}),
|
|
43
|
+
"override-date": core_1.Flags.string({
|
|
44
|
+
description: "Date with which to override $now and $millis in the template.",
|
|
45
|
+
}),
|
|
43
46
|
};
|
|
44
47
|
static description = "Execute a template against a connection and fixture to see the resulting transformed data. Each value not provided as a flag will be prompted for when the command is executed.";
|
|
45
48
|
static examples = [
|
|
@@ -66,6 +69,7 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
66
69
|
: {},
|
|
67
70
|
connectionId: templateInput.connectionId,
|
|
68
71
|
templateType: (0, extract_template_type_1.extractTemplateType)(templateInput.templatePath),
|
|
72
|
+
overrideDate: templateInput.overrideDate,
|
|
69
73
|
});
|
|
70
74
|
(0, render_template_result_1.renderTemplateResult)(result);
|
|
71
75
|
if (result.warnings.length > 0) {
|
|
@@ -95,6 +99,9 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
95
99
|
if (flags["connection-id"]) {
|
|
96
100
|
this.input["connection-id"] = flags["connection-id"];
|
|
97
101
|
}
|
|
102
|
+
if (flags["override-date"]) {
|
|
103
|
+
this.input["override-date"] = new Date(flags["override-date"]);
|
|
104
|
+
}
|
|
98
105
|
}
|
|
99
106
|
async getTemplateExecInput() {
|
|
100
107
|
const allConnections = await (0, get_connections_request_1.getConnections)({
|
|
@@ -134,6 +141,7 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
134
141
|
fixturePath: this.input["fixture-path"],
|
|
135
142
|
externalPath: this.input["external-data-path"] ?? "",
|
|
136
143
|
connectionId,
|
|
144
|
+
overrideDate: this.input["override-date"],
|
|
137
145
|
};
|
|
138
146
|
}
|
|
139
147
|
async validateAndGetConnection(allConnections, templatePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAE,MAAM,aAAa,CAAC;AA0B5C,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;YAyCnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WA6BvB,mBAAmB,CAC/B,MAAM,EAAE,MAAM,EACd,4BAA4B,EAAE,OAAO,GACpC,IAAI;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAE,MAAM,aAAa,CAAC;AA0B5C,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;YAyCnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WA6BvB,mBAAmB,CAC/B,MAAM,EAAE,MAAM,EACd,4BAA4B,EAAE,OAAO,GACpC,IAAI;IAsBP,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAWjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAuBlC,OAAO,CAAC,0BAA0B;CA4BnC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -155,6 +155,12 @@ class Init extends core_1.Command {
|
|
|
155
155
|
return !file.includes("mapping");
|
|
156
156
|
},
|
|
157
157
|
});
|
|
158
|
+
// Handle .gitignore file - npm renames it during publish, so we copy from 'gitignore' to '.gitignore'
|
|
159
|
+
const gitignoreSource = path.join(repoDir, "gitignore");
|
|
160
|
+
const gitignoreDest = path.join(newDir, ".gitignore");
|
|
161
|
+
if (fs_extra_1.default.existsSync(gitignoreSource)) {
|
|
162
|
+
fs_extra_1.default.copyFileSync(gitignoreSource, gitignoreDest);
|
|
163
|
+
}
|
|
158
164
|
}
|
|
159
165
|
static replacePackageName(name, repoPath) {
|
|
160
166
|
const packageJsonPath = path.join(repoPath, "package.json");
|
|
@@ -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,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
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;IACtB,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAwBjE"}
|
|
@@ -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, external } = initializeOptions(options);
|
|
36
|
+
const { name, fixture, external, overrideDate } = 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)({
|
|
@@ -44,6 +44,7 @@ async function executeTemplate(options) {
|
|
|
44
44
|
data: fixture,
|
|
45
45
|
showLogs: false,
|
|
46
46
|
external,
|
|
47
|
+
overrideDate,
|
|
47
48
|
});
|
|
48
49
|
if (!result.success) {
|
|
49
50
|
throw new Error(`Error executing template: ${result.error.message}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TemplateExecutionSuccessResponse, type TemplateExecutionErrorResponse } from "../types";
|
|
2
|
-
export declare function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
|
|
2
|
+
export declare function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs, overrideDate, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
|
|
3
3
|
interface Args {
|
|
4
4
|
template: string;
|
|
5
5
|
helpers: string;
|
|
@@ -8,6 +8,7 @@ interface Args {
|
|
|
8
8
|
connectionId: string;
|
|
9
9
|
templateType: string;
|
|
10
10
|
showLogs?: boolean;
|
|
11
|
+
overrideDate?: Date;
|
|
11
12
|
}
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=send-template-execute-request.d.ts.map
|
|
@@ -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,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,QAAe,
|
|
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,EACf,YAAY,GACb,EAAE,IAAI,GAAG,OAAO,CACf,gCAAgC,GAAG,8BAA8B,CAClE,CA+BA;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;IACnB,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB"}
|
|
@@ -5,7 +5,7 @@ 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, data, external, connectionId, templateType, showLogs = true, }) {
|
|
8
|
+
async function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs = true, overrideDate, }) {
|
|
9
9
|
const client = await (0, http_client_1.getHttpClient)();
|
|
10
10
|
const httpRequest = async () => {
|
|
11
11
|
return (await client.patch("templates/standalone/execute", {
|
|
@@ -15,6 +15,7 @@ async function sendTemplateExecuteRequest({ template, helpers, data, external, c
|
|
|
15
15
|
external,
|
|
16
16
|
connection_id: connectionId,
|
|
17
17
|
template_type: templateType,
|
|
18
|
+
...(overrideDate ? { override_date: overrideDate.toISOString() } : {}),
|
|
18
19
|
})).data;
|
|
19
20
|
};
|
|
20
21
|
try {
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -86,6 +86,13 @@
|
|
|
86
86
|
"hasDynamicHelp": false,
|
|
87
87
|
"multiple": false,
|
|
88
88
|
"type": "option"
|
|
89
|
+
},
|
|
90
|
+
"override-date": {
|
|
91
|
+
"description": "Date with which to override $now and $millis in the template.",
|
|
92
|
+
"name": "override-date",
|
|
93
|
+
"hasDynamicHelp": false,
|
|
94
|
+
"multiple": false,
|
|
95
|
+
"type": "option"
|
|
89
96
|
}
|
|
90
97
|
},
|
|
91
98
|
"hasDynamicHelp": false,
|
|
@@ -200,5 +207,5 @@
|
|
|
200
207
|
]
|
|
201
208
|
}
|
|
202
209
|
},
|
|
203
|
-
"version": "1.
|
|
210
|
+
"version": "1.16.0"
|
|
204
211
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-connect-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.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",
|
|
@@ -30,6 +30,8 @@
|
|
|
30
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
|
+
"mdlint": "markdownlint-cli2 \"**/*.md\"",
|
|
34
|
+
"mdlint:fix": "markdownlint-cli2 \"**/*.md\" --fix",
|
|
33
35
|
"license-check": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;BSD-2-Clause;ISC;MIT;0BSD'",
|
|
34
36
|
"postpack": "shx rm -f oclif.manifest.json",
|
|
35
37
|
"compile": "npm run build && npm run generate-readme && oclif manifest"
|
|
@@ -84,11 +86,13 @@
|
|
|
84
86
|
"@types/mock-fs": "^4.13.4",
|
|
85
87
|
"cross-env": "^10.0.0",
|
|
86
88
|
"eslint": "^9.25.0",
|
|
89
|
+
"eslint-config-prettier": "^10.1.8",
|
|
87
90
|
"eslint-plugin-prettier": "^5.2.6",
|
|
88
91
|
"eslint-plugin-promise": "^6.6.0",
|
|
89
92
|
"globals": "^16.0.0",
|
|
90
93
|
"jest": "^29.7.0",
|
|
91
94
|
"license-checker": "^25.0.1",
|
|
95
|
+
"markdownlint-cli2": "^0.20.0",
|
|
92
96
|
"mock-fs": "^5.2.0",
|
|
93
97
|
"nock": "14.0.10",
|
|
94
98
|
"oclif": "^4.17.42",
|