@articlesq/sdk 0.0.1 → 0.0.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.
package/dist/index.d.ts CHANGED
@@ -315,6 +315,7 @@ type Options$1<TData extends TDataShape = TDataShape, ThrowOnError extends boole
315
315
  type ClientOptions = {
316
316
  baseUrl: "https://articlesq.com/api/v1" | (string & {});
317
317
  };
318
+ type Webhooks = ArticlePublishedWebhookRequest | ArticleUpdatedWebhookRequest | ArticleUnpublishedWebhookRequest;
318
319
  type ApiError = {
319
320
  error: {
320
321
  title: string;
@@ -329,7 +330,7 @@ type ApiError = {
329
330
  };
330
331
  };
331
332
  };
332
- type ApiErrorCode = "missing_auth" | "invalid_auth_format" | "invalid_api_key" | "api_key_expired" | "insufficient_scope" | "not_found" | "route_not_found" | "validation_failed" | "slug_conflict" | "internal_error";
333
+ type ApiErrorCode = "missing_auth" | "invalid_auth_format" | "invalid_api_key" | "api_key_expired" | "insufficient_scope" | "forbidden" | "not_found" | "route_not_found" | "validation_failed" | "slug_conflict" | "internal_error";
333
334
  type Pagination = {
334
335
  /**
335
336
  * Current page number (starting from 1).
@@ -390,7 +391,7 @@ type Article = {
390
391
  */
391
392
  datePublished: string | null;
392
393
  /**
393
- * Last meaningful content update (schema.org `dateModified`) as an ISO 8601 string. Null until the article is edited after being published.
394
+ * Last meaningful content update (schema.org `dateModified`) as an ISO 8601 string. Stamped automatically when a published article's content changes, and overridable from the dashboard for imported content. Null until either happens.
394
395
  */
395
396
  dateModified: string | null;
396
397
  };
@@ -454,6 +455,134 @@ type UpdateArticleBody = {
454
455
  */
455
456
  faq?: Array<FaqItem>;
456
457
  };
458
+ type GenerateArticleImagesBody = {
459
+ cover?: CoverImagePrompt;
460
+ /**
461
+ * In-content images (16:9). Each one replaces its `{{IMAGE_N}}` marker in the article content with the generated image.
462
+ */
463
+ inline?: Array<InlineImagePrompt>;
464
+ };
465
+ /**
466
+ * Cover image (16:9). Replaces the current cover when the article already has one.
467
+ */
468
+ type CoverImagePrompt = {
469
+ /**
470
+ * What the image shows: subject, action, setting, composition, and where the logo or character sits if you want a specific spot. The project's image style, its logo and character references, the placement rules and the project's brand notes are added to this prompt automatically, so describe the scene only.
471
+ */
472
+ prompt: string;
473
+ /**
474
+ * Alt text for the image. Also used to name the stored file, so write it the way someone would search for it.
475
+ */
476
+ alt: string;
477
+ /**
478
+ * Set to `false` to leave the logo and character out of this image (e.g. a clean diagram). Defaults to the project's image settings.
479
+ */
480
+ branding?: boolean;
481
+ };
482
+ type InlineImagePrompt = {
483
+ /**
484
+ * Marker this image replaces. Put `{{IMAGE_1}}` on its own line in the article content where the image belongs, then send `id: "IMAGE_1"`.
485
+ */
486
+ id: string;
487
+ /**
488
+ * What the image shows: subject, action, setting, composition, and where the logo or character sits if you want a specific spot. The project's image style, its logo and character references, the placement rules and the project's brand notes are added to this prompt automatically, so describe the scene only.
489
+ */
490
+ prompt: string;
491
+ /**
492
+ * Alt text for the image. Also used to name the stored file, so write it the way someone would search for it.
493
+ */
494
+ alt: string;
495
+ /**
496
+ * Set to `false` to leave the logo and character out of this image (e.g. a clean diagram). Defaults to the project's image settings.
497
+ */
498
+ branding?: boolean;
499
+ };
500
+ type ArticleImagesResponse = {
501
+ article: Article;
502
+ images: GenerateArticleImagesResult;
503
+ };
504
+ type GenerateArticleImagesResult = {
505
+ /**
506
+ * Ids of the images that were generated and saved.
507
+ */
508
+ generated: Array<string>;
509
+ /**
510
+ * Ids of the images that are not in the article after this call. Send an inline id again only if its `{{ID}}` marker is still in the returned `article.content`; if the marker is gone, another call already placed an image there. Send the cover again if `coverImage` did not change.
511
+ */
512
+ failed: Array<string>;
513
+ };
514
+ type ImageSettingsResponse = {
515
+ imageSettings: ImageSettings;
516
+ };
517
+ type ImageSettings = {
518
+ /**
519
+ * A preset id from `stylePresets`, or your own style description. Prepended to every image prompt. An empty string selects the default preset.
520
+ */
521
+ imageStyle: "" | string;
522
+ /**
523
+ * The style text that is actually added to prompts: the preset's description, or `imageStyle` itself when it is custom.
524
+ */
525
+ imageStyleDescription: string;
526
+ stylePresets: Array<StylePreset>;
527
+ /**
528
+ * Whether the project's logo is placed in generated images, once per image.
529
+ */
530
+ logoEnabled: boolean;
531
+ /**
532
+ * The logo image attached to image prompts: the AI-specific logo variation when one is uploaded, otherwise the project logo.
533
+ */
534
+ logoImageUrl: string | null;
535
+ /**
536
+ * Whether the project's character appears in generated images as the main character.
537
+ */
538
+ characterEnabled: boolean;
539
+ /**
540
+ * The character reference photo. Upload it from the dashboard's image settings.
541
+ */
542
+ characterImageUrl: string | null;
543
+ /**
544
+ * Brand notes added to every image prompt, e.g. where the logo goes or what the character wears.
545
+ */
546
+ instructions: string;
547
+ };
548
+ type StylePreset = {
549
+ id: string;
550
+ label: string;
551
+ description: string;
552
+ };
553
+ type UpdateImageSettingsBody = {
554
+ /**
555
+ * A preset id from `stylePresets`, or your own style description. Prepended to every image prompt. An empty string selects the default preset.
556
+ */
557
+ imageStyle?: "" | string;
558
+ logoEnabled?: boolean;
559
+ /**
560
+ * Requires a character photo on the project (`characterImageUrl`).
561
+ */
562
+ characterEnabled?: boolean;
563
+ /**
564
+ * Brand notes added to every image prompt. Pass an empty string to clear them.
565
+ */
566
+ instructions?: string;
567
+ };
568
+ type ArticleEvent = {
569
+ /**
570
+ * Which event fired. `article.published` on an article becoming public, `article.updated` on a content change to an already-published article, `article.unpublished` when it returns to draft and leaves the public API.
571
+ */
572
+ type: "article.published" | "article.updated" | "article.unpublished";
573
+ /**
574
+ * When the event was generated, ISO 8601. Matches the `webhook-timestamp` header (seconds since the epoch) used to sign the request.
575
+ */
576
+ timestamp: string;
577
+ /**
578
+ * Identifies the article that changed. Fetch `GET /articles/{slug}` for the current content: the event is a notification, not a snapshot.
579
+ */
580
+ article: {
581
+ id: string;
582
+ slug: string;
583
+ projectId: string;
584
+ };
585
+ };
457
586
  type ListArticlesData = {
458
587
  body?: never;
459
588
  path?: never;
@@ -594,6 +723,122 @@ type UpdateArticleResponses = {
594
723
  200: ArticleResponse;
595
724
  };
596
725
  type UpdateArticleResponse = UpdateArticleResponses[keyof UpdateArticleResponses];
726
+ type GenerateArticleImagesData = {
727
+ body: GenerateArticleImagesBody;
728
+ path: {
729
+ slug: string;
730
+ };
731
+ query?: never;
732
+ url: "/articles/{slug}/images";
733
+ };
734
+ type GenerateArticleImagesErrors = {
735
+ /**
736
+ * Invalid request body, or the content has no marker for an inline image
737
+ */
738
+ 400: ApiError;
739
+ /**
740
+ * Invalid or missing API key
741
+ */
742
+ 401: ApiError;
743
+ /**
744
+ * API key lacks the required scope
745
+ */
746
+ 403: ApiError;
747
+ /**
748
+ * Article not found in this project
749
+ */
750
+ 404: ApiError;
751
+ };
752
+ type GenerateArticleImagesError = GenerateArticleImagesErrors[keyof GenerateArticleImagesErrors];
753
+ type GenerateArticleImagesResponses = {
754
+ /**
755
+ * Images generated and saved to the article
756
+ */
757
+ 200: ArticleImagesResponse;
758
+ };
759
+ type GenerateArticleImagesResponse = GenerateArticleImagesResponses[keyof GenerateArticleImagesResponses];
760
+ type GetImageSettingsData = {
761
+ body?: never;
762
+ path?: never;
763
+ query?: never;
764
+ url: "/image-settings";
765
+ };
766
+ type GetImageSettingsErrors = {
767
+ /**
768
+ * Invalid or missing API key
769
+ */
770
+ 401: ApiError;
771
+ /**
772
+ * API key lacks the required scope
773
+ */
774
+ 403: ApiError;
775
+ };
776
+ type GetImageSettingsError = GetImageSettingsErrors[keyof GetImageSettingsErrors];
777
+ type GetImageSettingsResponses = {
778
+ /**
779
+ * Image settings retrieved successfully
780
+ */
781
+ 200: ImageSettingsResponse;
782
+ };
783
+ type GetImageSettingsResponse = GetImageSettingsResponses[keyof GetImageSettingsResponses];
784
+ type UpdateImageSettingsData = {
785
+ body: UpdateImageSettingsBody;
786
+ path?: never;
787
+ query?: never;
788
+ url: "/image-settings";
789
+ };
790
+ type UpdateImageSettingsErrors = {
791
+ /**
792
+ * Invalid request body, or the character was enabled without a character photo
793
+ */
794
+ 400: ApiError;
795
+ /**
796
+ * Invalid or missing API key
797
+ */
798
+ 401: ApiError;
799
+ /**
800
+ * API key lacks the required scope
801
+ */
802
+ 403: ApiError;
803
+ };
804
+ type UpdateImageSettingsError = UpdateImageSettingsErrors[keyof UpdateImageSettingsErrors];
805
+ type UpdateImageSettingsResponses = {
806
+ /**
807
+ * Image settings updated
808
+ */
809
+ 200: ImageSettingsResponse;
810
+ };
811
+ type UpdateImageSettingsResponse = UpdateImageSettingsResponses[keyof UpdateImageSettingsResponses];
812
+ /**
813
+ * Event payload
814
+ */
815
+ type ArticlePublishedWebhookPayload = ArticleEvent;
816
+ type ArticlePublishedWebhookRequest = {
817
+ body: ArticlePublishedWebhookPayload;
818
+ key: "article.published";
819
+ path?: never;
820
+ query?: never;
821
+ };
822
+ /**
823
+ * Event payload
824
+ */
825
+ type ArticleUpdatedWebhookPayload = ArticleEvent;
826
+ type ArticleUpdatedWebhookRequest = {
827
+ body: ArticleUpdatedWebhookPayload;
828
+ key: "article.updated";
829
+ path?: never;
830
+ query?: never;
831
+ };
832
+ /**
833
+ * Event payload
834
+ */
835
+ type ArticleUnpublishedWebhookPayload = ArticleEvent;
836
+ type ArticleUnpublishedWebhookRequest = {
837
+ body: ArticleUnpublishedWebhookPayload;
838
+ key: "article.unpublished";
839
+ path?: never;
840
+ query?: never;
841
+ };
597
842
 
598
843
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
599
844
  /**
@@ -633,6 +878,26 @@ declare class Articles {
633
878
  * Update editable fields on an article — currently `content` and `metaDescription`. Send only the fields you want to change. Returns the full updated article.
634
879
  */
635
880
  static updateArticle<ThrowOnError extends boolean = false>(options: Options<UpdateArticleData, ThrowOnError>): RequestResult<UpdateArticleResponses, UpdateArticleErrors, ThrowOnError, "fields">;
881
+ /**
882
+ * Generate article images
883
+ *
884
+ * Generates the cover and in-content images for an article from your prompts, stores them and puts them into the article. Write `{{IMAGE_1}}`, `{{IMAGE_2}}`, ... on their own lines in the content where each image belongs, then send one prompt per marker. Each prompt describes the scene; ArticlesQ adds the project's image style, its logo and character (following the project's image settings, see `GET /image-settings`) and the project's brand notes. Images are generated in parallel and the response returns the updated article. To replace an in-content image, put its marker back in the content with `PATCH /articles/{slug}` and send its prompt again.
885
+ */
886
+ static generateArticleImages<ThrowOnError extends boolean = false>(options: Options<GenerateArticleImagesData, ThrowOnError>): RequestResult<GenerateArticleImagesResponses, GenerateArticleImagesErrors, ThrowOnError, "fields">;
887
+ }
888
+ declare class Images {
889
+ /**
890
+ * Get image settings
891
+ *
892
+ * Returns the project's image settings: the style added to every image prompt, whether the logo and the character are used, their reference images, and the brand notes. Read them before writing image prompts so your scenes fit the style and the brand notes.
893
+ */
894
+ static getImageSettings<ThrowOnError extends boolean = false>(options?: Options<GetImageSettingsData, ThrowOnError>): RequestResult<GetImageSettingsResponses, GetImageSettingsErrors, ThrowOnError, "fields">;
895
+ /**
896
+ * Update image settings
897
+ *
898
+ * Update the project's image style, turn the logo or the character on or off, or edit the brand notes. Send only the fields you want to change. Returns the full image settings.
899
+ */
900
+ static updateImageSettings<ThrowOnError extends boolean = false>(options: Options<UpdateImageSettingsData, ThrowOnError>): RequestResult<UpdateImageSettingsResponses, UpdateImageSettingsErrors, ThrowOnError, "fields">;
636
901
  }
637
902
 
638
903
  interface ArticlesQOptions {
@@ -670,6 +935,11 @@ declare class ArticlesQ {
670
935
  * key is scoped to.
671
936
  */
672
937
  readonly articles: ReturnType<typeof createArticlesNamespace>;
938
+ /**
939
+ * The project's image settings: style, logo, character and brand notes
940
+ * that ArticlesQ adds to every generated image.
941
+ */
942
+ readonly imageSettings: ReturnType<typeof createImageSettingsNamespace>;
673
943
  constructor(options: ArticlesQOptions);
674
944
  }
675
945
  declare function createArticlesNamespace(client: Client): {
@@ -731,6 +1001,51 @@ declare function createArticlesNamespace(client: Client): {
731
1001
  request?: Request;
732
1002
  response?: Response;
733
1003
  }>;
1004
+ /**
1005
+ * Generate the cover and in-content images for an article from your
1006
+ * prompts. Wraps `Articles.generateArticleImages`.
1007
+ *
1008
+ * Put `{{IMAGE_1}}`, `{{IMAGE_2}}`, ... in the content where each image
1009
+ * belongs, then send one prompt per marker. The project's image style,
1010
+ * logo, character and brand notes are added automatically.
1011
+ */
1012
+ generateImages: (slug: string, body: GenerateArticleImagesData["body"]) => Promise<({
1013
+ data: ArticleImagesResponse;
1014
+ error: undefined;
1015
+ } | {
1016
+ data: undefined;
1017
+ error: ApiError;
1018
+ }) & {
1019
+ request?: Request;
1020
+ response?: Response;
1021
+ }>;
1022
+ };
1023
+ declare function createImageSettingsNamespace(client: Client): {
1024
+ /** Read the project's image settings. Wraps `Images.getImageSettings`. */
1025
+ get: () => Promise<({
1026
+ data: ImageSettingsResponse;
1027
+ error: undefined;
1028
+ } | {
1029
+ data: undefined;
1030
+ error: ApiError;
1031
+ }) & {
1032
+ request?: Request;
1033
+ response?: Response;
1034
+ }>;
1035
+ /**
1036
+ * Update the image style, the logo/character toggles or the brand notes.
1037
+ * Wraps `Images.updateImageSettings`.
1038
+ */
1039
+ update: (body: UpdateImageSettingsData["body"]) => Promise<({
1040
+ data: ImageSettingsResponse;
1041
+ error: undefined;
1042
+ } | {
1043
+ data: undefined;
1044
+ error: ApiError;
1045
+ }) & {
1046
+ request?: Request;
1047
+ response?: Response;
1048
+ }>;
734
1049
  };
735
1050
 
736
- export { type ApiError, type ApiErrorCode, type Article, type ArticleResponse, type ArticleStatus, Articles, ArticlesQ, type ArticlesQOptions, type ClientOptions, type CreateArticleBody, type CreateArticleData, type CreateArticleError, type CreateArticleErrors, type CreateArticleResponse, type CreateArticleResponses, type FaqItem, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponse2, type ListArticlesResponses, type Options, type Pagination, type UpdateArticleBody, type UpdateArticleData, type UpdateArticleError, type UpdateArticleErrors, type UpdateArticleResponse, type UpdateArticleResponses, ArticlesQ as default };
1051
+ export { type ApiError, type ApiErrorCode, type Article, type ArticleEvent, type ArticleImagesResponse, type ArticlePublishedWebhookPayload, type ArticlePublishedWebhookRequest, type ArticleResponse, type ArticleStatus, type ArticleUnpublishedWebhookPayload, type ArticleUnpublishedWebhookRequest, type ArticleUpdatedWebhookPayload, type ArticleUpdatedWebhookRequest, Articles, ArticlesQ, type ArticlesQOptions, type ClientOptions, type CoverImagePrompt, type CreateArticleBody, type CreateArticleData, type CreateArticleError, type CreateArticleErrors, type CreateArticleResponse, type CreateArticleResponses, type FaqItem, type GenerateArticleImagesBody, type GenerateArticleImagesData, type GenerateArticleImagesError, type GenerateArticleImagesErrors, type GenerateArticleImagesResponse, type GenerateArticleImagesResponses, type GenerateArticleImagesResult, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetImageSettingsData, type GetImageSettingsError, type GetImageSettingsErrors, type GetImageSettingsResponse, type GetImageSettingsResponses, type ImageSettings, type ImageSettingsResponse, Images, type InlineImagePrompt, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponse2, type ListArticlesResponses, type Options, type Pagination, type StylePreset, type UpdateArticleBody, type UpdateArticleData, type UpdateArticleError, type UpdateArticleErrors, type UpdateArticleResponse, type UpdateArticleResponses, type UpdateImageSettingsBody, type UpdateImageSettingsData, type UpdateImageSettingsError, type UpdateImageSettingsErrors, type UpdateImageSettingsResponse, type UpdateImageSettingsResponses, type Webhooks, ArticlesQ as default };
package/dist/index.js CHANGED
@@ -872,6 +872,52 @@ var Articles = class {
872
872
  }
873
873
  });
874
874
  }
875
+ /**
876
+ * Generate article images
877
+ *
878
+ * Generates the cover and in-content images for an article from your prompts, stores them and puts them into the article. Write `{{IMAGE_1}}`, `{{IMAGE_2}}`, ... on their own lines in the content where each image belongs, then send one prompt per marker. Each prompt describes the scene; ArticlesQ adds the project's image style, its logo and character (following the project's image settings, see `GET /image-settings`) and the project's brand notes. Images are generated in parallel and the response returns the updated article. To replace an in-content image, put its marker back in the content with `PATCH /articles/{slug}` and send its prompt again.
879
+ */
880
+ static generateArticleImages(options) {
881
+ return (options.client ?? client).post({
882
+ security: [{ scheme: "bearer", type: "http" }],
883
+ url: "/articles/{slug}/images",
884
+ ...options,
885
+ headers: {
886
+ "Content-Type": "application/json",
887
+ ...options.headers
888
+ }
889
+ });
890
+ }
891
+ };
892
+ var Images = class {
893
+ /**
894
+ * Get image settings
895
+ *
896
+ * Returns the project's image settings: the style added to every image prompt, whether the logo and the character are used, their reference images, and the brand notes. Read them before writing image prompts so your scenes fit the style and the brand notes.
897
+ */
898
+ static getImageSettings(options) {
899
+ return (options?.client ?? client).get({
900
+ security: [{ scheme: "bearer", type: "http" }],
901
+ url: "/image-settings",
902
+ ...options
903
+ });
904
+ }
905
+ /**
906
+ * Update image settings
907
+ *
908
+ * Update the project's image style, turn the logo or the character on or off, or edit the brand notes. Send only the fields you want to change. Returns the full image settings.
909
+ */
910
+ static updateImageSettings(options) {
911
+ return (options.client ?? client).patch({
912
+ security: [{ scheme: "bearer", type: "http" }],
913
+ url: "/image-settings",
914
+ ...options,
915
+ headers: {
916
+ "Content-Type": "application/json",
917
+ ...options.headers
918
+ }
919
+ });
920
+ }
875
921
  };
876
922
 
877
923
  // src/index.ts
@@ -881,6 +927,11 @@ var ArticlesQ = class {
881
927
  * key is scoped to.
882
928
  */
883
929
  articles;
930
+ /**
931
+ * The project's image settings: style, logo, character and brand notes
932
+ * that ArticlesQ adds to every generated image.
933
+ */
934
+ imageSettings;
884
935
  constructor(options) {
885
936
  const client2 = createClient(
886
937
  createConfig({
@@ -891,6 +942,7 @@ var ArticlesQ = class {
891
942
  })
892
943
  );
893
944
  this.articles = createArticlesNamespace(client2);
945
+ this.imageSettings = createImageSettingsNamespace(client2);
894
946
  }
895
947
  };
896
948
  function createArticlesNamespace(client2) {
@@ -916,13 +968,34 @@ function createArticlesNamespace(client2) {
916
968
  * Send only the fields you want to change (currently `content` and
917
969
  * `metaDescription`). Returns the full updated article on success.
918
970
  */
919
- update: (slug, body) => Articles.updateArticle({ client: client2, path: { slug }, body })
971
+ update: (slug, body) => Articles.updateArticle({ client: client2, path: { slug }, body }),
972
+ /**
973
+ * Generate the cover and in-content images for an article from your
974
+ * prompts. Wraps `Articles.generateArticleImages`.
975
+ *
976
+ * Put `{{IMAGE_1}}`, `{{IMAGE_2}}`, ... in the content where each image
977
+ * belongs, then send one prompt per marker. The project's image style,
978
+ * logo, character and brand notes are added automatically.
979
+ */
980
+ generateImages: (slug, body) => Articles.generateArticleImages({ client: client2, path: { slug }, body })
981
+ };
982
+ }
983
+ function createImageSettingsNamespace(client2) {
984
+ return {
985
+ /** Read the project's image settings. Wraps `Images.getImageSettings`. */
986
+ get: () => Images.getImageSettings({ client: client2 }),
987
+ /**
988
+ * Update the image style, the logo/character toggles or the brand notes.
989
+ * Wraps `Images.updateImageSettings`.
990
+ */
991
+ update: (body) => Images.updateImageSettings({ client: client2, body })
920
992
  };
921
993
  }
922
994
  var index_default = ArticlesQ;
923
995
  export {
924
996
  Articles,
925
997
  ArticlesQ,
998
+ Images,
926
999
  index_default as default
927
1000
  };
928
1001
  //# sourceMappingURL=index.js.map