terse-cli 0.3.2 → 0.3.4
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/codegen.d.ts +0 -15
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +81 -466
- package/dist/codegen.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +1 -18
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/integrate.d.ts.map +1 -1
- package/dist/commands/integrate.js +5 -1
- package/dist/commands/integrate.js.map +1 -1
- package/dist/deploy.d.ts +1 -2
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +38 -61
- package/dist/deploy.js.map +1 -1
- package/dist/generate.d.ts +1 -2
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +69 -67
- package/dist/generate.js.map +1 -1
- package/dist/init.d.ts +1 -2
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +96 -45
- package/dist/init.js.map +1 -1
- package/dist/integrate.d.ts +0 -1
- package/dist/integrate.d.ts.map +1 -1
- package/dist/integrate.js +11 -191
- package/dist/integrate.js.map +1 -1
- package/dist/jsonOutput.d.ts +19 -0
- package/dist/jsonOutput.d.ts.map +1 -0
- package/dist/jsonOutput.js +25 -0
- package/dist/jsonOutput.js.map +1 -0
- package/dist/nonInteractive.d.ts +2 -4
- package/dist/nonInteractive.d.ts.map +1 -1
- package/dist/nonInteractive.js +2 -5
- package/dist/nonInteractive.js.map +1 -1
- package/dist/providers/python/PythonProvider.js +0 -1
- package/dist/providers/python/PythonProvider.js.map +1 -1
- package/dist/providers/typescript/modules/registry.d.ts.map +1 -1
- package/dist/providers/typescript/modules/registry.js +3 -1
- package/dist/providers/typescript/modules/registry.js.map +1 -1
- package/dist/providers/typescript/parkSignals.d.ts +7 -0
- package/dist/providers/typescript/parkSignals.d.ts.map +1 -0
- package/dist/providers/typescript/parkSignals.js +45 -0
- package/dist/providers/typescript/parkSignals.js.map +1 -0
- package/dist/replay.d.ts +3 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +20 -0
- package/dist/replay.js.map +1 -0
- package/dist/run.d.ts +11 -2
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +153 -42
- package/dist/run.js.map +1 -1
- package/dist/sampleEventId.d.ts +4 -0
- package/dist/sampleEventId.d.ts.map +1 -1
- package/dist/sampleEventId.js +4 -0
- package/dist/sampleEventId.js.map +1 -1
- package/dist/shared/ApiRoutes.d.ts +0 -19
- package/dist/shared/ApiRoutes.d.ts.map +1 -1
- package/dist/shared/ApiRoutes.js +1 -17
- package/dist/shared/ApiRoutes.js.map +1 -1
- package/dist/shared/Configs.d.ts +2 -24
- package/dist/shared/Configs.d.ts.map +1 -1
- package/dist/shared/Configs.js +2 -32
- package/dist/shared/Configs.js.map +1 -1
- package/dist/shared/Integrations.d.ts +1 -18
- package/dist/shared/Integrations.d.ts.map +1 -1
- package/dist/shared/Integrations.js +1 -10
- package/dist/shared/Integrations.js.map +1 -1
- package/dist/shared/InvalidationKeys.d.ts +0 -1
- package/dist/shared/InvalidationKeys.d.ts.map +1 -1
- package/dist/shared/InvalidationKeys.js +0 -3
- package/dist/shared/InvalidationKeys.js.map +1 -1
- package/dist/shared/ModelEvents.d.ts +0 -9
- package/dist/shared/ModelEvents.d.ts.map +1 -1
- package/dist/shared/ModelEvents.js +0 -15
- package/dist/shared/ModelEvents.js.map +1 -1
- package/dist/shared/ToolDisplayUtils.d.ts.map +1 -1
- package/dist/shared/ToolDisplayUtils.js +11 -107
- package/dist/shared/ToolDisplayUtils.js.map +1 -1
- package/dist/shared/types.d.ts +108 -1013
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js.map +1 -1
- package/dist/test.d.ts +1 -2
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +23 -43
- package/dist/test.js.map +1 -1
- package/dist/testRelay.d.ts +6 -0
- package/dist/testRelay.d.ts.map +1 -0
- package/dist/testRelay.js +91 -0
- package/dist/testRelay.js.map +1 -0
- package/dist/urls.d.ts +3 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.js +27 -0
- package/dist/urls.js.map +1 -0
- package/dist/util.d.ts +3 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +3 -3
- package/dist/util.js.map +1 -1
- package/package.json +3 -3
- package/src/providers/typescript/modules/apollo/apollo.tools.hbs +12 -0
- package/dist/_tmp_create_project.d.ts +0 -2
- package/dist/_tmp_create_project.d.ts.map +0 -1
- package/dist/_tmp_create_project.js +0 -17
- package/dist/_tmp_create_project.js.map +0 -1
- package/dist/_tmp_delete_agent.d.ts +0 -2
- package/dist/_tmp_delete_agent.d.ts.map +0 -1
- package/dist/_tmp_delete_agent.js +0 -14
- package/dist/_tmp_delete_agent.js.map +0 -1
- package/dist/_tmp_manual_trigger.d.ts +0 -2
- package/dist/_tmp_manual_trigger.d.ts.map +0 -1
- package/dist/_tmp_manual_trigger.js +0 -17
- package/dist/_tmp_manual_trigger.js.map +0 -1
- package/dist/_tmp_patch_active.d.ts +0 -2
- package/dist/_tmp_patch_active.d.ts.map +0 -1
- package/dist/_tmp_patch_active.js +0 -21
- package/dist/_tmp_patch_active.js.map +0 -1
- package/dist/commands/deployTheme.d.ts +0 -28
- package/dist/commands/deployTheme.d.ts.map +0 -1
- package/dist/commands/deployTheme.js +0 -68
- package/dist/commands/deployTheme.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -3
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -47
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/fsExec.d.ts +0 -8
- package/dist/commands/fsExec.d.ts.map +0 -1
- package/dist/commands/fsExec.js +0 -46
- package/dist/commands/fsExec.js.map +0 -1
- package/dist/commands/serve.d.ts +0 -1
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -2
- package/dist/commands/serve.js.map +0 -1
- package/dist/commands/terseCliTheme.d.ts +0 -28
- package/dist/commands/terseCliTheme.d.ts.map +0 -1
- package/dist/commands/terseCliTheme.js +0 -68
- package/dist/commands/terseCliTheme.js.map +0 -1
- package/dist/commands/tool.d.ts +0 -6
- package/dist/commands/tool.d.ts.map +0 -1
- package/dist/commands/tool.js +0 -34
- package/dist/commands/tool.js.map +0 -1
- package/dist/data/standardSlackEmoji.d.ts +0 -2
- package/dist/data/standardSlackEmoji.d.ts.map +0 -1
- package/dist/data/standardSlackEmoji.js +0 -1978
- package/dist/data/standardSlackEmoji.js.map +0 -1
- package/dist/data/standardSlackEmoji.json +0 -1974
- package/dist/perf.d.ts +0 -9
- package/dist/perf.d.ts.map +0 -1
- package/dist/perf.js +0 -59
- package/dist/perf.js.map +0 -1
- package/dist/providers/codegen.test.d.ts +0 -2
- package/dist/providers/codegen.test.d.ts.map +0 -1
- package/dist/providers/codegen.test.js +0 -45
- package/dist/providers/codegen.test.js.map +0 -1
- package/dist/providers/python/PythonProvider.test.d.ts +0 -2
- package/dist/providers/python/PythonProvider.test.d.ts.map +0 -1
- package/dist/providers/python/PythonProvider.test.js +0 -169
- package/dist/providers/python/PythonProvider.test.js.map +0 -1
- package/dist/providers/typescript/attioProjection.d.ts +0 -50
- package/dist/providers/typescript/attioProjection.d.ts.map +0 -1
- package/dist/providers/typescript/attioProjection.js +0 -358
- package/dist/providers/typescript/attioProjection.js.map +0 -1
- package/dist/providers/typescript/prepareCodegenData.test.d.ts +0 -2
- package/dist/providers/typescript/prepareCodegenData.test.d.ts.map +0 -1
- package/dist/providers/typescript/prepareCodegenData.test.js +0 -54
- package/dist/providers/typescript/prepareCodegenData.test.js.map +0 -1
- package/dist/providers/typescript/projectedTypes.d.ts +0 -11
- package/dist/providers/typescript/projectedTypes.d.ts.map +0 -1
- package/dist/providers/typescript/projectedTypes.js +0 -53
- package/dist/providers/typescript/projectedTypes.js.map +0 -1
- package/dist/providers/typescript/projectionPrinter.d.ts +0 -26
- package/dist/providers/typescript/projectionPrinter.d.ts.map +0 -1
- package/dist/providers/typescript/projectionPrinter.js +0 -110
- package/dist/providers/typescript/projectionPrinter.js.map +0 -1
- package/dist/providers/typescript/replayLogDedupe.d.ts +0 -6
- package/dist/providers/typescript/replayLogDedupe.d.ts.map +0 -1
- package/dist/providers/typescript/replayLogDedupe.js +0 -156
- package/dist/providers/typescript/replayLogDedupe.js.map +0 -1
- package/dist/providers/typescript/triggerPayloads.d.ts +0 -7
- package/dist/providers/typescript/triggerPayloads.d.ts.map +0 -1
- package/dist/providers/typescript/triggerPayloads.js +0 -60
- package/dist/providers/typescript/triggerPayloads.js.map +0 -1
- package/dist/providers/typescript/triggerTypeRegistry.d.ts +0 -7
- package/dist/providers/typescript/triggerTypeRegistry.d.ts.map +0 -1
- package/dist/providers/typescript/triggerTypeRegistry.js +0 -198
- package/dist/providers/typescript/triggerTypeRegistry.js.map +0 -1
- package/dist/triggerParseDetail.d.ts +0 -8
- package/dist/triggerParseDetail.d.ts.map +0 -1
- package/dist/triggerParseDetail.js +0 -30
- package/dist/triggerParseDetail.js.map +0 -1
- package/templates/typescript/codegen/.impeccable/hook.cache.json +0 -1
package/dist/init.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
1
|
import fs from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
3
|
+
import { exec, execSync } from "node:child_process";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
4
6
|
import ora from "ora";
|
|
5
|
-
import
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import { input } from "@inquirer/prompts";
|
|
6
9
|
import { generate } from "./generate.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export async function init(projectName
|
|
12
|
-
if (!projectName && fs.existsSync(path.join(process.cwd(), "package.json"))) {
|
|
13
|
-
console.error(chalk.red("\n Error: Detected an existing npm project in this directory."));
|
|
14
|
-
console.error(chalk.dim(" terse init is for scaffolding new projects only.\n"));
|
|
15
|
-
console.error(` To add Terse to this project for self-hosted mode, run ${chalk.cyan("terse attach")} instead.\n`);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
10
|
+
import { FRONTEND_URL, BACKEND_URL } from "./config.js";
|
|
11
|
+
const execAsync = promisify(exec);
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
export async function init(projectName) {
|
|
18
15
|
const targetDir = projectName ? path.resolve(process.cwd(), projectName) : process.cwd();
|
|
19
16
|
const resolvedName = projectName ?? path.basename(process.cwd());
|
|
20
17
|
console.log(`\n Creating Terse project ${chalk.bold(resolvedName)}\n`);
|
|
@@ -26,39 +23,40 @@ export async function init(projectName, provider = resolveProvider({ command: "i
|
|
|
26
23
|
}
|
|
27
24
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
28
25
|
}
|
|
29
|
-
// Create
|
|
26
|
+
// Create src directory
|
|
30
27
|
fs.mkdirSync(path.join(targetDir, "src"), { recursive: true });
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
versionSpinner.succeed(`Using terse-sdk ${sdkVersion}`);
|
|
34
|
-
const templateContext = provider.buildInitTemplateContext(resolvedName, sdkVersion);
|
|
28
|
+
const templatesDir = getTemplatesDir();
|
|
29
|
+
const replacements = { PROJECT_NAME: resolvedName };
|
|
35
30
|
// Write files from templates
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const files = [
|
|
32
|
+
{ template: "package.json.tmpl", output: "package.json" },
|
|
33
|
+
{ template: "tsconfig.json.tmpl", output: "tsconfig.json" },
|
|
34
|
+
{ template: "src/index.ts.tmpl", output: "src/index.ts" },
|
|
35
|
+
{ template: "env.example.tmpl", output: ".env.example" },
|
|
36
|
+
{ template: "gitignore.tmpl", output: ".gitignore" },
|
|
37
|
+
];
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
const content = readTemplate(templatesDir, file.template);
|
|
40
|
+
const rendered = applyReplacements(content, replacements);
|
|
38
41
|
const outputPath = path.join(targetDir, file.output);
|
|
39
|
-
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
40
42
|
fs.writeFileSync(outputPath, rendered);
|
|
41
43
|
console.log(` ${chalk.green("+")} ${file.output}`);
|
|
42
44
|
}
|
|
43
45
|
// Install dependencies
|
|
44
|
-
const pm =
|
|
46
|
+
const pm = detectPackageManager();
|
|
45
47
|
const spinner = ora(`Installing dependencies with ${pm}`).start();
|
|
46
|
-
// Rest of commands run in newly generated project directory
|
|
47
|
-
await changeDirectory(targetDir);
|
|
48
48
|
try {
|
|
49
|
-
await
|
|
49
|
+
await execAsync(`${pm} install`, { cwd: targetDir });
|
|
50
50
|
spinner.succeed(`Dependencies installed with ${pm}`);
|
|
51
51
|
}
|
|
52
52
|
catch {
|
|
53
53
|
spinner.warn(`Failed to install dependencies. Run ${chalk.cyan(`${pm} install`)} manually.`);
|
|
54
54
|
}
|
|
55
|
-
//
|
|
56
|
-
await
|
|
55
|
+
// Prompt for API key and write .env
|
|
56
|
+
await promptForApiKey(targetDir);
|
|
57
57
|
const envExists = fs.existsSync(path.join(targetDir, ".env"));
|
|
58
|
-
// Connect integrations
|
|
59
|
-
await listAndPromptIntegrations();
|
|
60
58
|
try {
|
|
61
|
-
await generate(
|
|
59
|
+
await generate();
|
|
62
60
|
spinner.succeed(`Generated code`);
|
|
63
61
|
}
|
|
64
62
|
catch {
|
|
@@ -72,27 +70,80 @@ export async function init(projectName, provider = resolveProvider({ command: "i
|
|
|
72
70
|
step++;
|
|
73
71
|
}
|
|
74
72
|
if (!envExists) {
|
|
75
|
-
console.log(` ${step}.
|
|
73
|
+
console.log(` ${step}. Copy .env.example to .env and add your TERSE_API_KEY`);
|
|
76
74
|
step++;
|
|
77
75
|
}
|
|
78
|
-
console.log(` ${step}. Edit
|
|
76
|
+
console.log(` ${step}. Edit src/index.ts to define your job`);
|
|
79
77
|
step++;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
step++;
|
|
84
|
-
}
|
|
85
|
-
console.log("");
|
|
78
|
+
console.log(` ${step}. ${pm} run build Build the project`);
|
|
79
|
+
step++;
|
|
80
|
+
console.log(` ${step}. ${pm} run dev Run in development mode\n`);
|
|
86
81
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
82
|
+
async function promptForApiKey(targetDir) {
|
|
83
|
+
console.log(`\n Create an API key at: ${chalk.cyan(`${FRONTEND_URL}/app/profile?tab=api-tokens`)}\n`);
|
|
84
|
+
try {
|
|
85
|
+
const key = (await input({ message: "Paste your API key (or press Enter to skip):" })).trim();
|
|
86
|
+
if (!key) {
|
|
87
|
+
fs.writeFileSync(path.join(targetDir, ".env"), "TERSE_API_KEY=\n");
|
|
88
|
+
console.log(chalk.dim(" Skipped — you can add TERSE_API_KEY to .env later."));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Validate the key against the backend
|
|
92
|
+
const spinner = ora("Verifying API key").start();
|
|
89
93
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
const res = await fetch(`${BACKEND_URL}/sdk/me`, {
|
|
95
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
96
|
+
});
|
|
97
|
+
if (res.ok) {
|
|
98
|
+
const data = await res.json();
|
|
99
|
+
const name = data.firstName || data.displayName || data.email || "there";
|
|
100
|
+
spinner.succeed(`Hello, ${name}! API key verified.`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
spinner.warn("Could not verify API key (invalid or server error). Saving it anyway.");
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
|
-
catch
|
|
94
|
-
|
|
106
|
+
catch {
|
|
107
|
+
spinner.warn("Could not reach the server to verify your API key. Saving it anyway.");
|
|
108
|
+
}
|
|
109
|
+
fs.writeFileSync(path.join(targetDir, ".env"), `TERSE_API_KEY=${key}\n`);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error instanceof Error && error.name === "ExitPromptError") {
|
|
113
|
+
console.log("\n");
|
|
114
|
+
process.exit(0);
|
|
95
115
|
}
|
|
96
|
-
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function getTemplatesDir() {
|
|
120
|
+
// In dist/, templates are at ../templates relative to the compiled file
|
|
121
|
+
const fromDist = path.resolve(__dirname, "..", "templates");
|
|
122
|
+
if (fs.existsSync(fromDist))
|
|
123
|
+
return fromDist;
|
|
124
|
+
// Fallback for development
|
|
125
|
+
const fromSrc = path.resolve(__dirname, "..", "..", "templates");
|
|
126
|
+
if (fs.existsSync(fromSrc))
|
|
127
|
+
return fromSrc;
|
|
128
|
+
throw new Error("Could not find templates directory");
|
|
129
|
+
}
|
|
130
|
+
function readTemplate(templatesDir, templatePath) {
|
|
131
|
+
return fs.readFileSync(path.join(templatesDir, templatePath), "utf-8");
|
|
132
|
+
}
|
|
133
|
+
function applyReplacements(content, replacements) {
|
|
134
|
+
let result = content;
|
|
135
|
+
for (const [token, value] of Object.entries(replacements)) {
|
|
136
|
+
result = result.replaceAll(`{{${token}}}`, value);
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
function detectPackageManager() {
|
|
141
|
+
try {
|
|
142
|
+
execSync("pnpm --version", { stdio: "ignore" });
|
|
143
|
+
return "pnpm";
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return "npm";
|
|
147
|
+
}
|
|
97
148
|
}
|
|
98
149
|
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,QAA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C,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAA;AAC1E,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe,EAAE,YAAoC;IAC5E,IAAI,MAAM,GAAG,OAAO,CAAA;IACpB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC;AAED,SAAS,oBAAoB;IACzB,IAAI,CAAC;QACD,QAAQ,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC/C,OAAO,MAAM,CAAA;IACjB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC"}
|
package/dist/integrate.d.ts
CHANGED
package/dist/integrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrate.d.ts","sourceRoot":"","sources":["../src/integrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integrate.d.ts","sourceRoot":"","sources":["../src/integrate.ts"],"names":[],"mappings":"AAKA,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAa/C"}
|
package/dist/integrate.js
CHANGED
|
@@ -1,199 +1,19 @@
|
|
|
1
|
-
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
2
|
-
import chalk from "chalk";
|
|
3
1
|
import { spawn } from "node:child_process";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { generate } from "./generate.js";
|
|
8
|
-
import { fetchInstallationUrl, fetchIntegrationFields, fetchIntegrations, pollForConnection, submitIntegrationForm } from "./integrationApi.js";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { FRONTEND_URL } from "./config.js";
|
|
4
|
+
const INTEGRATIONS_URL = `${FRONTEND_URL}/app/integrations`;
|
|
9
5
|
export async function integrate() {
|
|
10
|
-
const apiKey = readApiKeyOrBail();
|
|
11
|
-
let didChangeAnyIntegration = false;
|
|
12
|
-
let continueLoop = true;
|
|
13
|
-
while (continueLoop) {
|
|
14
|
-
const result = await connectOneIntegration(apiKey);
|
|
15
|
-
didChangeAnyIntegration = didChangeAnyIntegration || result.status !== "unchanged";
|
|
16
|
-
console.log("");
|
|
17
|
-
continueLoop = await confirm({ message: "Connect another integration?", default: false });
|
|
18
|
-
}
|
|
19
|
-
if (didChangeAnyIntegration) {
|
|
20
|
-
await generate();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export async function listAndPromptIntegrations() {
|
|
24
|
-
const apiKey = readApiKey();
|
|
25
|
-
if (!apiKey)
|
|
26
|
-
return;
|
|
27
|
-
let integrations;
|
|
28
|
-
try {
|
|
29
|
-
integrations = await fetchIntegrations(apiKey);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
console.error(chalk.red("Failed to fetch integrations"));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const active = integrations.filter(i => i.isActive && i.integrationType !== IntegrationType.TERSE && i.integrationType !== IntegrationType.CRON_JOB);
|
|
36
|
-
if (active.length > 0) {
|
|
37
|
-
console.log("\n Connected integrations:\n");
|
|
38
|
-
for (const i of active) {
|
|
39
|
-
const meta = INTEGRATION_METADATA[i.integrationType];
|
|
40
|
-
console.log(` ${chalk.green("✓")} ${meta?.name || i.integrationType}`);
|
|
41
|
-
}
|
|
42
|
-
console.log("");
|
|
43
|
-
const addMore = await confirm({ message: "Connect another integration?", default: false });
|
|
44
|
-
if (addMore)
|
|
45
|
-
await integrate();
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.log(chalk.dim("\n No integrated tools yet.\n"));
|
|
49
|
-
await integrate();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async function connectOneIntegration(apiKey) {
|
|
53
|
-
const spinner = ora("Fetching integrations").start();
|
|
54
|
-
let integrations;
|
|
55
|
-
try {
|
|
56
|
-
integrations = await fetchIntegrations(apiKey);
|
|
57
|
-
spinner.stop();
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
spinner.fail("Failed to fetch integrations");
|
|
61
|
-
console.error(chalk.red(` ${err.message}`));
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
// Filter out system integrations
|
|
65
|
-
const userFacing = integrations.filter(i => i.integrationType !== IntegrationType.TERSE && i.integrationType !== IntegrationType.CRON_JOB);
|
|
66
|
-
if (userFacing.length === 0) {
|
|
67
|
-
console.log(chalk.yellow("\n No integrations available.\n"));
|
|
68
|
-
return { status: "unchanged" };
|
|
69
|
-
}
|
|
70
|
-
const selected = await select({
|
|
71
|
-
message: "Select an integration to connect",
|
|
72
|
-
choices: userFacing.map(i => {
|
|
73
|
-
const meta = INTEGRATION_METADATA[i.integrationType];
|
|
74
|
-
const name = meta?.name || i.integrationType;
|
|
75
|
-
const status = i.isActive ? chalk.green(" ✓ connected") : chalk.dim(" not connected");
|
|
76
|
-
return {
|
|
77
|
-
name: `${name}${status}`,
|
|
78
|
-
value: i.integrationType,
|
|
79
|
-
description: meta?.description
|
|
80
|
-
};
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
const selectedIntegration = userFacing.find(i => i.integrationType === selected);
|
|
84
|
-
// Fetch fields for the selected integration
|
|
85
|
-
const fieldsSpinner = ora("Loading integration details").start();
|
|
86
|
-
let fieldsResponse;
|
|
87
|
-
try {
|
|
88
|
-
fieldsResponse = await fetchIntegrationFields(apiKey, selected);
|
|
89
|
-
fieldsSpinner.stop();
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
fieldsSpinner.fail("Failed to load integration details");
|
|
93
|
-
console.error(chalk.red(` ${err.message}`));
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
if (fieldsResponse.installationType === "form") {
|
|
97
|
-
const didUpdate = await handleFormIntegration(apiKey, selected, fieldsResponse.fields);
|
|
98
|
-
return {
|
|
99
|
-
status: didUpdate ? (selectedIntegration?.isActive ? "modified" : "added") : "unchanged",
|
|
100
|
-
integrationType: selected
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
else if (fieldsResponse.installationType === "oauth") {
|
|
104
|
-
const didUpdate = await handleOAuthIntegration(apiKey, selected, fieldsResponse.fields);
|
|
105
|
-
return {
|
|
106
|
-
status: didUpdate ? (selectedIntegration?.isActive ? "modified" : "added") : "unchanged",
|
|
107
|
-
integrationType: selected
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
console.log(chalk.yellow(`\n Integration '${selected}' has an unsupported installation type.\n`));
|
|
112
|
-
return {
|
|
113
|
-
status: "unchanged",
|
|
114
|
-
integrationType: selected
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// ─── Form-based integrations (Datadog, PostHog, Snowflake, etc.) ─────────────
|
|
119
|
-
async function handleFormIntegration(apiKey, integrationType, fields) {
|
|
120
6
|
console.log("");
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
validate: field.required ? v => (v.length > 0 ? true : `${field.label} is required`) : undefined
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
formValues[field.name] = await input({
|
|
132
|
-
message: `${field.label}${hint}`,
|
|
133
|
-
default: field.placeholder,
|
|
134
|
-
validate: field.required ? v => (v.length > 0 ? true : `${field.label} is required`) : undefined
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const spinner = ora("Connecting integration").start();
|
|
139
|
-
try {
|
|
140
|
-
const result = await submitIntegrationForm(apiKey, integrationType, formValues);
|
|
141
|
-
if (result.success) {
|
|
142
|
-
spinner.succeed(chalk.green("Integration connected successfully"));
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
spinner.fail(`Failed to connect: ${result.error || "Unknown error"}`);
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (err) {
|
|
151
|
-
spinner.fail("Failed to connect integration");
|
|
152
|
-
console.error(chalk.red(` ${err.message}`));
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// ─── OAuth-based integrations (Slack, GitHub, Gmail, etc.) ───────────────────
|
|
157
|
-
async function handleOAuthIntegration(apiKey, integrationType, configFields) {
|
|
158
|
-
// Prompt for configuration fields if any (e.g. Slack's bot vs user choice)
|
|
159
|
-
let options;
|
|
160
|
-
if (configFields.length > 0) {
|
|
161
|
-
console.log("");
|
|
162
|
-
options = {};
|
|
163
|
-
for (const field of configFields) {
|
|
164
|
-
const value = await select({
|
|
165
|
-
message: field.label,
|
|
166
|
-
choices: field.options.map(o => ({ name: o.label, value: o.value }))
|
|
167
|
-
});
|
|
168
|
-
options[field.name] = value;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const spinner = ora("Getting authorization URL").start();
|
|
172
|
-
let installationDetails;
|
|
173
|
-
try {
|
|
174
|
-
installationDetails = await fetchInstallationUrl(apiKey, integrationType, options);
|
|
175
|
-
spinner.stop();
|
|
176
|
-
}
|
|
177
|
-
catch (err) {
|
|
178
|
-
spinner.fail("Failed to get authorization URL");
|
|
179
|
-
console.error(chalk.red(` ${err.message}`));
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
console.log(`\n ${chalk.bold("Complete authorization in your browser:")}\n`);
|
|
183
|
-
console.log(` ${chalk.cyan(installationDetails.oauthUrl)}\n`);
|
|
184
|
-
openInBrowser(installationDetails.oauthUrl);
|
|
185
|
-
const pollSpinner = ora("Waiting for authorization to complete").start();
|
|
186
|
-
const connected = await pollForConnection(apiKey, integrationType);
|
|
187
|
-
if (connected) {
|
|
188
|
-
pollSpinner.succeed(chalk.green("Integration connected successfully"));
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
pollSpinner.fail("Authorization timed out — please try again");
|
|
193
|
-
return false;
|
|
7
|
+
console.log(` Open integrations in the Web UI: ${chalk.cyan(INTEGRATIONS_URL)}`);
|
|
8
|
+
console.log("");
|
|
9
|
+
const opened = openInBrowser(INTEGRATIONS_URL);
|
|
10
|
+
if (opened) {
|
|
11
|
+
console.log(chalk.green(" Opened in your default browser."));
|
|
12
|
+
return;
|
|
194
13
|
}
|
|
14
|
+
console.log(chalk.yellow(" Could not open browser automatically."));
|
|
15
|
+
console.log(` Open manually: ${chalk.cyan(INTEGRATIONS_URL)}`);
|
|
195
16
|
}
|
|
196
|
-
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
197
17
|
function openInBrowser(url) {
|
|
198
18
|
try {
|
|
199
19
|
if (process.platform === "darwin") {
|
package/dist/integrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrate.js","sourceRoot":"","sources":["../src/integrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"integrate.js","sourceRoot":"","sources":["../src/integrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,MAAM,gBAAgB,GAAG,GAAG,YAAY,mBAAmB,CAAA;AAE3D,MAAM,CAAC,KAAK,UAAU,SAAS;IAC3B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACf,OAAO,CAAC,GAAG,CAAC,sCAAsC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAA;IACjF,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
|
|
1
|
+
import type { Ora } from "ora";
|
|
2
|
+
export type JsonErrorPayload = {
|
|
3
|
+
error: {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare function emitJsonError(code: string, message: string, details?: Record<string, unknown>): void;
|
|
10
|
+
export declare function bailJsonError(code: string, message: string, details?: Record<string, unknown>, exitCode?: number): never;
|
|
11
|
+
export type GuardOptions = {
|
|
12
|
+
spinner?: Ora | null;
|
|
13
|
+
json?: boolean;
|
|
14
|
+
failMessage: string;
|
|
15
|
+
code: string;
|
|
16
|
+
details?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
export declare function withJsonError<T>(fn: () => Promise<T>, opts: GuardOptions): Promise<T>;
|
|
19
|
+
//# sourceMappingURL=jsonOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonOutput.d.ts","sourceRoot":"","sources":["../src/jsonOutput.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAK9B,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACzB,CAAA;CACJ,CAAA;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,IAAI,CAGxG;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,KAAK,CAG/H;AAED,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAKD,wBAAsB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAU3F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function emitJsonError(code, message, details = {}) {
|
|
3
|
+
const payload = { error: { code, message, ...details } };
|
|
4
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
5
|
+
}
|
|
6
|
+
export function bailJsonError(code, message, details = {}, exitCode = 1) {
|
|
7
|
+
emitJsonError(code, message, details);
|
|
8
|
+
process.exit(exitCode);
|
|
9
|
+
}
|
|
10
|
+
// Wraps an async call so that failures (a) stop the spinner with a red label in TTY mode,
|
|
11
|
+
// (b) emit a structured JSON error and exit 1 in --json mode, and (c) re-throw otherwise so
|
|
12
|
+
// the top-level error handler can surface the trace.
|
|
13
|
+
export async function withJsonError(fn, opts) {
|
|
14
|
+
try {
|
|
15
|
+
return await fn();
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
opts.spinner?.fail(chalk.red(opts.failMessage));
|
|
19
|
+
if (opts.json) {
|
|
20
|
+
bailJsonError(opts.code, error instanceof Error ? error.message : String(error), opts.details);
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=jsonOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonOutput.js","sourceRoot":"","sources":["../src/jsonOutput.ts"],"names":[],"mappings":"AAAA,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: boolean;
|
|
2
3
|
nonInteractive?: boolean;
|
|
3
4
|
};
|
|
4
5
|
/**
|
|
5
6
|
* True when the CLI should avoid any interactive prompt. Honors the explicit
|
|
6
7
|
* flag first, falls back to TTY detection so subprocess / piped invocations
|
|
7
|
-
* behave non-interactively without the caller needing to pass `--
|
|
8
|
+
* behave non-interactively without the caller needing to pass `--yes`.
|
|
8
9
|
*/
|
|
9
10
|
export declare function isNonInteractive(opts?: NonInteractiveOpts): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Supports parsing a series of key=value flags from the CLI.
|
|
12
|
-
*/
|
|
13
11
|
export declare function parseKeyValueFlags(values: string[] | undefined): Record<string, string>;
|
|
14
12
|
/**
|
|
15
13
|
* Read a JSON object from stdin and return it as a string map. Used by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nonInteractive.d.ts","sourceRoot":"","sources":["../src/nonInteractive.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAGnE;AAED
|
|
1
|
+
{"version":3,"file":"nonInteractive.d.ts","sourceRoot":"","sources":["../src/nonInteractive.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG;IAC7B,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAGnE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUvF;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA6B3E"}
|
package/dist/nonInteractive.js
CHANGED
|
@@ -2,16 +2,13 @@ import { CliError } from "./cliError.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* True when the CLI should avoid any interactive prompt. Honors the explicit
|
|
4
4
|
* flag first, falls back to TTY detection so subprocess / piped invocations
|
|
5
|
-
* behave non-interactively without the caller needing to pass `--
|
|
5
|
+
* behave non-interactively without the caller needing to pass `--yes`.
|
|
6
6
|
*/
|
|
7
7
|
export function isNonInteractive(opts) {
|
|
8
|
-
if (opts?.nonInteractive)
|
|
8
|
+
if (opts?.yes || opts?.nonInteractive)
|
|
9
9
|
return true;
|
|
10
10
|
return !process.stdin.isTTY || !process.stdout.isTTY;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Supports parsing a series of key=value flags from the CLI.
|
|
14
|
-
*/
|
|
15
12
|
export function parseKeyValueFlags(values) {
|
|
16
13
|
const out = {};
|
|
17
14
|
for (const raw of values ?? []) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nonInteractive.js","sourceRoot":"","sources":["../src/nonInteractive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"nonInteractive.js","sourceRoot":"","sources":["../src/nonInteractive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAOxC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAyB;IACtD,IAAI,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,cAAc;QAAE,OAAO,IAAI,CAAA;IAClD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAA;AACxD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAA4B;IAC3D,MAAM,GAAG,GAA2B,EAAE,CAAA;IACtC,KA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,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SAC3D,CAAC,CAAA;IACN,CAAC;IAED,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EAAE,iCAAiC,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE,CAAC,CAAA;IAC5H,CAAC;IAED,MAAM,GAAG,GAA2B,EAAE,CAAA;IACtC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAiC,CAAC,EAAE,CAAC;QACrE,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAA;QAC/E,CAAC;QACD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IACD,OAAO,GAAG,CAAA;AACd,CAAC"}
|
|
@@ -175,7 +175,6 @@ export const pythonProvider = new PythonProvider();
|
|
|
175
175
|
function createJobParametersFromPython(data) {
|
|
176
176
|
const jobParams = {
|
|
177
177
|
name: data.name,
|
|
178
|
-
// TODO: Temporarily adding unknown, fixing this later.
|
|
179
178
|
triggers: (data.triggers ?? []).map(reconstructPythonConfig),
|
|
180
179
|
onTrigger: async () => {
|
|
181
180
|
throw new Error("Python job execution must go through provider.executeJob()");
|