@bettercms-ai/sdk 1.6.0 → 1.8.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/dist/index.cjs CHANGED
@@ -757,6 +757,22 @@ async function updateComponent(client, id, input) {
757
757
  return res.data;
758
758
  }
759
759
 
760
+ // src/methods/management/ai.ts
761
+ async function writeContent(client, input) {
762
+ const res = await client.fetchJSON(client.url("/management/ai/content"), {
763
+ method: "POST",
764
+ body: JSON.stringify(input)
765
+ });
766
+ return res.data.suggestion;
767
+ }
768
+ async function generateSeoMeta(client, input) {
769
+ const res = await client.fetchJSON(client.url("/management/ai/seo-meta"), {
770
+ method: "POST",
771
+ body: JSON.stringify(input)
772
+ });
773
+ return res.data;
774
+ }
775
+
760
776
  // src/management-client.ts
761
777
  var DEFAULT_BASE_URL2 = "https://api.bettercms.ai/v1";
762
778
  var DEFAULT_TIMEOUT2 = 1e4;
@@ -765,15 +781,18 @@ var RETRY_DELAYS2 = [1e3, 2e3, 4e3];
765
781
  var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
766
782
  timeout;
767
783
  _apiKey;
784
+ _project;
768
785
  constructor(options) {
769
786
  super({ workspace: "", baseUrl: options.baseUrl ?? DEFAULT_BASE_URL2 });
770
787
  this._apiKey = options.apiKey;
788
+ this._project = options.project;
771
789
  this.timeout = options.timeout ?? DEFAULT_TIMEOUT2;
772
790
  }
773
791
  headers() {
774
792
  return {
775
793
  "Content-Type": "application/json",
776
- "X-API-Key": this._apiKey
794
+ "X-API-Key": this._apiKey,
795
+ ...this._project ? { "X-BCMS-Project": this._project } : {}
777
796
  };
778
797
  }
779
798
  /** Management API URL: baseUrl + path (path is workspace-scoped via the key). */
@@ -918,6 +937,15 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
918
937
  updateComponent(id, input) {
919
938
  return updateComponent(this, id, input);
920
939
  }
940
+ // ── AI (Option B): write/rewrite/translate copy + generate SEO meta (BYOK-metered) ──
941
+ /** Write, rewrite, or translate a piece of copy. Returns the suggested text. */
942
+ writeContent(input) {
943
+ return writeContent(this, input);
944
+ }
945
+ /** Generate SEO metadata for a piece of content (title, description, keywords, JSON-LD). */
946
+ generateSeoMeta(input) {
947
+ return generateSeoMeta(this, input);
948
+ }
921
949
  };
922
950
  function sleep2(ms) {
923
951
  return new Promise((resolve) => setTimeout(resolve, ms));