@constructor-io/constructorio-connect-cli 1.0.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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +16 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.js +10 -0
  7. package/boilerplate-repo/.env.example +1 -0
  8. package/boilerplate-repo/.eslintrc.json +11 -0
  9. package/boilerplate-repo/.vscode/extensions.json +5 -0
  10. package/boilerplate-repo/.vscode/launch.json +13 -0
  11. package/boilerplate-repo/.vscode/tasks.json +20 -0
  12. package/boilerplate-repo/LICENSE +21 -0
  13. package/boilerplate-repo/README.md +650 -0
  14. package/boilerplate-repo/connectrc.js +7 -0
  15. package/boilerplate-repo/package.json +21 -0
  16. package/boilerplate-repo/src/fixtures/item/item.json +39 -0
  17. package/boilerplate-repo/src/fixtures/item_group/item_group.json +22 -0
  18. package/boilerplate-repo/src/fixtures/mapping/mapping.json +26 -0
  19. package/boilerplate-repo/src/fixtures/variation/variation.json +11 -0
  20. package/boilerplate-repo/src/templates/grouping/grouping.jsonata +37 -0
  21. package/boilerplate-repo/src/templates/helpers.jsonata +3 -0
  22. package/boilerplate-repo/src/templates/item/item.jsonata +26 -0
  23. package/boilerplate-repo/src/templates/item_group/item_group.jsonata +4 -0
  24. package/boilerplate-repo/src/templates/mapping/mapping.jsonata +34 -0
  25. package/boilerplate-repo/src/templates/variation/variation.jsonata +26 -0
  26. package/dist/commands/deploy.d.ts +10 -0
  27. package/dist/commands/deploy.d.ts.map +1 -0
  28. package/dist/commands/deploy.js +64 -0
  29. package/dist/commands/execute.d.ts +35 -0
  30. package/dist/commands/execute.d.ts.map +1 -0
  31. package/dist/commands/execute.js +145 -0
  32. package/dist/commands/init.d.ts +18 -0
  33. package/dist/commands/init.d.ts.map +1 -0
  34. package/dist/commands/init.js +172 -0
  35. package/dist/customer/config.d.ts +6 -0
  36. package/dist/customer/config.d.ts.map +1 -0
  37. package/dist/customer/config.js +40 -0
  38. package/dist/customer/get-connect-token.d.ts +15 -0
  39. package/dist/customer/get-connect-token.d.ts.map +1 -0
  40. package/dist/customer/get-connect-token.js +69 -0
  41. package/dist/customer/path.d.ts +26 -0
  42. package/dist/customer/path.d.ts.map +1 -0
  43. package/dist/customer/path.js +48 -0
  44. package/dist/customer/template-source-code.d.ts +12 -0
  45. package/dist/customer/template-source-code.d.ts.map +1 -0
  46. package/dist/customer/template-source-code.js +42 -0
  47. package/dist/helpers/build-config-file.d.ts +13 -0
  48. package/dist/helpers/build-config-file.d.ts.map +1 -0
  49. package/dist/helpers/build-config-file.js +62 -0
  50. package/dist/helpers/file-loaders.d.ts +19 -0
  51. package/dist/helpers/file-loaders.d.ts.map +1 -0
  52. package/dist/helpers/file-loaders.js +45 -0
  53. package/dist/helpers/find-deep-files.d.ts +7 -0
  54. package/dist/helpers/find-deep-files.d.ts.map +1 -0
  55. package/dist/helpers/find-deep-files.js +27 -0
  56. package/dist/helpers/generate-command-input.d.ts +19 -0
  57. package/dist/helpers/generate-command-input.d.ts.map +1 -0
  58. package/dist/helpers/generate-command-input.js +51 -0
  59. package/dist/helpers/is-git-repo-initialized.d.ts +5 -0
  60. package/dist/helpers/is-git-repo-initialized.d.ts.map +1 -0
  61. package/dist/helpers/is-git-repo-initialized.js +24 -0
  62. package/dist/helpers/ux-action.d.ts +2 -0
  63. package/dist/helpers/ux-action.d.ts.map +1 -0
  64. package/dist/helpers/ux-action.js +31 -0
  65. package/dist/http/deploy-request.d.ts +16 -0
  66. package/dist/http/deploy-request.d.ts.map +1 -0
  67. package/dist/http/deploy-request.js +45 -0
  68. package/dist/http/execute-templates-request.d.ts +10 -0
  69. package/dist/http/execute-templates-request.d.ts.map +1 -0
  70. package/dist/http/execute-templates-request.js +28 -0
  71. package/dist/http/get-connections-request.d.ts +18 -0
  72. package/dist/http/get-connections-request.d.ts.map +1 -0
  73. package/dist/http/get-connections-request.js +24 -0
  74. package/dist/http/http-client.d.ts +6 -0
  75. package/dist/http/http-client.d.ts.map +1 -0
  76. package/dist/http/http-client.js +57 -0
  77. package/dist/index.d.ts +2 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +5 -0
  80. package/dist/prompt-data/filter-connections-by-template.d.ts +4 -0
  81. package/dist/prompt-data/filter-connections-by-template.d.ts.map +1 -0
  82. package/dist/prompt-data/filter-connections-by-template.js +30 -0
  83. package/dist/prompt-data/get-candidate-fixtures.d.ts +3 -0
  84. package/dist/prompt-data/get-candidate-fixtures.d.ts.map +1 -0
  85. package/dist/prompt-data/get-candidate-fixtures.js +49 -0
  86. package/dist/prompt-data/get-external-data-files.d.ts +3 -0
  87. package/dist/prompt-data/get-external-data-files.d.ts.map +1 -0
  88. package/dist/prompt-data/get-external-data-files.js +28 -0
  89. package/dist/prompt-data/get-template-files.d.ts +7 -0
  90. package/dist/prompt-data/get-template-files.d.ts.map +1 -0
  91. package/dist/prompt-data/get-template-files.js +50 -0
  92. package/dist/prompt-data/render-prompt.d.ts +9 -0
  93. package/dist/prompt-data/render-prompt.d.ts.map +1 -0
  94. package/dist/prompt-data/render-prompt.js +16 -0
  95. package/dist/rendering/render-repeat-input.d.ts +14 -0
  96. package/dist/rendering/render-repeat-input.d.ts.map +1 -0
  97. package/dist/rendering/render-repeat-input.js +25 -0
  98. package/dist/rendering/render-template-result.d.ts +2 -0
  99. package/dist/rendering/render-template-result.d.ts.map +1 -0
  100. package/dist/rendering/render-template-result.js +60 -0
  101. package/dist/rendering/render-tip.d.ts +6 -0
  102. package/dist/rendering/render-tip.d.ts.map +1 -0
  103. package/dist/rendering/render-tip.js +22 -0
  104. package/dist/types.d.ts +40 -0
  105. package/dist/types.d.ts.map +1 -0
  106. package/dist/types.js +2 -0
  107. package/oclif.manifest.json +129 -0
  108. package/package.json +98 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Constructor.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # Constructor.io Connect CLI
2
+
3
+ [![npm](https://img.shields.io/npm/v/@constructor-io/constructorio-connect-cli)](https://www.npmjs.com/package/@constructor-io/constructorio-connect-cli)
4
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Constructor-io/constructorio-connect-cli/blob/master/LICENSE)
5
+
6
+ Constructor.io is an e-commerce first product discovery service that optimizes results using artificial intelligence (including natural language processing, re-ranking to optimize for business metrics, and end user personalization).
7
+
8
+ This package is a CLI tool that helps you **build, test and deploy your connector templates**. By using templates, you can customize your catalog integration to shape your data the way you want it.
9
+
10
+ > If you're looking for a package to consume our API, please use [@constructor-io/constructorio-node](https://github.com/Constructor-io/constructorio-node) instead. 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
+
12
+ ## 1. Review the Requirements
13
+
14
+ Before you begin, note that this package is intended for use with partner connections. If you don't have a connector
15
+ running yet, please take a look at [our documentation](https://docs-beta.constructor.io/docs/integrating-with-constructor-platform-connectors) to see how you can get started.
16
+
17
+ ## 2. Install
18
+
19
+ This package can be installed via npm: `npm i @constructor-io/constructorio-connect-cli`. Once installed, simply import or require the package into your repository.
20
+
21
+ ## 3. Commands
22
+
23
+ <!-- Generated code below. Do not update! -->
24
+
25
+ <!-- commands -->
26
+ * [`constructorio-connect-cli deploy ENV`](#constructorio-connect-cli-deploy-env)
27
+ * [`constructorio-connect-cli execute`](#constructorio-connect-cli-execute)
28
+ * [`constructorio-connect-cli help [COMMAND]`](#constructorio-connect-cli-help-command)
29
+ * [`constructorio-connect-cli init NAME`](#constructorio-connect-cli-init-name)
30
+
31
+ ## `constructorio-connect-cli deploy ENV`
32
+
33
+ Deploys all templates defined on the `connectrc.js` file to the specified environment.
34
+
35
+ ```
36
+ USAGE
37
+ $ constructorio-connect-cli deploy ENV
38
+
39
+ ARGUMENTS
40
+ ENV (development|qa|production|demo) The target Constructor environment to deploy to.
41
+
42
+ DESCRIPTION
43
+
44
+ Deploys all templates defined on the `connectrc.js` file to the specified environment.
45
+
46
+ The script will use the `CONNECT_AUTH_TOKEN` environment variable to authenticate with Constructor.
47
+
48
+ EXAMPLES
49
+ $ constructorio-connect-cli deploy development
50
+
51
+ $ constructorio-connect-cli deploy qa
52
+
53
+ $ constructorio-connect-cli deploy production
54
+ ```
55
+
56
+ _See code: [src/commands/deploy.ts](https://github.com/Constructor-io/constructorio-connect-cli/blob/v1.0.0/src/commands/deploy.ts)_
57
+
58
+ ## `constructorio-connect-cli execute`
59
+
60
+ 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.
61
+
62
+ ```
63
+ USAGE
64
+ $ constructorio-connect-cli execute [--template-path <value>] [--fixture-path <value>]
65
+ [--external-data-path <value>] [--connection-id <value>]
66
+
67
+ FLAGS
68
+ --connection-id=<value> The ID of the connection to execute the template against.
69
+ --external-data-path=<value> The path to the external data to execute the template against. Must be in the
70
+ 'src/fixtures/external_data' directory.
71
+ --fixture-path=<value> The path to the fixture to execute the template against. Must be in the 'src/fixtures'
72
+ directory.
73
+ --template-path=<value> The path to the template to execute. Must be in the 'src/templates' directory.
74
+
75
+ DESCRIPTION
76
+ Execute a template against a connection and fixture to see the resulting transformed data. Each value not provided as
77
+ a flag will be prompted for when the command is executed.
78
+
79
+ EXAMPLES
80
+ $ constructorio-connect-cli execute
81
+
82
+ $ constructorio-connect-cli execute --template-path=item/item.jsonata
83
+
84
+ $ constructorio-connect-cli execute --template-path=variation/variation.jsonata
85
+
86
+ $ constructorio-connect-cli execute --template-path=item_group/item_group.jsonata --fixture-path=item_group.json
87
+
88
+ $ constructorio-connect-cli execute --template-path=grouping/grouping.jsonata --connection-id=example-connection-id
89
+
90
+ $ constructorio-connect-cli execute --template-path=mapping/mapping.jsonata
91
+ ```
92
+
93
+ _See code: [src/commands/execute.ts](https://github.com/Constructor-io/constructorio-connect-cli/blob/v1.0.0/src/commands/execute.ts)_
94
+
95
+ ## `constructorio-connect-cli help [COMMAND]`
96
+
97
+ Display help for constructorio-connect-cli.
98
+
99
+ ```
100
+ USAGE
101
+ $ constructorio-connect-cli help [COMMAND...] [-n]
102
+
103
+ ARGUMENTS
104
+ COMMAND... Command to show help for.
105
+
106
+ FLAGS
107
+ -n, --nested-commands Include all nested commands in the output.
108
+
109
+ DESCRIPTION
110
+ Display help for constructorio-connect-cli.
111
+ ```
112
+
113
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
114
+
115
+ ## `constructorio-connect-cli init NAME`
116
+
117
+ Bootstrap a new Constructor.io Connect CLI repository.
118
+
119
+ ```
120
+ USAGE
121
+ $ constructorio-connect-cli init NAME
122
+
123
+ ARGUMENTS
124
+ NAME name of the new folder
125
+
126
+ DESCRIPTION
127
+ Bootstrap a new Constructor.io Connect CLI repository.
128
+
129
+ EXAMPLES
130
+ $ constructorio-connect-cli init
131
+
132
+ $ constructorio-connect-cli init new-repo-name
133
+ ```
134
+
135
+ _See code: [src/commands/init.ts](https://github.com/Constructor-io/constructorio-connect-cli/blob/v1.0.0/src/commands/init.ts)_
136
+ <!-- commandsstop -->
137
+
138
+ ## Development
139
+
140
+ Here's some useful npm scripts:
141
+
142
+ ```bash
143
+ npm run lint # run lint on source code and tests
144
+ npm run test # run tests
145
+ npm run test:cov # run tests with coverage report
146
+ ```
147
+
148
+ ### Running locally
149
+
150
+ First, install dependencies:
151
+
152
+ ```bash
153
+ npm ci
154
+ ```
155
+
156
+ Then, set up your local environment and fill `.env` with your credentials:
157
+
158
+ ```bash
159
+ cp .env.example .env
160
+ ```
161
+
162
+ All done! You can now run the package locally:
163
+
164
+ ```bash
165
+ npm run dev [command] -- [arguments and flags]
166
+ # or, you can just directly access the built CLI:
167
+ bin/dev.js [command] [arguments and flags]
168
+ ```
169
+
170
+ You can also test inside other projects with:
171
+
172
+ ```bash
173
+ npm i full/path/to/this/repo
174
+ # or even install it globally
175
+
176
+ npm i -g full/path/to/this/repo
177
+ constructorio-connect-cli --help
178
+ ```
179
+
180
+ Finally, you can switch the host you're sending requests to if you need. For example, you can point to a local host if you have a local instance running.
181
+
182
+ ```
183
+ HOST=http://localhost:3000 constructorio-connect-cli deploy development
184
+ ```
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env -S npx ts-node
2
+
3
+ void (async () => {
4
+ const { config } = await import("dotenv");
5
+ config();
6
+
7
+ const oclif = await import("@oclif/core");
8
+
9
+ /**
10
+ * ! Disclaimer
11
+ *
12
+ * With the development flag set to true, the CLI will print/output some UX elements differently from the run.js command.
13
+ * Please use the run.js command for any layout or UX testing.
14
+ */
15
+ await oclif.execute({ dir: __dirname, development: true });
16
+ })();
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ void (async () => {
4
+ const oclif = await import("@oclif/core");
5
+ const { config } = await import("dotenv");
6
+ const path = await import("path");
7
+
8
+ config({ path: path.join(process.cwd(), ".env") });
9
+ await oclif.execute({ dir: __dirname });
10
+ })();
@@ -0,0 +1 @@
1
+ CONNECT_AUTH_TOKEN=
@@ -0,0 +1,11 @@
1
+ {
2
+ "root": true,
3
+ "env": {
4
+ "es2021": true,
5
+ "node": true
6
+ },
7
+ "extends": [
8
+ "plugin:prettier/recommended"
9
+ ],
10
+ "ignorePatterns": [".eslintrc.js"]
11
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "recommendations": [
3
+ "bigbug.vscode-language-jsonata"
4
+ ]
5
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "node",
6
+ "request": "launch",
7
+ "program": "${file}",
8
+ "name": "Execute template",
9
+ "preLaunchTask": "Execute template",
10
+ "skipFiles": ["<node_internals>/**"]
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "Execute template",
6
+ "type": "shell",
7
+ "command": "npm",
8
+ "args": ["run", "execute", "--", "--template-path=${file}"],
9
+ "group": {
10
+ "kind": "test",
11
+ "isDefault": true
12
+ },
13
+ "presentation": {
14
+ "reveal": "always",
15
+ "focus": true,
16
+ "showReuseMessage": true
17
+ }
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Constructor.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.