@jiggai/kitchen-plugin-marketing 0.3.1 → 0.3.3

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,16 +241,47 @@ 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 }));
266
+ const postDate = options?.scheduledAt || (/* @__PURE__ */ new Date()).toISOString();
245
267
  const payload = {
246
- content,
247
- integrationIds: [integrationId]
268
+ type: options?.scheduledAt ? "schedule" : "now",
269
+ date: postDate,
270
+ shortLink: false,
271
+ tags: [],
272
+ posts: [
273
+ {
274
+ integration: { id: integrationId },
275
+ value: [
276
+ {
277
+ content,
278
+ image,
279
+ settings
280
+ }
281
+ ]
282
+ }
283
+ ]
248
284
  };
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 }));
253
- }
254
285
  const res = await postizFetch(config, "/posts", {
255
286
  method: "POST",
256
287
  body: JSON.stringify(payload)
@@ -266,6 +297,7 @@ async function postizPublish(config, integrationId, content, options) {
266
297
  var BaseDriver = class {
267
298
  config;
268
299
  _postizIntegrationId = null;
300
+ _postizIdentifier = null;
269
301
  _statusCache = null;
270
302
  constructor(config) {
271
303
  this.config = config;
@@ -306,6 +338,7 @@ var BaseDriver = class {
306
338
  );
307
339
  if (match) {
308
340
  this._postizIntegrationId = this.config.postiz.integrationId || match.id;
341
+ this._postizIdentifier = (match.identifier || match.providerIdentifier || this.postizProvider).toLowerCase();
309
342
  this._statusCache = {
310
343
  connected: true,
311
344
  backend: "postiz",
@@ -367,7 +400,8 @@ var BaseDriver = class {
367
400
  const result = await postizPublish(cfg, integrationId, content.text, {
368
401
  scheduledAt: content.scheduledAt,
369
402
  mediaUrls: content.mediaUrls,
370
- settings: content.settings
403
+ settings: content.settings,
404
+ platformIdentifier: this._postizIdentifier || this.postizProvider
371
405
  });
372
406
  return {
373
407
  success: result.success,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiggai/kitchen-plugin-marketing",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Marketing Suite plugin for ClawKitchen",
5
5
  "main": "dist/index.js",
6
6
  "files": [