@smartlyqofficial/cli 0.1.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/LICENSE +21 -0
- package/README.md +354 -0
- package/dist/cli.js +505 -0
- package/dist/index.cjs +570 -0
- package/dist/index.d.cts +90 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +517 -0
- package/package.json +66 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
CliError: () => CliError,
|
|
34
|
+
buildProgram: () => buildProgram,
|
|
35
|
+
commands: () => commands,
|
|
36
|
+
configDir: () => configDir,
|
|
37
|
+
configPath: () => configPath,
|
|
38
|
+
deleteStoredApiKey: () => deleteStoredApiKey,
|
|
39
|
+
dispatch: () => dispatch,
|
|
40
|
+
formatError: () => formatError,
|
|
41
|
+
formatOutput: () => formatOutput,
|
|
42
|
+
kebabCase: () => kebabCase,
|
|
43
|
+
main: () => main,
|
|
44
|
+
parseData: () => parseData,
|
|
45
|
+
parseQuery: () => parseQuery,
|
|
46
|
+
promptHidden: () => promptHidden,
|
|
47
|
+
readStoredApiKey: () => readStoredApiKey,
|
|
48
|
+
resolveApiKey: () => resolveApiKey,
|
|
49
|
+
runLogin: () => runLogin,
|
|
50
|
+
runLogout: () => runLogout,
|
|
51
|
+
storeApiKey: () => storeApiKey
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(src_exports);
|
|
54
|
+
var import_commander = require("commander");
|
|
55
|
+
var import_node2 = __toESM(require("@smartlyqofficial/node"), 1);
|
|
56
|
+
|
|
57
|
+
// src/commands.gen.ts
|
|
58
|
+
var commands = [
|
|
59
|
+
{ "resourceKey": "account", "methodName": "getMe", "kebabMethod": "get-me", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get current user profile", "httpMethod": "GET", "path": "/me" },
|
|
60
|
+
{ "resourceKey": "account", "methodName": "getMeUsage", "kebabMethod": "get-me-usage", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "Get usage summary", "httpMethod": "GET", "path": "/me/usage" },
|
|
61
|
+
{ "resourceKey": "account", "methodName": "getMeBalance", "kebabMethod": "get-me-balance", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get wallet balance", "httpMethod": "GET", "path": "/me/balance" },
|
|
62
|
+
{ "resourceKey": "captain", "methodName": "sendMessage", "kebabMethod": "send-message", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Send AI Captain message", "httpMethod": "POST", "path": "/captain/messages" },
|
|
63
|
+
{ "resourceKey": "captain", "methodName": "listConversations", "kebabMethod": "list-conversations", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List AI Captain conversations", "httpMethod": "GET", "path": "/captain/conversations" },
|
|
64
|
+
{ "resourceKey": "captain", "methodName": "getConversation", "kebabMethod": "get-conversation", "pathParams": ["conversationId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get AI Captain conversation", "httpMethod": "GET", "path": "/captain/conversations/{conversation_id}" },
|
|
65
|
+
{ "resourceKey": "analytics", "methodName": "getOverview", "kebabMethod": "get-overview", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "Get analytics overview", "httpMethod": "GET", "path": "/analytics/overview" },
|
|
66
|
+
{ "resourceKey": "analytics", "methodName": "getPosts", "kebabMethod": "get-posts", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "Get post analytics", "httpMethod": "GET", "path": "/analytics/posts" },
|
|
67
|
+
{ "resourceKey": "analytics", "methodName": "getAccount", "kebabMethod": "get-account", "pathParams": ["accountId"], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "Get account analytics", "httpMethod": "GET", "path": "/analytics/accounts/{account_id}" },
|
|
68
|
+
{ "resourceKey": "articles", "methodName": "generate", "kebabMethod": "generate", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Generate article", "httpMethod": "POST", "path": "/articles/generate" },
|
|
69
|
+
{ "resourceKey": "articles", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List articles", "httpMethod": "GET", "path": "/articles" },
|
|
70
|
+
{ "resourceKey": "articles", "methodName": "get", "kebabMethod": "get", "pathParams": ["articleId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get article", "httpMethod": "GET", "path": "/articles/{article_id}" },
|
|
71
|
+
{ "resourceKey": "articles", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["articleId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete article", "httpMethod": "DELETE", "path": "/articles/{article_id}" },
|
|
72
|
+
{ "resourceKey": "audio", "methodName": "textToSpeech", "kebabMethod": "text-to-speech", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Text to speech", "httpMethod": "POST", "path": "/audio/text-to-speech" },
|
|
73
|
+
{ "resourceKey": "audio", "methodName": "speechToText", "kebabMethod": "speech-to-text", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Speech to text", "httpMethod": "POST", "path": "/audio/speech-to-text" },
|
|
74
|
+
{ "resourceKey": "audio", "methodName": "get", "kebabMethod": "get", "pathParams": ["audioId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get audio", "httpMethod": "GET", "path": "/audio/{audio_id}" },
|
|
75
|
+
{ "resourceKey": "chatbots", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List chatbots", "httpMethod": "GET", "path": "/chatbots" },
|
|
76
|
+
{ "resourceKey": "chatbots", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create chatbot", "httpMethod": "POST", "path": "/chatbots" },
|
|
77
|
+
{ "resourceKey": "chatbots", "methodName": "get", "kebabMethod": "get", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get chatbot", "httpMethod": "GET", "path": "/chatbots/{id}" },
|
|
78
|
+
{ "resourceKey": "chatbots", "methodName": "update", "kebabMethod": "update", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Update chatbot", "httpMethod": "PATCH", "path": "/chatbots/{id}" },
|
|
79
|
+
{ "resourceKey": "chatbots", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete chatbot", "httpMethod": "DELETE", "path": "/chatbots/{id}" },
|
|
80
|
+
{ "resourceKey": "chatbots", "methodName": "train", "kebabMethod": "train", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Start chatbot training", "httpMethod": "POST", "path": "/chatbots/{id}/train" },
|
|
81
|
+
{ "resourceKey": "chatbots", "methodName": "getTrainStatus", "kebabMethod": "get-train-status", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get chatbot training status", "httpMethod": "GET", "path": "/chatbots/{id}/train-status" },
|
|
82
|
+
{ "resourceKey": "chatbots", "methodName": "sendMessage", "kebabMethod": "send-message", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Send chatbot message", "httpMethod": "POST", "path": "/chatbots/{id}/messages" },
|
|
83
|
+
{ "resourceKey": "chatbots", "methodName": "listConversations", "kebabMethod": "list-conversations", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List chatbot conversations", "httpMethod": "GET", "path": "/chatbots/{id}/conversations" },
|
|
84
|
+
{ "resourceKey": "chatbots", "methodName": "getConversationMessages", "kebabMethod": "get-conversation-messages", "pathParams": ["id", "convId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get conversation messages", "httpMethod": "GET", "path": "/chatbots/{id}/conversations/{conv_id}/messages" },
|
|
85
|
+
{ "resourceKey": "comments", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List comments", "httpMethod": "GET", "path": "/social/comments" },
|
|
86
|
+
{ "resourceKey": "comments", "methodName": "replyTo", "kebabMethod": "reply-to", "pathParams": ["commentId"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Reply to a comment", "httpMethod": "POST", "path": "/social/comments/{comment_id}/reply" },
|
|
87
|
+
{ "resourceKey": "comments", "methodName": "hide", "kebabMethod": "hide", "pathParams": ["commentId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Hide or unhide a comment", "httpMethod": "POST", "path": "/social/comments/{comment_id}/hide" },
|
|
88
|
+
{ "resourceKey": "comments", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["commentId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete a comment", "httpMethod": "DELETE", "path": "/social/comments/{comment_id}" },
|
|
89
|
+
{ "resourceKey": "content", "methodName": "rewrite", "kebabMethod": "rewrite", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Rewrite content", "httpMethod": "POST", "path": "/content/rewrite" },
|
|
90
|
+
{ "resourceKey": "content", "methodName": "generateCaption", "kebabMethod": "generate-caption", "pathParams": [], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Generate a social caption", "httpMethod": "POST", "path": "/content/caption" },
|
|
91
|
+
{ "resourceKey": "contacts", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List contacts", "httpMethod": "GET", "path": "/contacts" },
|
|
92
|
+
{ "resourceKey": "contacts", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create or upsert a contact", "httpMethod": "POST", "path": "/contacts" },
|
|
93
|
+
{ "resourceKey": "contacts", "methodName": "get", "kebabMethod": "get", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get a contact", "httpMethod": "GET", "path": "/contacts/{id}" },
|
|
94
|
+
{ "resourceKey": "contacts", "methodName": "update", "kebabMethod": "update", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Update a contact", "httpMethod": "PATCH", "path": "/contacts/{id}" },
|
|
95
|
+
{ "resourceKey": "contacts", "methodName": "addTags", "kebabMethod": "add-tags", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Add tags to a contact", "httpMethod": "POST", "path": "/contacts/{id}/tags" },
|
|
96
|
+
{ "resourceKey": "contacts", "methodName": "removeTags", "kebabMethod": "remove-tags", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Remove tags from a contact", "httpMethod": "DELETE", "path": "/contacts/{id}/tags" },
|
|
97
|
+
{ "resourceKey": "contacts", "methodName": "listNotes", "kebabMethod": "list-notes", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List contact notes", "httpMethod": "GET", "path": "/contacts/{id}/notes" },
|
|
98
|
+
{ "resourceKey": "contacts", "methodName": "addNote", "kebabMethod": "add-note", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Add a note to a contact", "httpMethod": "POST", "path": "/contacts/{id}/notes" },
|
|
99
|
+
{ "resourceKey": "contacts", "methodName": "enroll", "kebabMethod": "enroll", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Enroll a contact in an automation", "httpMethod": "POST", "path": "/contacts/{id}/enroll" },
|
|
100
|
+
{ "resourceKey": "contacts", "methodName": "addMessage", "kebabMethod": "add-message", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Log a message on a contact's timeline", "httpMethod": "POST", "path": "/contacts/{id}/messages" },
|
|
101
|
+
{ "resourceKey": "customFields", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List custom fields", "httpMethod": "GET", "path": "/custom-fields" },
|
|
102
|
+
{ "resourceKey": "customFields", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create a custom field", "httpMethod": "POST", "path": "/custom-fields" },
|
|
103
|
+
{ "resourceKey": "customFields", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete a custom field", "httpMethod": "DELETE", "path": "/custom-fields/{id}" },
|
|
104
|
+
{ "resourceKey": "opportunities", "methodName": "listPipelines", "kebabMethod": "list-pipelines", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List pipelines", "httpMethod": "GET", "path": "/pipelines" },
|
|
105
|
+
{ "resourceKey": "opportunities", "methodName": "createPipeline", "kebabMethod": "create-pipeline", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create a pipeline", "httpMethod": "POST", "path": "/pipelines" },
|
|
106
|
+
{ "resourceKey": "opportunities", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List opportunities", "httpMethod": "GET", "path": "/opportunities" },
|
|
107
|
+
{ "resourceKey": "opportunities", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create an opportunity", "httpMethod": "POST", "path": "/opportunities" },
|
|
108
|
+
{ "resourceKey": "opportunities", "methodName": "get", "kebabMethod": "get", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get an opportunity", "httpMethod": "GET", "path": "/opportunities/{id}" },
|
|
109
|
+
{ "resourceKey": "opportunities", "methodName": "update", "kebabMethod": "update", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Update an opportunity", "httpMethod": "PATCH", "path": "/opportunities/{id}" },
|
|
110
|
+
{ "resourceKey": "opportunities", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete an opportunity", "httpMethod": "DELETE", "path": "/opportunities/{id}" },
|
|
111
|
+
{ "resourceKey": "opportunities", "methodName": "updateStatus", "kebabMethod": "update-status", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Update opportunity status", "httpMethod": "POST", "path": "/opportunities/{id}/status" },
|
|
112
|
+
{ "resourceKey": "messages", "methodName": "listConversations", "kebabMethod": "list-conversations", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List DM conversations", "httpMethod": "GET", "path": "/social/conversations" },
|
|
113
|
+
{ "resourceKey": "messages", "methodName": "list", "kebabMethod": "list", "pathParams": ["conversationId"], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List messages in a conversation", "httpMethod": "GET", "path": "/social/conversations/{conversation_id}/messages" },
|
|
114
|
+
{ "resourceKey": "messages", "methodName": "send", "kebabMethod": "send", "pathParams": ["conversationId"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Send a direct message", "httpMethod": "POST", "path": "/social/conversations/{conversation_id}/messages" },
|
|
115
|
+
{ "resourceKey": "messages", "methodName": "markConversationRead", "kebabMethod": "mark-conversation-read", "pathParams": ["conversationId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Mark a conversation read", "httpMethod": "POST", "path": "/social/conversations/{conversation_id}/read" },
|
|
116
|
+
{ "resourceKey": "images", "methodName": "generate", "kebabMethod": "generate", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Generate image", "httpMethod": "POST", "path": "/images/generate" },
|
|
117
|
+
{ "resourceKey": "images", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List images", "httpMethod": "GET", "path": "/images" },
|
|
118
|
+
{ "resourceKey": "images", "methodName": "get", "kebabMethod": "get", "pathParams": ["imageId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get image", "httpMethod": "GET", "path": "/images/{image_id}" },
|
|
119
|
+
{ "resourceKey": "images", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["imageId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete image", "httpMethod": "DELETE", "path": "/images/{image_id}" },
|
|
120
|
+
{ "resourceKey": "jobs", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List jobs", "httpMethod": "GET", "path": "/jobs" },
|
|
121
|
+
{ "resourceKey": "jobs", "methodName": "get", "kebabMethod": "get", "pathParams": ["jobId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get job", "httpMethod": "GET", "path": "/jobs/{job_id}" },
|
|
122
|
+
{ "resourceKey": "jobs", "methodName": "cancel", "kebabMethod": "cancel", "pathParams": ["jobId"], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Cancel job", "httpMethod": "POST", "path": "/jobs/{job_id}/cancel" },
|
|
123
|
+
{ "resourceKey": "media", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List media", "httpMethod": "GET", "path": "/media" },
|
|
124
|
+
{ "resourceKey": "media", "methodName": "get", "kebabMethod": "get", "pathParams": ["mediaId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get media", "httpMethod": "GET", "path": "/media/{media_id}" },
|
|
125
|
+
{ "resourceKey": "media", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["mediaId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete media", "httpMethod": "DELETE", "path": "/media/{media_id}" },
|
|
126
|
+
{ "resourceKey": "media", "methodName": "getUploadUrl", "kebabMethod": "get-upload-url", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Get presigned upload URL", "httpMethod": "POST", "path": "/media/upload-url" },
|
|
127
|
+
{ "resourceKey": "presentations", "methodName": "generate", "kebabMethod": "generate", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Generate presentation", "httpMethod": "POST", "path": "/presentations/generate" },
|
|
128
|
+
{ "resourceKey": "presentations", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List presentations", "httpMethod": "GET", "path": "/presentations" },
|
|
129
|
+
{ "resourceKey": "presentations", "methodName": "get", "kebabMethod": "get", "pathParams": ["presentationId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get presentation", "httpMethod": "GET", "path": "/presentations/{presentation_id}" },
|
|
130
|
+
{ "resourceKey": "presentations", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["presentationId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete presentation", "httpMethod": "DELETE", "path": "/presentations/{presentation_id}" },
|
|
131
|
+
{ "resourceKey": "profiles", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List profiles", "httpMethod": "GET", "path": "/profiles" },
|
|
132
|
+
{ "resourceKey": "profiles", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create a profile", "httpMethod": "POST", "path": "/profiles" },
|
|
133
|
+
{ "resourceKey": "profiles", "methodName": "get", "kebabMethod": "get", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get a profile", "httpMethod": "GET", "path": "/profiles/{id}" },
|
|
134
|
+
{ "resourceKey": "profiles", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Delete a profile", "httpMethod": "DELETE", "path": "/profiles/{id}" },
|
|
135
|
+
{ "resourceKey": "profiles", "methodName": "listAccounts", "kebabMethod": "list-accounts", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List a profile's connected accounts", "httpMethod": "GET", "path": "/profiles/{id}/accounts" },
|
|
136
|
+
{ "resourceKey": "profiles", "methodName": "pause", "kebabMethod": "pause", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Pause a profile", "httpMethod": "POST", "path": "/profiles/{id}/pause" },
|
|
137
|
+
{ "resourceKey": "profiles", "methodName": "resume", "kebabMethod": "resume", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Resume a profile", "httpMethod": "POST", "path": "/profiles/{id}/resume" },
|
|
138
|
+
{ "resourceKey": "profiles", "methodName": "createConnectLink", "kebabMethod": "create-connect-link", "pathParams": ["id"], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Create a hosted connect link", "httpMethod": "POST", "path": "/profiles/{id}/connect-link" },
|
|
139
|
+
{ "resourceKey": "profiles", "methodName": "createConnectUrl", "kebabMethod": "create-connect-url", "pathParams": ["id", "platform"], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Get a raw connect URL for one platform", "httpMethod": "POST", "path": "/profiles/{id}/connect/{platform}" },
|
|
140
|
+
{ "resourceKey": "profiles", "methodName": "getAccountBilling", "kebabMethod": "get-account-billing", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Account billing summary", "httpMethod": "GET", "path": "/me/account-billing" },
|
|
141
|
+
{ "resourceKey": "seo", "methodName": "keywordResearch", "kebabMethod": "keyword-research", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Keyword research", "httpMethod": "POST", "path": "/seo/keyword-research" },
|
|
142
|
+
{ "resourceKey": "seo", "methodName": "serp", "kebabMethod": "serp", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Live SERP lookup", "httpMethod": "POST", "path": "/seo/serp" },
|
|
143
|
+
{ "resourceKey": "seo", "methodName": "keywordDifficulty", "kebabMethod": "keyword-difficulty", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Keyword difficulty", "httpMethod": "POST", "path": "/seo/keyword-difficulty" },
|
|
144
|
+
{ "resourceKey": "seo", "methodName": "rankedKeywords", "kebabMethod": "ranked-keywords", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Ranked keywords (rank tracking)", "httpMethod": "POST", "path": "/seo/ranked-keywords" },
|
|
145
|
+
{ "resourceKey": "seo", "methodName": "domainOverview", "kebabMethod": "domain-overview", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Domain rank overview", "httpMethod": "POST", "path": "/seo/domain-overview" },
|
|
146
|
+
{ "resourceKey": "seo", "methodName": "competitors", "kebabMethod": "competitors", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Organic competitors", "httpMethod": "POST", "path": "/seo/competitors" },
|
|
147
|
+
{ "resourceKey": "seo", "methodName": "backlinksSummary", "kebabMethod": "backlinks-summary", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Backlink profile summary", "httpMethod": "POST", "path": "/seo/backlinks-summary" },
|
|
148
|
+
{ "resourceKey": "seo", "methodName": "audit", "kebabMethod": "audit", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "On-page SEO audit", "httpMethod": "POST", "path": "/seo/audit" },
|
|
149
|
+
{ "resourceKey": "seo", "methodName": "backlinkProspects", "kebabMethod": "backlink-prospects", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Backlink prospects (link gap)", "httpMethod": "POST", "path": "/seo/backlink-prospects" },
|
|
150
|
+
{ "resourceKey": "seo", "methodName": "referringDomains", "kebabMethod": "referring-domains", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Referring domains", "httpMethod": "POST", "path": "/seo/referring-domains" },
|
|
151
|
+
{ "resourceKey": "seo", "methodName": "backlinkAnchors", "kebabMethod": "backlink-anchors", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Backlink anchors", "httpMethod": "POST", "path": "/seo/backlink-anchors" },
|
|
152
|
+
{ "resourceKey": "seo", "methodName": "spamScore", "kebabMethod": "spam-score", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Backlink spam score", "httpMethod": "POST", "path": "/seo/spam-score" },
|
|
153
|
+
{ "resourceKey": "seo", "methodName": "rankHistory", "kebabMethod": "rank-history", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Historical rank overview", "httpMethod": "POST", "path": "/seo/rank-history" },
|
|
154
|
+
{ "resourceKey": "seo", "methodName": "siteAudit", "kebabMethod": "site-audit", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Deep site audit", "httpMethod": "POST", "path": "/seo/site-audit" },
|
|
155
|
+
{ "resourceKey": "seo", "methodName": "brandLookup", "kebabMethod": "brand-lookup", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "AI Visibility: brand lookup", "httpMethod": "POST", "path": "/seo/brand-lookup" },
|
|
156
|
+
{ "resourceKey": "seo", "methodName": "promptExplorer", "kebabMethod": "prompt-explorer", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "AI Visibility: prompt explorer", "httpMethod": "POST", "path": "/seo/prompt-explorer" },
|
|
157
|
+
{ "resourceKey": "seo", "methodName": "aiAudit", "kebabMethod": "ai-audit", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "AI Visibility Audit (async)", "httpMethod": "POST", "path": "/seo/ai-audit" },
|
|
158
|
+
{ "resourceKey": "shorts", "methodName": "generate", "kebabMethod": "generate", "pathParams": [], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Generate viral shorts from a long video", "httpMethod": "POST", "path": "/shorts/generate" },
|
|
159
|
+
{ "resourceKey": "shorts", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List shorts jobs", "httpMethod": "GET", "path": "/shorts" },
|
|
160
|
+
{ "resourceKey": "shorts", "methodName": "get", "kebabMethod": "get", "pathParams": ["uid"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get shorts job + clips", "httpMethod": "GET", "path": "/shorts/{uid}" },
|
|
161
|
+
{ "resourceKey": "social", "methodName": "listAccounts", "kebabMethod": "list-accounts", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List social accounts", "httpMethod": "GET", "path": "/social/accounts" },
|
|
162
|
+
{ "resourceKey": "social", "methodName": "listPosts", "kebabMethod": "list-posts", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List social posts", "httpMethod": "GET", "path": "/social/posts" },
|
|
163
|
+
{ "resourceKey": "social", "methodName": "createPost", "kebabMethod": "create-post", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create post (publish immediately)", "httpMethod": "POST", "path": "/social/posts" },
|
|
164
|
+
{ "resourceKey": "social", "methodName": "schedulePost", "kebabMethod": "schedule-post", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Schedule post", "httpMethod": "POST", "path": "/social/posts/schedule" },
|
|
165
|
+
{ "resourceKey": "social", "methodName": "getPost", "kebabMethod": "get-post", "pathParams": ["postId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get social post", "httpMethod": "GET", "path": "/social/posts/{post_id}" },
|
|
166
|
+
{ "resourceKey": "social", "methodName": "updatePost", "kebabMethod": "update-post", "pathParams": ["postId"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Update social post", "httpMethod": "PATCH", "path": "/social/posts/{post_id}" },
|
|
167
|
+
{ "resourceKey": "social", "methodName": "deletePost", "kebabMethod": "delete-post", "pathParams": ["postId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete social post", "httpMethod": "DELETE", "path": "/social/posts/{post_id}" },
|
|
168
|
+
{ "resourceKey": "social", "methodName": "disconnectAccount", "kebabMethod": "disconnect-account", "pathParams": ["accountId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Disconnect a social account", "httpMethod": "DELETE", "path": "/social/accounts/{account_id}" },
|
|
169
|
+
{ "resourceKey": "social", "methodName": "getAccountHealth", "kebabMethod": "get-account-health", "pathParams": ["accountId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Account health", "httpMethod": "GET", "path": "/social/accounts/{account_id}/health" },
|
|
170
|
+
{ "resourceKey": "social", "methodName": "getAccountReconnectUrl", "kebabMethod": "get-account-reconnect-url", "pathParams": ["accountId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Account reconnect URL", "httpMethod": "GET", "path": "/social/accounts/{account_id}/reconnect-url" },
|
|
171
|
+
{ "resourceKey": "social", "methodName": "pauseAccount", "kebabMethod": "pause-account", "pathParams": ["accountId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Pause posting to an account", "httpMethod": "POST", "path": "/social/accounts/{account_id}/pause" },
|
|
172
|
+
{ "resourceKey": "social", "methodName": "resumeAccount", "kebabMethod": "resume-account", "pathParams": ["accountId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Resume posting to an account", "httpMethod": "POST", "path": "/social/accounts/{account_id}/resume" },
|
|
173
|
+
{ "resourceKey": "social", "methodName": "retryPost", "kebabMethod": "retry-post", "pathParams": ["postId"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Retry publishing a post", "httpMethod": "POST", "path": "/social/posts/{post_id}/retry" },
|
|
174
|
+
{ "resourceKey": "social", "methodName": "connectAccountStatus", "kebabMethod": "connect-account-status", "pathParams": ["platform"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Poll headless connection status", "httpMethod": "GET", "path": "/social/connect/{platform}" },
|
|
175
|
+
{ "resourceKey": "social", "methodName": "connectAccount", "kebabMethod": "connect-account", "pathParams": ["platform"], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Start headless account connection", "httpMethod": "POST", "path": "/social/connect/{platform}" },
|
|
176
|
+
{ "resourceKey": "urls", "methodName": "shorten", "kebabMethod": "shorten", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Shorten URL", "httpMethod": "POST", "path": "/urls/shorten" },
|
|
177
|
+
{ "resourceKey": "urls", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List short URLs", "httpMethod": "GET", "path": "/urls" },
|
|
178
|
+
{ "resourceKey": "urls", "methodName": "get", "kebabMethod": "get", "pathParams": ["urlId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get short URL", "httpMethod": "GET", "path": "/urls/{url_id}" },
|
|
179
|
+
{ "resourceKey": "urls", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["urlId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete short URL", "httpMethod": "DELETE", "path": "/urls/{url_id}" },
|
|
180
|
+
{ "resourceKey": "urls", "methodName": "getStats", "kebabMethod": "get-stats", "pathParams": ["urlId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get short URL stats", "httpMethod": "GET", "path": "/urls/{url_id}/stats" },
|
|
181
|
+
{ "resourceKey": "videos", "methodName": "listModels", "kebabMethod": "list-models", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List available video models", "httpMethod": "GET", "path": "/videos/models" },
|
|
182
|
+
{ "resourceKey": "videos", "methodName": "generate", "kebabMethod": "generate", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Generate video", "httpMethod": "POST", "path": "/videos/generate" },
|
|
183
|
+
{ "resourceKey": "videos", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": true, "summary": "List videos", "httpMethod": "GET", "path": "/videos" },
|
|
184
|
+
{ "resourceKey": "videos", "methodName": "get", "kebabMethod": "get", "pathParams": ["videoId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get video", "httpMethod": "GET", "path": "/videos/{video_id}" },
|
|
185
|
+
{ "resourceKey": "videos", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["videoId"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete video", "httpMethod": "DELETE", "path": "/videos/{video_id}" },
|
|
186
|
+
{ "resourceKey": "videos", "methodName": "generateHook", "kebabMethod": "generate-hook", "pathParams": [], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Generate a viral hook line", "httpMethod": "POST", "path": "/videos/hook" },
|
|
187
|
+
{ "resourceKey": "videos", "methodName": "suggestBroll", "kebabMethod": "suggest-broll", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Suggest B-roll moments", "httpMethod": "POST", "path": "/videos/broll-suggest" },
|
|
188
|
+
{ "resourceKey": "videos", "methodName": "suggestEmphasis", "kebabMethod": "suggest-emphasis", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Suggest on-screen emphasis", "httpMethod": "POST", "path": "/videos/emphasis" },
|
|
189
|
+
{ "resourceKey": "videos", "methodName": "generateViralThumbnail", "kebabMethod": "generate-viral-thumbnail", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Generate a viral thumbnail", "httpMethod": "POST", "path": "/videos/viral-thumbnail" },
|
|
190
|
+
{ "resourceKey": "webhooks", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List webhooks", "httpMethod": "GET", "path": "/webhooks" },
|
|
191
|
+
{ "resourceKey": "webhooks", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create webhook", "httpMethod": "POST", "path": "/webhooks" },
|
|
192
|
+
{ "resourceKey": "webhooks", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Delete webhook", "httpMethod": "DELETE", "path": "/webhooks/{id}" },
|
|
193
|
+
{ "resourceKey": "workspaces", "methodName": "list", "kebabMethod": "list", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List workspaces (sub-accounts)", "httpMethod": "GET", "path": "/workspaces" },
|
|
194
|
+
{ "resourceKey": "workspaces", "methodName": "create", "kebabMethod": "create", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Create a workspace (sub-account)", "httpMethod": "POST", "path": "/workspaces" },
|
|
195
|
+
{ "resourceKey": "workspaces", "methodName": "bulkAction", "kebabMethod": "bulk-action", "pathParams": [], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Bulk sub-account action", "httpMethod": "POST", "path": "/workspaces/bulk" },
|
|
196
|
+
{ "resourceKey": "workspaces", "methodName": "get", "kebabMethod": "get", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get a workspace (sub-account)", "httpMethod": "GET", "path": "/workspaces/{id}" },
|
|
197
|
+
{ "resourceKey": "workspaces", "methodName": "delete", "kebabMethod": "delete", "pathParams": ["id"], "hasBody": true, "bodyRequired": true, "hasQuery": false, "summary": "Delete a workspace (sub-account)", "httpMethod": "DELETE", "path": "/workspaces/{id}" },
|
|
198
|
+
{ "resourceKey": "workspaces", "methodName": "disableSaas", "kebabMethod": "disable-saas", "pathParams": ["id"], "hasBody": true, "bodyRequired": false, "hasQuery": false, "summary": "Disable SaaS mode for a workspace", "httpMethod": "POST", "path": "/workspaces/{id}/disable-saas" },
|
|
199
|
+
{ "resourceKey": "workspaces", "methodName": "pause", "kebabMethod": "pause", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Pause (suspend) a workspace", "httpMethod": "POST", "path": "/workspaces/{id}/pause" },
|
|
200
|
+
{ "resourceKey": "workspaces", "methodName": "resume", "kebabMethod": "resume", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Resume a paused workspace", "httpMethod": "POST", "path": "/workspaces/{id}/resume" },
|
|
201
|
+
{ "resourceKey": "workspaces", "methodName": "getSubscription", "kebabMethod": "get-subscription", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get a sub-account's subscription", "httpMethod": "GET", "path": "/workspaces/{id}/subscription" },
|
|
202
|
+
{ "resourceKey": "workspaces", "methodName": "getWallet", "kebabMethod": "get-wallet", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get a sub-account's wallet balance", "httpMethod": "GET", "path": "/workspaces/{id}/wallet" },
|
|
203
|
+
{ "resourceKey": "workspaces", "methodName": "listSaasPlans", "kebabMethod": "list-saas-plans", "pathParams": [], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "List SaaS plans", "httpMethod": "GET", "path": "/saas/plans" },
|
|
204
|
+
{ "resourceKey": "workspaces", "methodName": "getSaasPlan", "kebabMethod": "get-saas-plan", "pathParams": ["id"], "hasBody": false, "bodyRequired": false, "hasQuery": false, "summary": "Get a SaaS plan", "httpMethod": "GET", "path": "/saas/plans/{id}" }
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
// src/config.ts
|
|
208
|
+
var import_node_fs = require("fs");
|
|
209
|
+
var import_node_os = require("os");
|
|
210
|
+
var import_node_path = require("path");
|
|
211
|
+
function configDir() {
|
|
212
|
+
return process.env.SMARTLYQ_CONFIG_DIR ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".smartlyq");
|
|
213
|
+
}
|
|
214
|
+
function configPath() {
|
|
215
|
+
return (0, import_node_path.join)(configDir(), "config.json");
|
|
216
|
+
}
|
|
217
|
+
function readConfig() {
|
|
218
|
+
try {
|
|
219
|
+
return JSON.parse((0, import_node_fs.readFileSync)(configPath(), "utf8"));
|
|
220
|
+
} catch {
|
|
221
|
+
return {};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function readStoredApiKey() {
|
|
225
|
+
const key = readConfig().apiKey;
|
|
226
|
+
return typeof key === "string" && key.length > 0 ? key : void 0;
|
|
227
|
+
}
|
|
228
|
+
function storeApiKey(apiKey) {
|
|
229
|
+
const dir = configDir();
|
|
230
|
+
(0, import_node_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
231
|
+
const path = configPath();
|
|
232
|
+
(0, import_node_fs.writeFileSync)(path, `${JSON.stringify({ ...readConfig(), apiKey }, null, 2)}
|
|
233
|
+
`, { mode: 384 });
|
|
234
|
+
(0, import_node_fs.chmodSync)(path, 384);
|
|
235
|
+
return path;
|
|
236
|
+
}
|
|
237
|
+
function deleteStoredApiKey() {
|
|
238
|
+
const path = configPath();
|
|
239
|
+
if (!(0, import_node_fs.existsSync)(path)) return false;
|
|
240
|
+
(0, import_node_fs.unlinkSync)(path);
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
function resolveApiKey(flagValue) {
|
|
244
|
+
if (flagValue) return flagValue;
|
|
245
|
+
const env = process.env.SMARTLYQ_API_KEY;
|
|
246
|
+
if (env) return env;
|
|
247
|
+
return readStoredApiKey();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/io.ts
|
|
251
|
+
var import_node_fs2 = require("fs");
|
|
252
|
+
var import_node = require("@smartlyqofficial/node");
|
|
253
|
+
|
|
254
|
+
// src/util.ts
|
|
255
|
+
function kebabCase(name) {
|
|
256
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
257
|
+
}
|
|
258
|
+
var CliError = class extends Error {
|
|
259
|
+
constructor(message) {
|
|
260
|
+
super(message);
|
|
261
|
+
this.name = "CliError";
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/io.ts
|
|
266
|
+
function defaultReadStdin() {
|
|
267
|
+
return (0, import_node_fs2.readFileSync)(0, "utf8");
|
|
268
|
+
}
|
|
269
|
+
function parseData(raw, readStdin = defaultReadStdin) {
|
|
270
|
+
let text = raw;
|
|
271
|
+
if (raw === "-") {
|
|
272
|
+
text = readStdin();
|
|
273
|
+
} else if (raw.startsWith("@")) {
|
|
274
|
+
const file = raw.slice(1);
|
|
275
|
+
try {
|
|
276
|
+
text = (0, import_node_fs2.readFileSync)(file, "utf8");
|
|
277
|
+
} catch (err) {
|
|
278
|
+
throw new CliError(`Could not read --data file "${file}": ${err.message}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
return JSON.parse(text);
|
|
283
|
+
} catch (err) {
|
|
284
|
+
throw new CliError(`Invalid JSON in --data: ${err.message}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function parseQuery(raw) {
|
|
288
|
+
const trimmed = raw.trim();
|
|
289
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
290
|
+
let parsed;
|
|
291
|
+
try {
|
|
292
|
+
parsed = JSON.parse(trimmed);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
throw new CliError(`Invalid JSON in --query: ${err.message}`);
|
|
295
|
+
}
|
|
296
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
297
|
+
throw new CliError(`--query JSON must be an object, e.g. '{"status":"draft"}'.`);
|
|
298
|
+
}
|
|
299
|
+
return parsed;
|
|
300
|
+
}
|
|
301
|
+
const out = {};
|
|
302
|
+
for (const [key, value] of new URLSearchParams(trimmed)) {
|
|
303
|
+
const existing = out[key];
|
|
304
|
+
if (existing === void 0) {
|
|
305
|
+
out[key] = value;
|
|
306
|
+
} else if (Array.isArray(existing)) {
|
|
307
|
+
existing.push(value);
|
|
308
|
+
} else {
|
|
309
|
+
out[key] = [existing, value];
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return out;
|
|
313
|
+
}
|
|
314
|
+
function formatOutput(result, mode = "pretty") {
|
|
315
|
+
if (result === void 0) return "";
|
|
316
|
+
return mode === "json" ? JSON.stringify(result) : JSON.stringify(result, null, 2);
|
|
317
|
+
}
|
|
318
|
+
function formatError(err) {
|
|
319
|
+
if (err instanceof CliError) return err.message;
|
|
320
|
+
if (err instanceof import_node.SmartlyQError) {
|
|
321
|
+
const code = err.code ?? "UNKNOWN";
|
|
322
|
+
const request = err.requestId ? ` (request ${err.requestId})` : "";
|
|
323
|
+
return `Error ${err.status} ${code}: ${err.message}${request}`;
|
|
324
|
+
}
|
|
325
|
+
return err instanceof Error ? err.message : String(err);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// src/login.ts
|
|
329
|
+
var import_node_readline = require("readline");
|
|
330
|
+
var import_node_stream = require("stream");
|
|
331
|
+
function promptHidden(prompt) {
|
|
332
|
+
return new Promise((resolve, reject) => {
|
|
333
|
+
process.stdout.write(prompt);
|
|
334
|
+
const muted = new import_node_stream.Writable({
|
|
335
|
+
write(_chunk, _encoding, callback) {
|
|
336
|
+
callback();
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
const rl = (0, import_node_readline.createInterface)({ input: process.stdin, output: muted, terminal: true });
|
|
340
|
+
rl.question("", (answer) => {
|
|
341
|
+
rl.close();
|
|
342
|
+
process.stdout.write("\n");
|
|
343
|
+
resolve(answer.trim());
|
|
344
|
+
});
|
|
345
|
+
rl.on("error", reject);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
async function runLogin() {
|
|
349
|
+
const key = await promptHidden("SmartlyQ API key (input hidden): ");
|
|
350
|
+
if (!key) {
|
|
351
|
+
throw new CliError("No API key entered. Get one from your Developer Dashboard at https://app.smartlyq.com.");
|
|
352
|
+
}
|
|
353
|
+
if (!/^sqk_(live|test)_/.test(key)) {
|
|
354
|
+
process.stderr.write("Warning: the key does not look like a SmartlyQ API key (sqk_live_... / sqk_test_...). Storing it anyway.\n");
|
|
355
|
+
}
|
|
356
|
+
const path = storeApiKey(key);
|
|
357
|
+
process.stdout.write(`API key saved to ${path}
|
|
358
|
+
`);
|
|
359
|
+
}
|
|
360
|
+
function runLogout() {
|
|
361
|
+
const removed = deleteStoredApiKey();
|
|
362
|
+
process.stdout.write(
|
|
363
|
+
removed ? `Logged out. Deleted ${configPath()}
|
|
364
|
+
` : "No stored API key found. Nothing to do.\n"
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// package.json
|
|
369
|
+
var package_default = {
|
|
370
|
+
name: "@smartlyqofficial/cli",
|
|
371
|
+
version: "0.1.0",
|
|
372
|
+
description: "Official command line for the SmartlyQ API - social posting, AI content generation, SEO, CRM, and more.",
|
|
373
|
+
keywords: [
|
|
374
|
+
"smartlyq",
|
|
375
|
+
"cli",
|
|
376
|
+
"social-media",
|
|
377
|
+
"api",
|
|
378
|
+
"ai",
|
|
379
|
+
"content-generation",
|
|
380
|
+
"social-posting",
|
|
381
|
+
"seo"
|
|
382
|
+
],
|
|
383
|
+
homepage: "https://docs.smartlyq.com",
|
|
384
|
+
repository: {
|
|
385
|
+
type: "git",
|
|
386
|
+
url: "git+https://github.com/SmartlyQ/smartlyq-cli.git"
|
|
387
|
+
},
|
|
388
|
+
license: "MIT",
|
|
389
|
+
type: "module",
|
|
390
|
+
main: "./dist/index.cjs",
|
|
391
|
+
module: "./dist/index.js",
|
|
392
|
+
types: "./dist/index.d.ts",
|
|
393
|
+
exports: {
|
|
394
|
+
".": {
|
|
395
|
+
types: "./dist/index.d.ts",
|
|
396
|
+
import: "./dist/index.js",
|
|
397
|
+
require: "./dist/index.cjs"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
bin: {
|
|
401
|
+
smartlyq: "./dist/cli.js"
|
|
402
|
+
},
|
|
403
|
+
files: [
|
|
404
|
+
"dist",
|
|
405
|
+
"README.md",
|
|
406
|
+
"LICENSE"
|
|
407
|
+
],
|
|
408
|
+
scripts: {
|
|
409
|
+
"fetch-spec": "curl -f --retry 5 --retry-delay 2 --retry-all-errors --max-time 60 -o openapi.json https://docs.smartlyq.com/openapi.json",
|
|
410
|
+
generate: "tsx scripts/generate-commands.ts",
|
|
411
|
+
"generate:readme": "tsx scripts/generate-readme.ts",
|
|
412
|
+
"generate:tests": "tsx scripts/generate-tests.ts",
|
|
413
|
+
build: "tsup",
|
|
414
|
+
typecheck: "tsc --noEmit",
|
|
415
|
+
pretest: "npm run build",
|
|
416
|
+
test: "vitest run",
|
|
417
|
+
"test:watch": "vitest",
|
|
418
|
+
prepublishOnly: "npm run build"
|
|
419
|
+
},
|
|
420
|
+
dependencies: {
|
|
421
|
+
"@smartlyqofficial/node": "^0.1.2",
|
|
422
|
+
commander: "^12.1.0"
|
|
423
|
+
},
|
|
424
|
+
devDependencies: {
|
|
425
|
+
"@types/node": "^22.0.0",
|
|
426
|
+
tsup: "^8.0.0",
|
|
427
|
+
tsx: "^4.19.0",
|
|
428
|
+
typescript: "^5.6.0",
|
|
429
|
+
vitest: "^3.0.0"
|
|
430
|
+
},
|
|
431
|
+
engines: {
|
|
432
|
+
node: ">=18"
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// src/index.ts
|
|
437
|
+
var MISSING_KEY_MESSAGE = "No API key found. Run `smartlyq login` to store one, or set the SMARTLYQ_API_KEY environment variable, or pass --api-key.";
|
|
438
|
+
async function dispatch(desc, pathArgs, flags = {}, overrides = {}) {
|
|
439
|
+
const apiKey = resolveApiKey(flags.apiKey) ?? overrides.apiKey;
|
|
440
|
+
if (!apiKey) throw new CliError(MISSING_KEY_MESSAGE);
|
|
441
|
+
const clientOptions = { apiKey };
|
|
442
|
+
if (flags.baseUrl) clientOptions.baseUrl = flags.baseUrl;
|
|
443
|
+
if (flags.timeout !== void 0) {
|
|
444
|
+
const timeout = Number(flags.timeout);
|
|
445
|
+
if (!Number.isFinite(timeout) || timeout <= 0) {
|
|
446
|
+
throw new CliError("--timeout must be a positive number of milliseconds.");
|
|
447
|
+
}
|
|
448
|
+
clientOptions.timeout = timeout;
|
|
449
|
+
}
|
|
450
|
+
Object.assign(clientOptions, overrides, { apiKey });
|
|
451
|
+
const sq = new import_node2.default(clientOptions);
|
|
452
|
+
const callArgs = [...pathArgs];
|
|
453
|
+
if (desc.hasBody) {
|
|
454
|
+
const body = flags.data !== void 0 ? parseData(flags.data) : void 0;
|
|
455
|
+
if (body === void 0 && desc.bodyRequired) {
|
|
456
|
+
throw new CliError(
|
|
457
|
+
"This command requires a request body. Pass --data '<json>' (or --data @file.json, or --data - to read stdin)."
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
callArgs.push(body);
|
|
461
|
+
}
|
|
462
|
+
if (desc.hasQuery) {
|
|
463
|
+
callArgs.push(flags.query !== void 0 ? parseQuery(flags.query) : void 0);
|
|
464
|
+
}
|
|
465
|
+
const options = {};
|
|
466
|
+
if (flags.profile) options.profileId = flags.profile;
|
|
467
|
+
if (flags.idempotencyKey) options.idempotencyKey = flags.idempotencyKey;
|
|
468
|
+
callArgs.push(Object.keys(options).length > 0 ? options : void 0);
|
|
469
|
+
const resource = sq[desc.resourceKey];
|
|
470
|
+
return resource[desc.methodName](...callArgs);
|
|
471
|
+
}
|
|
472
|
+
function fail(err) {
|
|
473
|
+
process.stderr.write(`${formatError(err)}
|
|
474
|
+
`);
|
|
475
|
+
process.exitCode = 1;
|
|
476
|
+
}
|
|
477
|
+
function attachMethodCommand(resourceCmd, desc) {
|
|
478
|
+
const cmd = resourceCmd.command(desc.kebabMethod).description(`${desc.summary} (${desc.httpMethod} ${desc.path})`);
|
|
479
|
+
for (const param of desc.pathParams) {
|
|
480
|
+
cmd.argument(`<${kebabCase(param)}>`, `path parameter for ${desc.path}`);
|
|
481
|
+
}
|
|
482
|
+
if (desc.hasBody) {
|
|
483
|
+
cmd.option(
|
|
484
|
+
"--data <json>",
|
|
485
|
+
`request body as JSON${desc.bodyRequired ? "" : " (optional)"}; @file.json reads a file, - reads stdin`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
if (desc.hasQuery) {
|
|
489
|
+
cmd.option("--query <query>", "query parameters as k=v&k2=v2 pairs or a JSON object");
|
|
490
|
+
}
|
|
491
|
+
cmd.option("--profile <id>", "act on behalf of a managed Profile (X-Profile-Id header)").option("--idempotency-key <key>", "idempotency key for safely retrying writes").option("--api-key <key>", "API key (defaults to SMARTLYQ_API_KEY, then `smartlyq login`)").option("--base-url <url>", "API base URL (default https://api.smartlyq.com/v1)").option("--output <mode>", "output format: pretty (indented JSON, default) or json (compact)", "pretty").option("--timeout <ms>", "request timeout in milliseconds").addHelpText(
|
|
492
|
+
"after",
|
|
493
|
+
[
|
|
494
|
+
"",
|
|
495
|
+
`Endpoint: ${desc.httpMethod} ${desc.path}`,
|
|
496
|
+
...desc.pathParams.length > 0 ? [`Path arguments: ${desc.pathParams.map((p) => `<${kebabCase(p)}>`).join(" ")}`] : []
|
|
497
|
+
].join("\n")
|
|
498
|
+
).action(async (...actionArgs) => {
|
|
499
|
+
const flags = actionArgs[actionArgs.length - 2];
|
|
500
|
+
if (flags.output !== void 0 && flags.output !== "json" && flags.output !== "pretty") {
|
|
501
|
+
fail(new CliError('--output must be "json" or "pretty".'));
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const pathArgs = actionArgs.slice(0, desc.pathParams.length);
|
|
505
|
+
try {
|
|
506
|
+
const result = await dispatch(desc, pathArgs, flags);
|
|
507
|
+
const rendered = formatOutput(result, flags.output);
|
|
508
|
+
if (rendered) process.stdout.write(`${rendered}
|
|
509
|
+
`);
|
|
510
|
+
} catch (err) {
|
|
511
|
+
fail(err);
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function buildProgram() {
|
|
516
|
+
const program = new import_commander.Command("smartlyq");
|
|
517
|
+
program.description(
|
|
518
|
+
"SmartlyQ API command line - social posting, AI content generation (articles, images, video, audio, presentations), SEO research, CRM, and more."
|
|
519
|
+
).version(package_default.version).configureHelp({ sortSubcommands: true });
|
|
520
|
+
program.command("login").description("Prompt for your API key and store it in ~/.smartlyq/config.json").action(async () => {
|
|
521
|
+
try {
|
|
522
|
+
await runLogin();
|
|
523
|
+
} catch (err) {
|
|
524
|
+
fail(err);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
program.command("logout").description("Delete the stored API key").action(() => {
|
|
528
|
+
try {
|
|
529
|
+
runLogout();
|
|
530
|
+
} catch (err) {
|
|
531
|
+
fail(err);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
const byResource = /* @__PURE__ */ new Map();
|
|
535
|
+
for (const desc of commands) {
|
|
536
|
+
if (!byResource.has(desc.resourceKey)) byResource.set(desc.resourceKey, []);
|
|
537
|
+
byResource.get(desc.resourceKey).push(desc);
|
|
538
|
+
}
|
|
539
|
+
for (const [resourceKey, descs] of byResource) {
|
|
540
|
+
const resourceCmd = program.command(kebabCase(resourceKey)).description(`${descs.length} ${resourceKey} command${descs.length === 1 ? "" : "s"}`);
|
|
541
|
+
for (const desc of descs) attachMethodCommand(resourceCmd, desc);
|
|
542
|
+
}
|
|
543
|
+
return program;
|
|
544
|
+
}
|
|
545
|
+
async function main(argv = process.argv) {
|
|
546
|
+
const program = buildProgram();
|
|
547
|
+
await program.parseAsync(argv);
|
|
548
|
+
}
|
|
549
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
550
|
+
0 && (module.exports = {
|
|
551
|
+
CliError,
|
|
552
|
+
buildProgram,
|
|
553
|
+
commands,
|
|
554
|
+
configDir,
|
|
555
|
+
configPath,
|
|
556
|
+
deleteStoredApiKey,
|
|
557
|
+
dispatch,
|
|
558
|
+
formatError,
|
|
559
|
+
formatOutput,
|
|
560
|
+
kebabCase,
|
|
561
|
+
main,
|
|
562
|
+
parseData,
|
|
563
|
+
parseQuery,
|
|
564
|
+
promptHidden,
|
|
565
|
+
readStoredApiKey,
|
|
566
|
+
resolveApiKey,
|
|
567
|
+
runLogin,
|
|
568
|
+
runLogout,
|
|
569
|
+
storeApiKey
|
|
570
|
+
});
|