postiz 2.0.2 → 2.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/dist/index.js +124 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12364,9 +12364,44 @@ var _PostizAPI = class _PostizAPI {
|
|
|
12364
12364
|
});
|
|
12365
12365
|
}
|
|
12366
12366
|
async upload(file, filename) {
|
|
12367
|
+
var _a7;
|
|
12367
12368
|
const formData = new FormData();
|
|
12368
|
-
const extension = filename.split(".").pop() || "
|
|
12369
|
-
const
|
|
12369
|
+
const extension = ((_a7 = filename.split(".").pop()) == null ? void 0 : _a7.toLowerCase()) || "";
|
|
12370
|
+
const mimeTypes = {
|
|
12371
|
+
// Images
|
|
12372
|
+
"png": "image/png",
|
|
12373
|
+
"jpg": "image/jpeg",
|
|
12374
|
+
"jpeg": "image/jpeg",
|
|
12375
|
+
"gif": "image/gif",
|
|
12376
|
+
"webp": "image/webp",
|
|
12377
|
+
"svg": "image/svg+xml",
|
|
12378
|
+
"bmp": "image/bmp",
|
|
12379
|
+
"ico": "image/x-icon",
|
|
12380
|
+
// Videos
|
|
12381
|
+
"mp4": "video/mp4",
|
|
12382
|
+
"mov": "video/quicktime",
|
|
12383
|
+
"avi": "video/x-msvideo",
|
|
12384
|
+
"mkv": "video/x-matroska",
|
|
12385
|
+
"webm": "video/webm",
|
|
12386
|
+
"flv": "video/x-flv",
|
|
12387
|
+
"wmv": "video/x-ms-wmv",
|
|
12388
|
+
"m4v": "video/x-m4v",
|
|
12389
|
+
"mpeg": "video/mpeg",
|
|
12390
|
+
"mpg": "video/mpeg",
|
|
12391
|
+
"3gp": "video/3gpp",
|
|
12392
|
+
// Audio
|
|
12393
|
+
"mp3": "audio/mpeg",
|
|
12394
|
+
"wav": "audio/wav",
|
|
12395
|
+
"ogg": "audio/ogg",
|
|
12396
|
+
"aac": "audio/aac",
|
|
12397
|
+
"flac": "audio/flac",
|
|
12398
|
+
"m4a": "audio/mp4",
|
|
12399
|
+
// Documents
|
|
12400
|
+
"pdf": "application/pdf",
|
|
12401
|
+
"doc": "application/msword",
|
|
12402
|
+
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
12403
|
+
};
|
|
12404
|
+
const type = mimeTypes[extension] || "application/octet-stream";
|
|
12370
12405
|
const blob = new Blob([
|
|
12371
12406
|
file
|
|
12372
12407
|
], {
|
|
@@ -12393,6 +12428,20 @@ var _PostizAPI = class _PostizAPI {
|
|
|
12393
12428
|
method: "GET"
|
|
12394
12429
|
});
|
|
12395
12430
|
}
|
|
12431
|
+
async getIntegrationSettings(integrationId) {
|
|
12432
|
+
return this.request(`/public/v1/integration-settings/${integrationId}`, {
|
|
12433
|
+
method: "GET"
|
|
12434
|
+
});
|
|
12435
|
+
}
|
|
12436
|
+
async triggerIntegrationTool(integrationId, methodName, data) {
|
|
12437
|
+
return this.request(`/public/v1/integration-trigger/${integrationId}`, {
|
|
12438
|
+
method: "POST",
|
|
12439
|
+
body: JSON.stringify({
|
|
12440
|
+
methodName,
|
|
12441
|
+
data
|
|
12442
|
+
})
|
|
12443
|
+
});
|
|
12444
|
+
}
|
|
12396
12445
|
};
|
|
12397
12446
|
__name(_PostizAPI, "PostizAPI");
|
|
12398
12447
|
var PostizAPI = _PostizAPI;
|
|
@@ -12521,9 +12570,9 @@ async function listPosts(args) {
|
|
|
12521
12570
|
startDate: args.startDate || defaultStartDate.toISOString(),
|
|
12522
12571
|
endDate: args.endDate || defaultEndDate.toISOString()
|
|
12523
12572
|
};
|
|
12524
|
-
if (args.
|
|
12525
|
-
|
|
12526
|
-
|
|
12573
|
+
if (args.customer) {
|
|
12574
|
+
filters.customer = args.customer;
|
|
12575
|
+
}
|
|
12527
12576
|
try {
|
|
12528
12577
|
const result = await api.listPosts(filters);
|
|
12529
12578
|
console.log("\u{1F4CB} Posts:");
|
|
@@ -12567,6 +12616,55 @@ async function listIntegrations() {
|
|
|
12567
12616
|
}
|
|
12568
12617
|
}
|
|
12569
12618
|
__name(listIntegrations, "listIntegrations");
|
|
12619
|
+
async function getIntegrationSettings(args) {
|
|
12620
|
+
const config = getConfig();
|
|
12621
|
+
const api = new PostizAPI(config);
|
|
12622
|
+
if (!args.id) {
|
|
12623
|
+
console.error("\u274C Integration ID is required");
|
|
12624
|
+
process.exit(1);
|
|
12625
|
+
}
|
|
12626
|
+
try {
|
|
12627
|
+
const result = await api.getIntegrationSettings(args.id);
|
|
12628
|
+
console.log(`\u2699\uFE0F Settings for integration: ${args.id}`);
|
|
12629
|
+
console.log(JSON.stringify(result, null, 2));
|
|
12630
|
+
return result;
|
|
12631
|
+
} catch (error) {
|
|
12632
|
+
console.error("\u274C Failed to get integration settings:", error.message);
|
|
12633
|
+
process.exit(1);
|
|
12634
|
+
}
|
|
12635
|
+
}
|
|
12636
|
+
__name(getIntegrationSettings, "getIntegrationSettings");
|
|
12637
|
+
async function triggerIntegrationTool(args) {
|
|
12638
|
+
const config = getConfig();
|
|
12639
|
+
const api = new PostizAPI(config);
|
|
12640
|
+
if (!args.id) {
|
|
12641
|
+
console.error("\u274C Integration ID is required");
|
|
12642
|
+
process.exit(1);
|
|
12643
|
+
}
|
|
12644
|
+
if (!args.method) {
|
|
12645
|
+
console.error("\u274C Method name is required");
|
|
12646
|
+
process.exit(1);
|
|
12647
|
+
}
|
|
12648
|
+
let data = {};
|
|
12649
|
+
if (args.data) {
|
|
12650
|
+
try {
|
|
12651
|
+
data = JSON.parse(args.data);
|
|
12652
|
+
} catch (error) {
|
|
12653
|
+
console.error("\u274C Failed to parse data JSON:", error.message);
|
|
12654
|
+
process.exit(1);
|
|
12655
|
+
}
|
|
12656
|
+
}
|
|
12657
|
+
try {
|
|
12658
|
+
const result = await api.triggerIntegrationTool(args.id, args.method, data);
|
|
12659
|
+
console.log(`\u{1F527} Tool result for ${args.method}:`);
|
|
12660
|
+
console.log(JSON.stringify(result, null, 2));
|
|
12661
|
+
return result;
|
|
12662
|
+
} catch (error) {
|
|
12663
|
+
console.error("\u274C Failed to trigger tool:", error.message);
|
|
12664
|
+
process.exit(1);
|
|
12665
|
+
}
|
|
12666
|
+
}
|
|
12667
|
+
__name(triggerIntegrationTool, "triggerIntegrationTool");
|
|
12570
12668
|
|
|
12571
12669
|
// src/commands/upload.ts
|
|
12572
12670
|
var import_fs6 = require("fs");
|
|
@@ -12645,27 +12743,33 @@ yargs_default(hideBin(process.argv)).scriptName("postiz").usage("$0 <command> [o
|
|
|
12645
12743
|
}).option("endDate", {
|
|
12646
12744
|
describe: "End date (ISO 8601 format). Default: 30 days from now",
|
|
12647
12745
|
type: "string"
|
|
12648
|
-
}).option("
|
|
12649
|
-
|
|
12650
|
-
describe: "Page number",
|
|
12651
|
-
type: "number",
|
|
12652
|
-
default: 1
|
|
12653
|
-
}).option("limit", {
|
|
12654
|
-
alias: "l",
|
|
12655
|
-
describe: "Number of posts per page",
|
|
12656
|
-
type: "number",
|
|
12657
|
-
default: 10
|
|
12658
|
-
}).option("search", {
|
|
12659
|
-
alias: "s",
|
|
12660
|
-
describe: "Search query",
|
|
12746
|
+
}).option("customer", {
|
|
12747
|
+
describe: "Customer ID (optional)",
|
|
12661
12748
|
type: "string"
|
|
12662
|
-
}).example("$0 posts:list", "List all posts (last 30 days to next 30 days)").example(
|
|
12749
|
+
}).example("$0 posts:list", "List all posts (last 30 days to next 30 days)").example('$0 posts:list --startDate "2024-01-01T00:00:00Z" --endDate "2024-12-31T23:59:59Z"', "List posts for a specific date range").example('$0 posts:list --customer "customer-id"', "List posts for a specific customer");
|
|
12663
12750
|
}, listPosts).command("posts:delete <id>", "Delete a post", (yargs) => {
|
|
12664
12751
|
return yargs.positional("id", {
|
|
12665
12752
|
describe: "Post ID to delete",
|
|
12666
12753
|
type: "string"
|
|
12667
12754
|
}).example("$0 posts:delete abc123", "Delete post with ID abc123");
|
|
12668
|
-
}, deletePost).command("integrations:list", "List all connected integrations", {}, listIntegrations).command("
|
|
12755
|
+
}, deletePost).command("integrations:list", "List all connected integrations", {}, listIntegrations).command("integrations:settings <id>", "Get settings schema for a specific integration", (yargs) => {
|
|
12756
|
+
return yargs.positional("id", {
|
|
12757
|
+
describe: "Integration ID",
|
|
12758
|
+
type: "string"
|
|
12759
|
+
}).example("$0 integrations:settings reddit-123", "Get settings schema for Reddit integration").example("$0 integrations:settings youtube-456", "Get settings schema for YouTube integration");
|
|
12760
|
+
}, getIntegrationSettings).command("integrations:trigger <id> <method>", "Trigger an integration tool to fetch additional data", (yargs) => {
|
|
12761
|
+
return yargs.positional("id", {
|
|
12762
|
+
describe: "Integration ID",
|
|
12763
|
+
type: "string"
|
|
12764
|
+
}).positional("method", {
|
|
12765
|
+
describe: "Method name from the integration tools",
|
|
12766
|
+
type: "string"
|
|
12767
|
+
}).option("data", {
|
|
12768
|
+
alias: "d",
|
|
12769
|
+
describe: "Data to pass to the tool as JSON string",
|
|
12770
|
+
type: "string"
|
|
12771
|
+
}).example("$0 integrations:trigger reddit-123 getSubreddits", "Get list of subreddits").example(`$0 integrations:trigger reddit-123 searchSubreddits -d '{"query":"programming"}'`, "Search for subreddits").example("$0 integrations:trigger youtube-123 getPlaylists", "Get YouTube playlists");
|
|
12772
|
+
}, triggerIntegrationTool).command("upload <file>", "Upload a file", (yargs) => {
|
|
12669
12773
|
return yargs.positional("file", {
|
|
12670
12774
|
describe: "File path to upload",
|
|
12671
12775
|
type: "string"
|