@publishq/cli 0.0.3 → 0.0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 PublishQ
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ <p align="center">
2
+ <img src="https://publishq.com/favicon.svg" width="80" alt="PublishQ logo" />
3
+ </p>
4
+
5
+ <h1 align="center">@publishq/cli</h1>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@publishq/cli"><img src="https://img.shields.io/npm/v/@publishq/cli.svg" alt="npm version"></a>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <strong>Schedule and publish across your social platforms from your terminal. Built for humans and AI agents.</strong>
13
+ </p>
14
+
15
+ The official CLI for [PublishQ](https://publishq.com). It wraps the [PublishQ API](https://publishq.com/docs) so you and your AI agents can manage posts, accounts, workspaces, and media without leaving the shell.
16
+
17
+ Output is JSON by default: easy to pipe into `jq` and easy for an AI agent to parse. Pass `--pretty` when you want to read it yourself.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install -g @publishq/cli
23
+ ```
24
+
25
+ You get two commands: `publishq` and the shorter `pq`. They do the same thing.
26
+
27
+ ## Quick start
28
+
29
+ ```bash
30
+ # 1. Save your API key (create one under Settings → API Keys in the web app)
31
+ pq auth set --key "pq_live_..."
32
+
33
+ # 2. See your connected accounts
34
+ pq accounts list --pretty
35
+
36
+ # 3. Schedule a post
37
+ pq posts create --content "Hello 👋" --account <account-id> --scheduled-at 2026-01-01T09:00:00Z
38
+ ```
39
+
40
+ Running in CI or wiring this into an agent? Skip step 1 and set `PUBLISHQ_API_KEY` in the environment instead. The CLI reads it directly, so there's no config file to write or clean up. Set `PUBLISHQ_API_URL` to point at a staging/local server.
41
+
42
+ ## Posts
43
+
44
+ ```bash
45
+ pq posts # list (default command)
46
+ pq posts list --page 1 --limit 20
47
+ pq posts get <post-id>
48
+ pq posts create --content "Hello" --account <id> [--account <id2>] \
49
+ [--media-id <id>] [--thumbnail-timestamp <ms>] [--scheduled-at <iso>] [--publish-now]
50
+ pq posts create --content "Hello TikTok" --accounts-json '[{"accountId":"<id>","postOverrides":{"content":"TikTok caption"},"platformSpecificSettings":{"privacyLevel":"PUBLIC_TO_EVERYONE","disableComment":false,"disableDuet":false,"disableStitch":false,"brandContentToggle":false,"brandOrganicToggle":false}}]' --publish-now
51
+ pq posts update <post-id> [--content "New text"] [--scheduled-at <iso>] \
52
+ [--media-id <id>] [--thumbnail-timestamp <ms>]
53
+ pq posts update <post-id> --media-ids-json '[]' # remove all media
54
+ pq posts delete <post-id>
55
+ pq posts remove-account <post-id> <account-id>
56
+ ```
57
+
58
+ A post with neither `--scheduled-at` nor `--publish-now` is saved as a **draft**. Repeat `--account` (and `--media-id`) to target multiple simple accounts or attach multiple media files. Use `--accounts-json` instead of `--account` when an account needs `postOverrides` or `platformSpecificSettings`; the two account input modes cannot be combined. For TikTok, first run `pq accounts tiktok-creator-info <account-id>`, then include the required TikTok settings shown above with a supported `privacyLevel`.
59
+
60
+ ## Accounts
61
+
62
+ ```bash
63
+ pq accounts list
64
+ pq accounts list --platform TIKTOK --platform BLUESKY # OR filter
65
+ pq accounts list --workspace-id <workspace-id>
66
+ pq accounts tiktok-creator-info <account-id> # call before posting to TikTok
67
+ ```
68
+
69
+ ## Workspaces
70
+
71
+ ```bash
72
+ pq workspaces list
73
+ pq workspaces get <workspace-id>
74
+ pq workspaces create --name "Client A" [--description "..."] [--color "#6366f1"]
75
+ ```
76
+
77
+ ## Media
78
+
79
+ ```bash
80
+ pq media list [--page 1] [--limit 20] [--id <media-id>] \
81
+ [--media-type IMAGE] [--source UPLOAD]
82
+ pq media get <media-id>
83
+ pq media upload --file ./photo.jpg [--filename custom.jpg]
84
+ ```
85
+
86
+ Upload returns a media object whose `id` you can pass to `pq posts create --media-id <id>`.
87
+
88
+ ## Scopes
89
+
90
+ API keys carry scopes that control access. A call missing the required scope returns `403`.
91
+
92
+ | Scope | Allows |
93
+ | ------------------ | -------------------------------------------------------- |
94
+ | `posts:read` | `posts list`, `posts get` |
95
+ | `posts:write` | `posts create`, `posts update`, `posts delete`, `posts remove-account` |
96
+ | `accounts:read` | `accounts list`, `accounts tiktok-creator-info` |
97
+ | `workspaces:read` | `workspaces list`, `workspaces get` |
98
+ | `workspaces:write` | `workspaces create` |
99
+ | `media:read` | `media list`, `media get` |
100
+ | `media:write` | `media upload` |
101
+
102
+ ## Related
103
+
104
+ - [`@publishq/sdk`](https://www.npmjs.com/package/@publishq/sdk) — the TypeScript SDK this CLI is built on.
105
+ - [`@publishq/mcp`](https://www.npmjs.com/package/@publishq/mcp) — Model Context Protocol server for Claude Desktop and other AI agents.
106
+
107
+ ## License
108
+
109
+ [Apache-2.0](./LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,373 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { readFileSync as readFileSync2 } from "fs";
5
+ import { basename } from "path";
6
+ import yargs from "yargs";
7
+ import { hideBin } from "yargs/helpers";
8
+
9
+ // src/config.ts
10
+ import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "fs";
11
+ import { homedir } from "os";
12
+ import { dirname, join } from "path";
13
+ import PublishQ from "@publishq/sdk";
14
+ var CONFIG_PATH = join(homedir(), ".publishq", "config.json");
15
+ function readConfig() {
16
+ try {
17
+ return JSON.parse(readFileSync(CONFIG_PATH, "utf8"));
18
+ } catch {
19
+ return {};
20
+ }
21
+ }
22
+ function saveApiKey(apiKey, baseUrl) {
23
+ const config = { ...readConfig(), apiKey, ...baseUrl ? { baseUrl } : {} };
24
+ mkdirSync(dirname(CONFIG_PATH), { recursive: true });
25
+ writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
26
+ chmodSync(CONFIG_PATH, 384);
27
+ return CONFIG_PATH;
28
+ }
29
+ function getApiKey() {
30
+ return process.env.PUBLISHQ_API_KEY ?? readConfig().apiKey;
31
+ }
32
+ function getClient() {
33
+ const apiKey = getApiKey();
34
+ if (!apiKey) {
35
+ console.error(
36
+ 'No API key found. Generate one at https://publishq.com/app/settings, then run `publishq auth set --key "pq_live_..."` or set PUBLISHQ_API_KEY.'
37
+ );
38
+ process.exit(1);
39
+ }
40
+ const baseUrl = process.env.PUBLISHQ_API_URL ?? readConfig().baseUrl;
41
+ return new PublishQ({ apiKey, ...baseUrl ? { baseUrl } : {} });
42
+ }
43
+
44
+ // src/output.ts
45
+ async function output(call, pretty) {
46
+ const { data, error, response } = await call;
47
+ if (error !== void 0 || response && !response.ok) {
48
+ let payload2;
49
+ if (error instanceof Error) {
50
+ payload2 = { error: describeError(error) };
51
+ } else if (error !== void 0) {
52
+ payload2 = error;
53
+ } else {
54
+ const status = response ? `${response.status} ${response.statusText}` : "Request failed";
55
+ payload2 = { error: `API request failed (${status.trim()})` };
56
+ }
57
+ console.error(JSON.stringify(payload2, null, pretty ? 2 : void 0));
58
+ process.exit(1);
59
+ }
60
+ const payload = response?.status === 204 ? { success: true } : data ?? {};
61
+ console.log(JSON.stringify(payload, null, pretty ? 2 : void 0));
62
+ }
63
+ function describeError(error) {
64
+ const cause = error.cause;
65
+ if (cause instanceof Error) {
66
+ const code = cause.code;
67
+ return code ? `${cause.message} (${code})` : cause.message;
68
+ }
69
+ return error.message;
70
+ }
71
+
72
+ // src/index.ts
73
+ function parseJsonOption(option, value) {
74
+ try {
75
+ return JSON.parse(value);
76
+ } catch (error) {
77
+ throw new Error(
78
+ `${option} must be valid JSON: ${error instanceof Error ? error.message : String(error)}`
79
+ );
80
+ }
81
+ }
82
+ yargs(hideBin(process.argv)).scriptName("publishq").usage("$0 <command> [options]").option("pretty", {
83
+ type: "boolean",
84
+ default: false,
85
+ describe: "Pretty-print JSON output"
86
+ }).command(
87
+ "auth",
88
+ "Manage authentication",
89
+ (y) => y.command(
90
+ "set",
91
+ "Save your API key locally (~/.publishq/config.json)",
92
+ (yy) => yy.option("key", {
93
+ type: "string",
94
+ demandOption: true,
95
+ describe: "Your PublishQ API key (pq_live_...)"
96
+ }).option("url", {
97
+ type: "string",
98
+ describe: "Override the API base URL (staging/local)"
99
+ }),
100
+ (argv) => {
101
+ const path = saveApiKey(argv.key, argv.url);
102
+ console.log(
103
+ JSON.stringify(
104
+ { success: true, configPath: path },
105
+ null,
106
+ argv.pretty ? 2 : void 0
107
+ )
108
+ );
109
+ }
110
+ ).demandCommand(1, "Specify an auth subcommand (set)."),
111
+ () => {
112
+ }
113
+ ).command(
114
+ "posts",
115
+ "Create, list, update, and delete posts",
116
+ (y) => y.command(
117
+ ["list", "$0"],
118
+ "List posts (paginate with --page and --limit)",
119
+ (yy) => yy.option("page", {
120
+ type: "number",
121
+ describe: "Page number (starts at 1)"
122
+ }).option("limit", {
123
+ type: "number",
124
+ describe: "Page size (max 100)"
125
+ }),
126
+ (argv) => {
127
+ const query = {
128
+ ...argv.page !== void 0 ? { page: argv.page } : {},
129
+ ...argv.limit !== void 0 ? { limit: argv.limit } : {}
130
+ };
131
+ output(
132
+ getClient().posts.list(
133
+ Object.keys(query).length ? query : void 0
134
+ ),
135
+ argv.pretty
136
+ );
137
+ }
138
+ ).command(
139
+ "get <id>",
140
+ "Get a post by id",
141
+ (yy) => yy.positional("id", { type: "string", demandOption: true }),
142
+ (argv) => output(getClient().posts.get(argv.id), argv.pretty)
143
+ ).command(
144
+ "create",
145
+ "Create a post for one or more connected accounts",
146
+ (yy) => yy.option("content", {
147
+ type: "string",
148
+ describe: "Shared text content for the post"
149
+ }).option("account", {
150
+ type: "array",
151
+ string: true,
152
+ describe: "Connected account id to post to (repeat for multiple simple accounts)"
153
+ }).option("accounts-json", {
154
+ type: "string",
155
+ describe: "JSON array of account objects with accountId and optional postOverrides/platformSpecificSettings"
156
+ }).conflicts("account", "accounts-json").option("media-id", {
157
+ type: "array",
158
+ string: true,
159
+ describe: "Media id to attach (repeat for multiple)"
160
+ }).option("thumbnail-timestamp", {
161
+ type: "number",
162
+ describe: "Default video thumbnail timestamp in milliseconds for Instagram and TikTok"
163
+ }).option("scheduled-at", {
164
+ type: "string",
165
+ describe: "ISO 8601 schedule time. Omit (and no --publish-now) to save as a draft."
166
+ }).option("publish-now", {
167
+ type: "boolean",
168
+ describe: "Publish immediately. Cannot be combined with --scheduled-at."
169
+ }),
170
+ (argv) => {
171
+ const accounts = argv["accounts-json"] !== void 0 ? parseJsonOption(
172
+ "--accounts-json",
173
+ argv["accounts-json"]
174
+ ) : (argv.account ?? []).map(
175
+ (accountId) => ({ accountId })
176
+ );
177
+ const mediaIds = argv["media-id"];
178
+ output(
179
+ getClient().posts.create({
180
+ ...argv.content !== void 0 ? { content: argv.content } : {},
181
+ accounts,
182
+ ...mediaIds !== void 0 ? { mediaIds } : {},
183
+ ...argv["thumbnail-timestamp"] !== void 0 ? { thumbnailTimestamp: argv["thumbnail-timestamp"] } : {},
184
+ ...argv["scheduled-at"] !== void 0 ? { scheduledAt: argv["scheduled-at"] } : {},
185
+ ...argv["publish-now"] !== void 0 ? { publishNow: argv["publish-now"] } : {}
186
+ }),
187
+ argv.pretty
188
+ );
189
+ }
190
+ ).command(
191
+ "update <id>",
192
+ "Update a draft or scheduled post",
193
+ (yy) => yy.positional("id", { type: "string", demandOption: true }).option("content", { type: "string" }).option("scheduled-at", {
194
+ type: "string",
195
+ describe: "ISO 8601 schedule time"
196
+ }).option("media-id", {
197
+ type: "array",
198
+ string: true,
199
+ describe: "Replacement media id (repeat for multiple). Replaces all current media."
200
+ }).option("media-ids-json", {
201
+ type: "string",
202
+ describe: "Exact replacement media ID array as JSON; use [] to remove all media"
203
+ }).conflicts("media-id", "media-ids-json").option("thumbnail-timestamp", {
204
+ type: "number",
205
+ describe: "New video thumbnail timestamp in milliseconds"
206
+ }),
207
+ (argv) => {
208
+ const mediaIds = argv["media-ids-json"] !== void 0 ? parseJsonOption(
209
+ "--media-ids-json",
210
+ argv["media-ids-json"]
211
+ ) : argv["media-id"];
212
+ output(
213
+ getClient().posts.update(argv.id, {
214
+ ...argv.content !== void 0 ? { content: argv.content } : {},
215
+ ...argv["scheduled-at"] !== void 0 ? { scheduledAt: argv["scheduled-at"] } : {},
216
+ ...mediaIds !== void 0 ? { mediaIds } : {},
217
+ ...argv["thumbnail-timestamp"] !== void 0 ? { thumbnailTimestamp: argv["thumbnail-timestamp"] } : {}
218
+ }),
219
+ argv.pretty
220
+ );
221
+ }
222
+ ).command(
223
+ "delete <id>",
224
+ "Delete a scheduled or draft post by id",
225
+ (yy) => yy.positional("id", { type: "string", demandOption: true }),
226
+ (argv) => output(getClient().posts.delete(argv.id), argv.pretty)
227
+ ).command(
228
+ "remove-account <id> <accountId>",
229
+ "Remove one account from a post (leaves the others untouched)",
230
+ (yy) => yy.positional("id", { type: "string", demandOption: true }).positional("accountId", { type: "string", demandOption: true }),
231
+ (argv) => output(
232
+ getClient().posts.removeAccount(argv.id, argv.accountId),
233
+ argv.pretty
234
+ )
235
+ ).demandCommand(1, "Specify a posts subcommand."),
236
+ () => {
237
+ }
238
+ ).command(
239
+ "accounts",
240
+ "List connected social accounts",
241
+ (y) => y.command(
242
+ ["list", "$0"],
243
+ "List connected social accounts",
244
+ (yy) => yy.option("workspace-id", {
245
+ type: "string",
246
+ describe: "Return only accounts in this workspace"
247
+ }).option("platform", {
248
+ type: "array",
249
+ string: true,
250
+ describe: "Filter by platform (TWITTER, INSTAGRAM, FACEBOOK, LINKEDIN, YOUTUBE, TIKTOK, THREADS, BLUESKY); repeat for OR"
251
+ }),
252
+ (argv) => {
253
+ const platform = argv.platform;
254
+ const query = {
255
+ ...argv["workspace-id"] !== void 0 ? { workspaceId: argv["workspace-id"] } : {},
256
+ ...platform !== void 0 ? { platform } : {}
257
+ };
258
+ output(
259
+ getClient().accounts.list(
260
+ Object.keys(query).length ? query : void 0
261
+ ),
262
+ argv.pretty
263
+ );
264
+ }
265
+ ).command(
266
+ "tiktok-creator-info <id>",
267
+ "Get a TikTok account\u2019s creator info (call before posting to TikTok)",
268
+ (yy) => yy.positional("id", { type: "string", demandOption: true }),
269
+ (argv) => output(
270
+ getClient().accounts.getTikTokCreatorInfo(argv.id),
271
+ argv.pretty
272
+ )
273
+ ).demandCommand(1, "Specify an accounts subcommand."),
274
+ () => {
275
+ }
276
+ ).command(
277
+ "workspaces",
278
+ "List, create, and retrieve workspaces",
279
+ (y) => y.command(
280
+ ["list", "$0"],
281
+ "List your workspaces",
282
+ (yy) => yy,
283
+ (argv) => output(getClient().workspaces.list(), argv.pretty)
284
+ ).command(
285
+ "get <id>",
286
+ "Get a workspace by id",
287
+ (yy) => yy.positional("id", { type: "string", demandOption: true }),
288
+ (argv) => output(getClient().workspaces.get(argv.id), argv.pretty)
289
+ ).command(
290
+ "create",
291
+ "Create a workspace to organize your accounts",
292
+ (yy) => yy.option("name", {
293
+ type: "string",
294
+ demandOption: true,
295
+ describe: "Workspace name"
296
+ }).option("description", { type: "string" }).option("color", {
297
+ type: "string",
298
+ describe: "Accent color as a hex string like #6366f1"
299
+ }),
300
+ (argv) => output(
301
+ getClient().workspaces.create({
302
+ name: argv.name,
303
+ ...argv.description !== void 0 ? { description: argv.description } : {},
304
+ ...argv.color !== void 0 ? { color: argv.color } : {}
305
+ }),
306
+ argv.pretty
307
+ )
308
+ ).demandCommand(1, "Specify a workspaces subcommand."),
309
+ () => {
310
+ }
311
+ ).command(
312
+ "media",
313
+ "Upload, list, and retrieve media files",
314
+ (y) => y.command(
315
+ ["list", "$0"],
316
+ "List your uploaded and generated media",
317
+ (yy) => yy.option("page", { type: "number" }).option("limit", { type: "number" }).option("id", {
318
+ type: "array",
319
+ string: true,
320
+ describe: "Filter by media ID; repeat for OR"
321
+ }).option("media-type", {
322
+ type: "array",
323
+ string: true,
324
+ describe: "Filter by media type (IMAGE, VIDEO); repeat for OR"
325
+ }).option("source", {
326
+ type: "array",
327
+ string: true,
328
+ describe: "Filter by media source (UPLOAD, GENERATED, AI_GENERATED); repeat for OR"
329
+ }),
330
+ (argv) => {
331
+ const ids = argv.id;
332
+ const mediaTypes = argv["media-type"];
333
+ const sources = argv.source;
334
+ const query = {
335
+ ...argv.page !== void 0 ? { page: argv.page } : {},
336
+ ...argv.limit !== void 0 ? { limit: argv.limit } : {},
337
+ ...ids !== void 0 ? { ids } : {},
338
+ ...mediaTypes !== void 0 ? { mediaTypes } : {},
339
+ ...sources !== void 0 ? { sources } : {}
340
+ };
341
+ output(
342
+ getClient().media.list(
343
+ Object.keys(query).length ? query : void 0
344
+ ),
345
+ argv.pretty
346
+ );
347
+ }
348
+ ).command(
349
+ "get <id>",
350
+ "Get a media file by id",
351
+ (yy) => yy.positional("id", { type: "string", demandOption: true }),
352
+ (argv) => output(getClient().media.get(argv.id), argv.pretty)
353
+ ).command(
354
+ "upload",
355
+ "Upload a media file and get back a media id",
356
+ (yy) => yy.option("file", {
357
+ type: "string",
358
+ demandOption: true,
359
+ describe: "Path to the file to upload"
360
+ }).option("filename", {
361
+ type: "string",
362
+ describe: "Override the uploaded file name"
363
+ }),
364
+ (argv) => {
365
+ const buffer = readFileSync2(argv.file);
366
+ const name = argv.filename ?? basename(argv.file);
367
+ const file = new File([buffer], name);
368
+ output(getClient().media.upload({ file }), argv.pretty);
369
+ }
370
+ ).demandCommand(1, "Specify a media subcommand."),
371
+ () => {
372
+ }
373
+ ).demandCommand(1, "Specify a command. Run `publishq --help` to see them all.").strict().help().parse();
package/package.json CHANGED
@@ -1,16 +1,50 @@
1
1
  {
2
2
  "name": "@publishq/cli",
3
- "version": "0.0.3",
4
- "description": "PublishQ CLI - Social media scheduling and publishing",
5
- "bin": {
6
- "publishq": "./index.js"
7
- },
8
- "keywords": ["social-media", "scheduling", "publishing", "cli"],
3
+ "version": "0.0.4",
4
+ "private": false,
5
+ "description": "Official command-line interface for the PublishQ API — schedule and publish across your social platforms.",
6
+ "license": "Apache-2.0",
9
7
  "author": "PublishQ",
10
8
  "homepage": "https://publishq.com",
11
- "license": "MIT",
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/PublishQ/PublishQ"
9
+ "keywords": [
10
+ "publishq",
11
+ "social-media",
12
+ "scheduling",
13
+ "cli",
14
+ "ai-agent"
15
+ ],
16
+ "type": "module",
17
+ "bin": {
18
+ "publishq": "./dist/index.js",
19
+ "pq": "./dist/index.js"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "dependencies": {
27
+ "yargs": "^17.7.2",
28
+ "@publishq/sdk": "^0.0.1"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20",
32
+ "@types/yargs": "^17.0.33",
33
+ "tsup": "^8.5.1",
34
+ "typescript": "^5",
35
+ "vitest": "3.2.4"
36
+ },
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "dev": "tsup --watch",
46
+ "typecheck": "tsc --noEmit",
47
+ "lint": "eslint src tests --max-warnings 0",
48
+ "test": "pnpm build && vitest run"
15
49
  }
16
- }
50
+ }
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- console.log("PublishQ CLI - Coming soon")