@jiggai/kitchen-plugin-marketing 0.3.0 → 0.3.2

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.
@@ -241,15 +241,45 @@ async function getPostizIntegrations(config) {
241
241
  const data = await res.json();
242
242
  return Array.isArray(data) ? data : data.integrations || [];
243
243
  }
244
+ var DEFAULT_PLATFORM_SETTINGS = {
245
+ "x": { __type: "x", who_can_reply_post: "everyone" },
246
+ "instagram": { __type: "instagram", post_type: "post", is_trial_reel: false, collaborators: [] },
247
+ "instagram-standalone": { __type: "instagram-standalone", post_type: "post", is_trial_reel: false, collaborators: [] },
248
+ "facebook": { __type: "facebook" },
249
+ "linkedin": { __type: "linkedin" },
250
+ "linkedin-page": { __type: "linkedin-page" },
251
+ "threads": { __type: "threads" },
252
+ "bluesky": { __type: "bluesky" },
253
+ "mastodon": { __type: "mastodon" },
254
+ "telegram": { __type: "telegram" },
255
+ "discord": { __type: "discord" },
256
+ "tiktok": { __type: "tiktok", privacy_level: "PUBLIC_TO_EVERYONE", duet: true, stitch: true, comment: true, autoAddMusic: "no", brand_content_toggle: false, brand_organic_toggle: false, content_posting_method: "DIRECT_POST" },
257
+ "youtube": { __type: "youtube", title: "Post", type: "public" },
258
+ "reddit": { __type: "reddit" },
259
+ "pinterest": { __type: "pinterest" }
260
+ };
244
261
  async function postizPublish(config, integrationId, content, options) {
262
+ const platformId = (options?.platformIdentifier || "").toLowerCase();
263
+ const defaultSettings = DEFAULT_PLATFORM_SETTINGS[platformId] || { __type: platformId };
264
+ const settings = { ...defaultSettings, ...options?.settings || {} };
265
+ const image = (options?.mediaUrls || []).map((url, i) => ({ id: `img${i}`, path: url }));
245
266
  const payload = {
246
- content,
247
- integrationIds: [integrationId]
267
+ type: options?.scheduledAt ? "schedule" : "now",
268
+ shortLink: false,
269
+ tags: [],
270
+ posts: [
271
+ {
272
+ integration: { id: integrationId },
273
+ value: {
274
+ content,
275
+ image,
276
+ settings
277
+ }
278
+ }
279
+ ]
248
280
  };
249
- if (options?.scheduledAt) payload.date = options.scheduledAt;
250
- if (options?.settings) payload.settings = options.settings;
251
- if (options?.mediaUrls?.length) {
252
- payload.media = options.mediaUrls.map((url) => ({ url }));
281
+ if (options?.scheduledAt) {
282
+ payload.date = options.scheduledAt;
253
283
  }
254
284
  const res = await postizFetch(config, "/posts", {
255
285
  method: "POST",
@@ -266,6 +296,7 @@ async function postizPublish(config, integrationId, content, options) {
266
296
  var BaseDriver = class {
267
297
  config;
268
298
  _postizIntegrationId = null;
299
+ _postizIdentifier = null;
269
300
  _statusCache = null;
270
301
  constructor(config) {
271
302
  this.config = config;
@@ -306,6 +337,7 @@ var BaseDriver = class {
306
337
  );
307
338
  if (match) {
308
339
  this._postizIntegrationId = this.config.postiz.integrationId || match.id;
340
+ this._postizIdentifier = (match.identifier || match.providerIdentifier || this.postizProvider).toLowerCase();
309
341
  this._statusCache = {
310
342
  connected: true,
311
343
  backend: "postiz",
@@ -367,7 +399,8 @@ var BaseDriver = class {
367
399
  const result = await postizPublish(cfg, integrationId, content.text, {
368
400
  scheduledAt: content.scheduledAt,
369
401
  mediaUrls: content.mediaUrls,
370
- settings: content.settings
402
+ settings: content.settings,
403
+ platformIdentifier: this._postizIdentifier || this.postizProvider
371
404
  });
372
405
  return {
373
406
  success: result.success,
@@ -602,8 +635,51 @@ function getBackendSources(req, teamId) {
602
635
  const configPath5 = (0, import_path2.join)((0, import_os2.homedir)(), ".openclaw", "openclaw.json5");
603
636
  const actualPath = (0, import_fs2.existsSync)(configPath) ? configPath : (0, import_fs2.existsSync)(configPath5) ? configPath5 : null;
604
637
  if (actualPath) {
605
- const raw = (0, import_fs2.readFileSync)(actualPath, "utf8").replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
606
- const cfg = JSON.parse(raw);
638
+ const raw = (0, import_fs2.readFileSync)(actualPath, "utf8");
639
+ let cfg;
640
+ try {
641
+ cfg = JSON.parse(raw);
642
+ } catch {
643
+ let cleaned = "";
644
+ let inStr = false;
645
+ let escape = false;
646
+ for (let i = 0; i < raw.length; i++) {
647
+ const ch = raw[i];
648
+ if (escape) {
649
+ cleaned += ch;
650
+ escape = false;
651
+ continue;
652
+ }
653
+ if (inStr) {
654
+ if (ch === "\\") {
655
+ escape = true;
656
+ cleaned += ch;
657
+ continue;
658
+ }
659
+ if (ch === '"') inStr = false;
660
+ cleaned += ch;
661
+ continue;
662
+ }
663
+ if (ch === '"') {
664
+ inStr = true;
665
+ cleaned += ch;
666
+ continue;
667
+ }
668
+ if (ch === "/" && raw[i + 1] === "/") {
669
+ while (i < raw.length && raw[i] !== "\n") i++;
670
+ cleaned += "\n";
671
+ continue;
672
+ }
673
+ if (ch === "/" && raw[i + 1] === "*") {
674
+ i += 2;
675
+ while (i < raw.length && !(raw[i] === "*" && raw[i + 1] === "/")) i++;
676
+ i++;
677
+ continue;
678
+ }
679
+ cleaned += ch;
680
+ }
681
+ cfg = JSON.parse(cleaned);
682
+ }
607
683
  const plugins = cfg?.plugins?.entries || {};
608
684
  const channels = [];
609
685
  if (plugins.discord?.enabled) channels.push("discord");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiggai/kitchen-plugin-marketing",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Marketing Suite plugin for ClawKitchen",
5
5
  "main": "dist/index.js",
6
6
  "files": [