@articlesq/sdk 0.0.2 → 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.cjs +76 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -2
- package/dist/index.d.ts +268 -2
- package/dist/index.js +74 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -330,7 +330,7 @@ type ApiError = {
|
|
|
330
330
|
};
|
|
331
331
|
};
|
|
332
332
|
};
|
|
333
|
-
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";
|
|
334
334
|
type Pagination = {
|
|
335
335
|
/**
|
|
336
336
|
* Current page number (starting from 1).
|
|
@@ -455,6 +455,116 @@ type UpdateArticleBody = {
|
|
|
455
455
|
*/
|
|
456
456
|
faq?: Array<FaqItem>;
|
|
457
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
|
+
};
|
|
458
568
|
type ArticleEvent = {
|
|
459
569
|
/**
|
|
460
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.
|
|
@@ -613,6 +723,92 @@ type UpdateArticleResponses = {
|
|
|
613
723
|
200: ArticleResponse;
|
|
614
724
|
};
|
|
615
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];
|
|
616
812
|
/**
|
|
617
813
|
* Event payload
|
|
618
814
|
*/
|
|
@@ -682,6 +878,26 @@ declare class Articles {
|
|
|
682
878
|
* Update editable fields on an article — currently `content` and `metaDescription`. Send only the fields you want to change. Returns the full updated article.
|
|
683
879
|
*/
|
|
684
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">;
|
|
685
901
|
}
|
|
686
902
|
|
|
687
903
|
interface ArticlesQOptions {
|
|
@@ -719,6 +935,11 @@ declare class ArticlesQ {
|
|
|
719
935
|
* key is scoped to.
|
|
720
936
|
*/
|
|
721
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>;
|
|
722
943
|
constructor(options: ArticlesQOptions);
|
|
723
944
|
}
|
|
724
945
|
declare function createArticlesNamespace(client: Client): {
|
|
@@ -780,6 +1001,51 @@ declare function createArticlesNamespace(client: Client): {
|
|
|
780
1001
|
request?: Request;
|
|
781
1002
|
response?: Response;
|
|
782
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
|
+
}>;
|
|
783
1049
|
};
|
|
784
1050
|
|
|
785
|
-
export { type ApiError, type ApiErrorCode, type Article, type ArticleEvent, type ArticlePublishedWebhookPayload, type ArticlePublishedWebhookRequest, type ArticleResponse, type ArticleStatus, type ArticleUnpublishedWebhookPayload, type ArticleUnpublishedWebhookRequest, type ArticleUpdatedWebhookPayload, type ArticleUpdatedWebhookRequest, 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, type Webhooks, 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.d.ts
CHANGED
|
@@ -330,7 +330,7 @@ type ApiError = {
|
|
|
330
330
|
};
|
|
331
331
|
};
|
|
332
332
|
};
|
|
333
|
-
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";
|
|
334
334
|
type Pagination = {
|
|
335
335
|
/**
|
|
336
336
|
* Current page number (starting from 1).
|
|
@@ -455,6 +455,116 @@ type UpdateArticleBody = {
|
|
|
455
455
|
*/
|
|
456
456
|
faq?: Array<FaqItem>;
|
|
457
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
|
+
};
|
|
458
568
|
type ArticleEvent = {
|
|
459
569
|
/**
|
|
460
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.
|
|
@@ -613,6 +723,92 @@ type UpdateArticleResponses = {
|
|
|
613
723
|
200: ArticleResponse;
|
|
614
724
|
};
|
|
615
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];
|
|
616
812
|
/**
|
|
617
813
|
* Event payload
|
|
618
814
|
*/
|
|
@@ -682,6 +878,26 @@ declare class Articles {
|
|
|
682
878
|
* Update editable fields on an article — currently `content` and `metaDescription`. Send only the fields you want to change. Returns the full updated article.
|
|
683
879
|
*/
|
|
684
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">;
|
|
685
901
|
}
|
|
686
902
|
|
|
687
903
|
interface ArticlesQOptions {
|
|
@@ -719,6 +935,11 @@ declare class ArticlesQ {
|
|
|
719
935
|
* key is scoped to.
|
|
720
936
|
*/
|
|
721
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>;
|
|
722
943
|
constructor(options: ArticlesQOptions);
|
|
723
944
|
}
|
|
724
945
|
declare function createArticlesNamespace(client: Client): {
|
|
@@ -780,6 +1001,51 @@ declare function createArticlesNamespace(client: Client): {
|
|
|
780
1001
|
request?: Request;
|
|
781
1002
|
response?: Response;
|
|
782
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
|
+
}>;
|
|
783
1049
|
};
|
|
784
1050
|
|
|
785
|
-
export { type ApiError, type ApiErrorCode, type Article, type ArticleEvent, type ArticlePublishedWebhookPayload, type ArticlePublishedWebhookRequest, type ArticleResponse, type ArticleStatus, type ArticleUnpublishedWebhookPayload, type ArticleUnpublishedWebhookRequest, type ArticleUpdatedWebhookPayload, type ArticleUpdatedWebhookRequest, 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, type Webhooks, 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 };
|