@fkws/klonk 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "name": "@fkws/klonk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A lightweight, extensible workflow automation engine for Node.js and Bun",
5
- "bin": {
6
- "klonk": "./dist/cli.js"
7
- },
8
5
  "module": "dist/index.js",
9
6
  "main": "dist/index.js",
10
7
  "types": "dist/index.d.ts",
@@ -43,19 +40,13 @@
43
40
  "author": "FKWS (https://klonk.dev)",
44
41
  "devDependencies": {
45
42
  "@types/bun": "latest",
46
- "@types/express": "^5.0.1",
47
43
  "@types/node": "latest",
48
- "bunup": "^0.6.2",
49
- "tavily": "^1.0.2"
44
+ "bunup": "^0.6.2"
50
45
  },
51
46
  "peerDependencies": {
52
47
  "typescript": "^5"
53
48
  },
54
49
  "dependencies": {
55
- "cli-highlight": "^2.1.11",
56
- "commander": "^13.1.0",
57
- "express": "^5.1.0",
58
- "json-to-zod": "^1.1.2",
59
50
  "pino": "^10.1.0"
60
51
  }
61
52
  }
package/dist/cli.cjs DELETED
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env node
2
- var import_node_module = require("node:module");
3
- var __create = Object.create;
4
- var __getProtoOf = Object.getPrototypeOf;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
-
20
- // src/cli.ts
21
- var import_commander = require("commander");
22
- var import_express = __toESM(require("express"));
23
- var import_json_to_zod = require("json-to-zod");
24
- var import_cli_highlight = require("cli-highlight");
25
- var readline = __toESM(require("node:readline/promises"));
26
- var import_node_process = require("node:process");
27
- var program = new import_commander.Command;
28
- program.name("klonk").description("CLI for Klonk workflow automation engine").version("0.1.18");
29
- program.command("test").description("Run a test to check if the CLI is working.").action(() => {
30
- console.log("TEST SUCCESSFUL");
31
- });
32
- var setupCommand = program.command("setup").description("Setup integrations");
33
- var setupIntegrationCommand = setupCommand.command("integration").description("Setup a specific integration");
34
- setupIntegrationCommand.command("dropbox").description("Get a refresh token for Dropbox").action(async () => {
35
- const rl = readline.createInterface({ input: import_node_process.stdin, output: import_node_process.stdout });
36
- const appKey = await rl.question("Enter your Dropbox App Key: ");
37
- const appSecret = await rl.question("Enter your Dropbox App Secret: ");
38
- console.log(`
39
- Please go to this URL to authorize the app:
40
- https://www.dropbox.com/oauth2/authorize?client_id=${appKey}&response_type=code&token_access_type=offline
41
- `);
42
- const authCode = await rl.question("Paste the authorization code here: ");
43
- rl.close();
44
- try {
45
- const response = await fetch("https://api.dropbox.com/oauth2/token", {
46
- method: "POST",
47
- headers: {
48
- "Content-Type": "application/x-www-form-urlencoded",
49
- Authorization: `Basic ${Buffer.from(`${appKey}:${appSecret}`).toString("base64")}`
50
- },
51
- body: new URLSearchParams({
52
- code: authCode,
53
- grant_type: "authorization_code"
54
- })
55
- });
56
- const data = await response.json();
57
- if (!response.ok) {
58
- console.error(`
59
- Error getting refresh token:`);
60
- console.error(import_cli_highlight.highlight(JSON.stringify(data, null, 2), { language: "json" }));
61
- process.exit(1);
62
- }
63
- console.log(`
64
- Success! Here are your tokens:`);
65
- console.log(import_cli_highlight.highlight(JSON.stringify(data, null, 2), { language: "json" }));
66
- console.log("\nStore the `refresh_token` securely. You will use it, along with your app key and secret, to configure the Dropbox integration.");
67
- } catch (error) {
68
- console.error(`
69
- An error occurred while fetching the refresh token:`, error);
70
- }
71
- });
72
- var introspectCommand = program.command("introspect").description("Introspection utilities");
73
- introspectCommand.command("webhook-payload").description("Introspect a webhook payload").option("--gt, --generate-type", "Generate a TypeScript type definition for the payload").option("-p, --port <port>", "Port to listen on", "2021").option("--base-url <url>", "Base URL for the webhook endpoint").action(async (options) => {
74
- const app = import_express.default();
75
- app.use(import_express.default.json());
76
- const port = parseInt(options.port, 10);
77
- const displayUrl = options.baseUrl ? options.baseUrl : `http://localhost:${port}`;
78
- let server = null;
79
- const closeServer = () => {
80
- if (server) {
81
- server.close(() => {
82
- console.log(`
83
- Server closed.`);
84
- process.exit(0);
85
- });
86
- }
87
- };
88
- app.get("/", (req, res) => {
89
- const challenge = req.query.challenge;
90
- if (challenge && typeof challenge === "string") {
91
- console.log(`
92
- Received verification challenge. Responding with: ${challenge}`);
93
- res.setHeader("Content-Type", "text/plain");
94
- res.status(200).send(challenge);
95
- console.log("Challenge response sent. Waiting for POST payload...");
96
- return;
97
- }
98
- console.warn(`
99
- Received GET request to / without a 'challenge' parameter.`);
100
- res.status(400).send('Bad Request: Missing "challenge" query parameter.');
101
- });
102
- app.post("/", (req, res) => {
103
- const payload = req.body;
104
- console.log(`
105
- Webhook Payload:`);
106
- console.log(import_cli_highlight.highlight(JSON.stringify(payload, null, 2), { language: "json", ignoreIllegals: true }));
107
- if (options.generateType) {
108
- try {
109
- const zodSchemaString = import_json_to_zod.jsonToZod(payload, "PayloadSchema", true);
110
- const typeAliasString = `
111
- type Payload = z.infer<typeof PayloadSchema>;`;
112
- const combinedOutput = zodSchemaString + typeAliasString;
113
- console.log(`
114
- Generated Zod Schema & TypeScript Type:`);
115
- console.log(import_cli_highlight.highlight(combinedOutput, { language: "typescript", ignoreIllegals: true }));
116
- } catch (error) {
117
- console.error(`
118
- Error generating Zod schema:`, error);
119
- }
120
- }
121
- res.status(200).send("Payload received");
122
- closeServer();
123
- });
124
- server = app.listen(port, () => {
125
- console.log(`Listening for webhook payload on ${displayUrl}`);
126
- });
127
- server.on("error", (error) => {
128
- console.error("Server error:", error);
129
- process.exit(1);
130
- });
131
- });
132
- program.parse(process.argv);
package/dist/cli.d.ts DELETED
File without changes
package/dist/cli.js DELETED
@@ -1,115 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/cli.ts
4
- import { Command } from "commander";
5
- import express from "express";
6
- import { jsonToZod } from "json-to-zod";
7
- import { highlight } from "cli-highlight";
8
- import * as readline from "node:readline/promises";
9
- import { stdin as input, stdout as output } from "node:process";
10
- var program = new Command;
11
- program.name("klonk").description("CLI for Klonk workflow automation engine").version("0.1.18");
12
- program.command("test").description("Run a test to check if the CLI is working.").action(() => {
13
- console.log("TEST SUCCESSFUL");
14
- });
15
- var setupCommand = program.command("setup").description("Setup integrations");
16
- var setupIntegrationCommand = setupCommand.command("integration").description("Setup a specific integration");
17
- setupIntegrationCommand.command("dropbox").description("Get a refresh token for Dropbox").action(async () => {
18
- const rl = readline.createInterface({ input, output });
19
- const appKey = await rl.question("Enter your Dropbox App Key: ");
20
- const appSecret = await rl.question("Enter your Dropbox App Secret: ");
21
- console.log(`
22
- Please go to this URL to authorize the app:
23
- https://www.dropbox.com/oauth2/authorize?client_id=${appKey}&response_type=code&token_access_type=offline
24
- `);
25
- const authCode = await rl.question("Paste the authorization code here: ");
26
- rl.close();
27
- try {
28
- const response = await fetch("https://api.dropbox.com/oauth2/token", {
29
- method: "POST",
30
- headers: {
31
- "Content-Type": "application/x-www-form-urlencoded",
32
- Authorization: `Basic ${Buffer.from(`${appKey}:${appSecret}`).toString("base64")}`
33
- },
34
- body: new URLSearchParams({
35
- code: authCode,
36
- grant_type: "authorization_code"
37
- })
38
- });
39
- const data = await response.json();
40
- if (!response.ok) {
41
- console.error(`
42
- Error getting refresh token:`);
43
- console.error(highlight(JSON.stringify(data, null, 2), { language: "json" }));
44
- process.exit(1);
45
- }
46
- console.log(`
47
- Success! Here are your tokens:`);
48
- console.log(highlight(JSON.stringify(data, null, 2), { language: "json" }));
49
- console.log("\nStore the `refresh_token` securely. You will use it, along with your app key and secret, to configure the Dropbox integration.");
50
- } catch (error) {
51
- console.error(`
52
- An error occurred while fetching the refresh token:`, error);
53
- }
54
- });
55
- var introspectCommand = program.command("introspect").description("Introspection utilities");
56
- introspectCommand.command("webhook-payload").description("Introspect a webhook payload").option("--gt, --generate-type", "Generate a TypeScript type definition for the payload").option("-p, --port <port>", "Port to listen on", "2021").option("--base-url <url>", "Base URL for the webhook endpoint").action(async (options) => {
57
- const app = express();
58
- app.use(express.json());
59
- const port = parseInt(options.port, 10);
60
- const displayUrl = options.baseUrl ? options.baseUrl : `http://localhost:${port}`;
61
- let server = null;
62
- const closeServer = () => {
63
- if (server) {
64
- server.close(() => {
65
- console.log(`
66
- Server closed.`);
67
- process.exit(0);
68
- });
69
- }
70
- };
71
- app.get("/", (req, res) => {
72
- const challenge = req.query.challenge;
73
- if (challenge && typeof challenge === "string") {
74
- console.log(`
75
- Received verification challenge. Responding with: ${challenge}`);
76
- res.setHeader("Content-Type", "text/plain");
77
- res.status(200).send(challenge);
78
- console.log("Challenge response sent. Waiting for POST payload...");
79
- return;
80
- }
81
- console.warn(`
82
- Received GET request to / without a 'challenge' parameter.`);
83
- res.status(400).send('Bad Request: Missing "challenge" query parameter.');
84
- });
85
- app.post("/", (req, res) => {
86
- const payload = req.body;
87
- console.log(`
88
- Webhook Payload:`);
89
- console.log(highlight(JSON.stringify(payload, null, 2), { language: "json", ignoreIllegals: true }));
90
- if (options.generateType) {
91
- try {
92
- const zodSchemaString = jsonToZod(payload, "PayloadSchema", true);
93
- const typeAliasString = `
94
- type Payload = z.infer<typeof PayloadSchema>;`;
95
- const combinedOutput = zodSchemaString + typeAliasString;
96
- console.log(`
97
- Generated Zod Schema & TypeScript Type:`);
98
- console.log(highlight(combinedOutput, { language: "typescript", ignoreIllegals: true }));
99
- } catch (error) {
100
- console.error(`
101
- Error generating Zod schema:`, error);
102
- }
103
- }
104
- res.status(200).send("Payload received");
105
- closeServer();
106
- });
107
- server = app.listen(port, () => {
108
- console.log(`Listening for webhook payload on ${displayUrl}`);
109
- });
110
- server.on("error", (error) => {
111
- console.error("Server error:", error);
112
- process.exit(1);
113
- });
114
- });
115
- program.parse(process.argv);