@articlesq/sdk 0.0.2 → 0.0.4
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 +276 -2
- package/dist/index.d.ts +276 -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).
|
|
@@ -428,6 +428,10 @@ type CreateArticleBody = {
|
|
|
428
428
|
* Defaults to `draft`.
|
|
429
429
|
*/
|
|
430
430
|
status?: "draft" | "published";
|
|
431
|
+
/**
|
|
432
|
+
* Public publish date (schema.org `datePublished`) as an ISO 8601 date-time. Can be set on a draft and is kept when the article is published, so you can back-date imported or scheduled content. `null` clears it. When it is not set, the date of the first publish is used.
|
|
433
|
+
*/
|
|
434
|
+
datePublished?: string | null;
|
|
431
435
|
/**
|
|
432
436
|
* Structured FAQ as plain-text Q/A pairs. Server trims whitespace, drops fully-empty pairs, and rejects half-filled ones (only `q` or only `a`).
|
|
433
437
|
*/
|
|
@@ -450,11 +454,125 @@ type UpdateArticleBody = {
|
|
|
450
454
|
* SEO meta description, recommended < 155 characters.
|
|
451
455
|
*/
|
|
452
456
|
metaDescription?: string;
|
|
457
|
+
/**
|
|
458
|
+
* Public publish date (schema.org `datePublished`) as an ISO 8601 date-time. Can be set on a draft and is kept when the article is published, so you can back-date imported or scheduled content. `null` clears it. When it is not set, the date of the first publish is used.
|
|
459
|
+
*/
|
|
460
|
+
datePublished?: string | null;
|
|
453
461
|
/**
|
|
454
462
|
* Replace the structured FAQ. Server trims whitespace, drops fully-empty pairs, rejects half-filled ones. Pass `[]` to remove all items. Omit to leave it unchanged.
|
|
455
463
|
*/
|
|
456
464
|
faq?: Array<FaqItem>;
|
|
457
465
|
};
|
|
466
|
+
type GenerateArticleImagesBody = {
|
|
467
|
+
cover?: CoverImagePrompt;
|
|
468
|
+
/**
|
|
469
|
+
* In-content images (16:9). Each one replaces its `{{IMAGE_N}}` marker in the article content with the generated image.
|
|
470
|
+
*/
|
|
471
|
+
inline?: Array<InlineImagePrompt>;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Cover image (16:9). Replaces the current cover when the article already has one; the previous cover is kept in the article's image gallery.
|
|
475
|
+
*/
|
|
476
|
+
type CoverImagePrompt = {
|
|
477
|
+
/**
|
|
478
|
+
* 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.
|
|
479
|
+
*/
|
|
480
|
+
prompt: string;
|
|
481
|
+
/**
|
|
482
|
+
* Alt text for the image. Also used to name the stored file, so write it the way someone would search for it.
|
|
483
|
+
*/
|
|
484
|
+
alt: string;
|
|
485
|
+
/**
|
|
486
|
+
* 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.
|
|
487
|
+
*/
|
|
488
|
+
branding?: boolean;
|
|
489
|
+
};
|
|
490
|
+
type InlineImagePrompt = {
|
|
491
|
+
/**
|
|
492
|
+
* Marker this image replaces. Put `{{IMAGE_1}}` on its own line in the article content where the image belongs, then send `id: "IMAGE_1"`.
|
|
493
|
+
*/
|
|
494
|
+
id: string;
|
|
495
|
+
/**
|
|
496
|
+
* 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.
|
|
497
|
+
*/
|
|
498
|
+
prompt: string;
|
|
499
|
+
/**
|
|
500
|
+
* Alt text for the image. Also used to name the stored file, so write it the way someone would search for it.
|
|
501
|
+
*/
|
|
502
|
+
alt: string;
|
|
503
|
+
/**
|
|
504
|
+
* 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.
|
|
505
|
+
*/
|
|
506
|
+
branding?: boolean;
|
|
507
|
+
};
|
|
508
|
+
type ArticleImagesResponse = {
|
|
509
|
+
article: Article;
|
|
510
|
+
images: GenerateArticleImagesResult;
|
|
511
|
+
};
|
|
512
|
+
type GenerateArticleImagesResult = {
|
|
513
|
+
/**
|
|
514
|
+
* Ids of the images that were generated and saved.
|
|
515
|
+
*/
|
|
516
|
+
generated: Array<string>;
|
|
517
|
+
/**
|
|
518
|
+
* 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. Every image that was generated is kept in the article's image gallery, placed or not.
|
|
519
|
+
*/
|
|
520
|
+
failed: Array<string>;
|
|
521
|
+
};
|
|
522
|
+
type ImageSettingsResponse = {
|
|
523
|
+
imageSettings: ImageSettings;
|
|
524
|
+
};
|
|
525
|
+
type ImageSettings = {
|
|
526
|
+
/**
|
|
527
|
+
* A preset id from `stylePresets`, or your own style description. Prepended to every image prompt. An empty string selects the default preset.
|
|
528
|
+
*/
|
|
529
|
+
imageStyle: "" | string;
|
|
530
|
+
/**
|
|
531
|
+
* The style text that is actually added to prompts: the preset's description, or `imageStyle` itself when it is custom.
|
|
532
|
+
*/
|
|
533
|
+
imageStyleDescription: string;
|
|
534
|
+
stylePresets: Array<StylePreset>;
|
|
535
|
+
/**
|
|
536
|
+
* Whether the project's logo is placed in generated images, once per image.
|
|
537
|
+
*/
|
|
538
|
+
logoEnabled: boolean;
|
|
539
|
+
/**
|
|
540
|
+
* The logo image attached to image prompts: the AI-specific logo variation when one is uploaded, otherwise the project logo.
|
|
541
|
+
*/
|
|
542
|
+
logoImageUrl: string | null;
|
|
543
|
+
/**
|
|
544
|
+
* Whether the project's character appears in generated images as the main character.
|
|
545
|
+
*/
|
|
546
|
+
characterEnabled: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* The character reference photo. Upload it from the dashboard's image settings.
|
|
549
|
+
*/
|
|
550
|
+
characterImageUrl: string | null;
|
|
551
|
+
/**
|
|
552
|
+
* Brand notes added to every image prompt, e.g. where the logo goes or what the character wears.
|
|
553
|
+
*/
|
|
554
|
+
instructions: string;
|
|
555
|
+
};
|
|
556
|
+
type StylePreset = {
|
|
557
|
+
id: string;
|
|
558
|
+
label: string;
|
|
559
|
+
description: string;
|
|
560
|
+
};
|
|
561
|
+
type UpdateImageSettingsBody = {
|
|
562
|
+
/**
|
|
563
|
+
* A preset id from `stylePresets`, or your own style description. Prepended to every image prompt. An empty string selects the default preset.
|
|
564
|
+
*/
|
|
565
|
+
imageStyle?: "" | string;
|
|
566
|
+
logoEnabled?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Requires a character photo on the project (`characterImageUrl`).
|
|
569
|
+
*/
|
|
570
|
+
characterEnabled?: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Brand notes added to every image prompt. Pass an empty string to clear them.
|
|
573
|
+
*/
|
|
574
|
+
instructions?: string;
|
|
575
|
+
};
|
|
458
576
|
type ArticleEvent = {
|
|
459
577
|
/**
|
|
460
578
|
* 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 +731,92 @@ type UpdateArticleResponses = {
|
|
|
613
731
|
200: ArticleResponse;
|
|
614
732
|
};
|
|
615
733
|
type UpdateArticleResponse = UpdateArticleResponses[keyof UpdateArticleResponses];
|
|
734
|
+
type GenerateArticleImagesData = {
|
|
735
|
+
body: GenerateArticleImagesBody;
|
|
736
|
+
path: {
|
|
737
|
+
slug: string;
|
|
738
|
+
};
|
|
739
|
+
query?: never;
|
|
740
|
+
url: "/articles/{slug}/images";
|
|
741
|
+
};
|
|
742
|
+
type GenerateArticleImagesErrors = {
|
|
743
|
+
/**
|
|
744
|
+
* Invalid request body, or the content has no marker for an inline image
|
|
745
|
+
*/
|
|
746
|
+
400: ApiError;
|
|
747
|
+
/**
|
|
748
|
+
* Invalid or missing API key
|
|
749
|
+
*/
|
|
750
|
+
401: ApiError;
|
|
751
|
+
/**
|
|
752
|
+
* API key lacks the required scope
|
|
753
|
+
*/
|
|
754
|
+
403: ApiError;
|
|
755
|
+
/**
|
|
756
|
+
* Article not found in this project
|
|
757
|
+
*/
|
|
758
|
+
404: ApiError;
|
|
759
|
+
};
|
|
760
|
+
type GenerateArticleImagesError = GenerateArticleImagesErrors[keyof GenerateArticleImagesErrors];
|
|
761
|
+
type GenerateArticleImagesResponses = {
|
|
762
|
+
/**
|
|
763
|
+
* Images generated and saved to the article
|
|
764
|
+
*/
|
|
765
|
+
200: ArticleImagesResponse;
|
|
766
|
+
};
|
|
767
|
+
type GenerateArticleImagesResponse = GenerateArticleImagesResponses[keyof GenerateArticleImagesResponses];
|
|
768
|
+
type GetImageSettingsData = {
|
|
769
|
+
body?: never;
|
|
770
|
+
path?: never;
|
|
771
|
+
query?: never;
|
|
772
|
+
url: "/image-settings";
|
|
773
|
+
};
|
|
774
|
+
type GetImageSettingsErrors = {
|
|
775
|
+
/**
|
|
776
|
+
* Invalid or missing API key
|
|
777
|
+
*/
|
|
778
|
+
401: ApiError;
|
|
779
|
+
/**
|
|
780
|
+
* API key lacks the required scope
|
|
781
|
+
*/
|
|
782
|
+
403: ApiError;
|
|
783
|
+
};
|
|
784
|
+
type GetImageSettingsError = GetImageSettingsErrors[keyof GetImageSettingsErrors];
|
|
785
|
+
type GetImageSettingsResponses = {
|
|
786
|
+
/**
|
|
787
|
+
* Image settings retrieved successfully
|
|
788
|
+
*/
|
|
789
|
+
200: ImageSettingsResponse;
|
|
790
|
+
};
|
|
791
|
+
type GetImageSettingsResponse = GetImageSettingsResponses[keyof GetImageSettingsResponses];
|
|
792
|
+
type UpdateImageSettingsData = {
|
|
793
|
+
body: UpdateImageSettingsBody;
|
|
794
|
+
path?: never;
|
|
795
|
+
query?: never;
|
|
796
|
+
url: "/image-settings";
|
|
797
|
+
};
|
|
798
|
+
type UpdateImageSettingsErrors = {
|
|
799
|
+
/**
|
|
800
|
+
* Invalid request body, or the character was enabled without a character photo
|
|
801
|
+
*/
|
|
802
|
+
400: ApiError;
|
|
803
|
+
/**
|
|
804
|
+
* Invalid or missing API key
|
|
805
|
+
*/
|
|
806
|
+
401: ApiError;
|
|
807
|
+
/**
|
|
808
|
+
* API key lacks the required scope
|
|
809
|
+
*/
|
|
810
|
+
403: ApiError;
|
|
811
|
+
};
|
|
812
|
+
type UpdateImageSettingsError = UpdateImageSettingsErrors[keyof UpdateImageSettingsErrors];
|
|
813
|
+
type UpdateImageSettingsResponses = {
|
|
814
|
+
/**
|
|
815
|
+
* Image settings updated
|
|
816
|
+
*/
|
|
817
|
+
200: ImageSettingsResponse;
|
|
818
|
+
};
|
|
819
|
+
type UpdateImageSettingsResponse = UpdateImageSettingsResponses[keyof UpdateImageSettingsResponses];
|
|
616
820
|
/**
|
|
617
821
|
* Event payload
|
|
618
822
|
*/
|
|
@@ -682,6 +886,26 @@ declare class Articles {
|
|
|
682
886
|
* Update editable fields on an article — currently `content` and `metaDescription`. Send only the fields you want to change. Returns the full updated article.
|
|
683
887
|
*/
|
|
684
888
|
static updateArticle<ThrowOnError extends boolean = false>(options: Options<UpdateArticleData, ThrowOnError>): RequestResult<UpdateArticleResponses, UpdateArticleErrors, ThrowOnError, "fields">;
|
|
889
|
+
/**
|
|
890
|
+
* Generate article images
|
|
891
|
+
*
|
|
892
|
+
* 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.
|
|
893
|
+
*/
|
|
894
|
+
static generateArticleImages<ThrowOnError extends boolean = false>(options: Options<GenerateArticleImagesData, ThrowOnError>): RequestResult<GenerateArticleImagesResponses, GenerateArticleImagesErrors, ThrowOnError, "fields">;
|
|
895
|
+
}
|
|
896
|
+
declare class Images {
|
|
897
|
+
/**
|
|
898
|
+
* Get image settings
|
|
899
|
+
*
|
|
900
|
+
* 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.
|
|
901
|
+
*/
|
|
902
|
+
static getImageSettings<ThrowOnError extends boolean = false>(options?: Options<GetImageSettingsData, ThrowOnError>): RequestResult<GetImageSettingsResponses, GetImageSettingsErrors, ThrowOnError, "fields">;
|
|
903
|
+
/**
|
|
904
|
+
* Update image settings
|
|
905
|
+
*
|
|
906
|
+
* 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.
|
|
907
|
+
*/
|
|
908
|
+
static updateImageSettings<ThrowOnError extends boolean = false>(options: Options<UpdateImageSettingsData, ThrowOnError>): RequestResult<UpdateImageSettingsResponses, UpdateImageSettingsErrors, ThrowOnError, "fields">;
|
|
685
909
|
}
|
|
686
910
|
|
|
687
911
|
interface ArticlesQOptions {
|
|
@@ -719,6 +943,11 @@ declare class ArticlesQ {
|
|
|
719
943
|
* key is scoped to.
|
|
720
944
|
*/
|
|
721
945
|
readonly articles: ReturnType<typeof createArticlesNamespace>;
|
|
946
|
+
/**
|
|
947
|
+
* The project's image settings: style, logo, character and brand notes
|
|
948
|
+
* that ArticlesQ adds to every generated image.
|
|
949
|
+
*/
|
|
950
|
+
readonly imageSettings: ReturnType<typeof createImageSettingsNamespace>;
|
|
722
951
|
constructor(options: ArticlesQOptions);
|
|
723
952
|
}
|
|
724
953
|
declare function createArticlesNamespace(client: Client): {
|
|
@@ -780,6 +1009,51 @@ declare function createArticlesNamespace(client: Client): {
|
|
|
780
1009
|
request?: Request;
|
|
781
1010
|
response?: Response;
|
|
782
1011
|
}>;
|
|
1012
|
+
/**
|
|
1013
|
+
* Generate the cover and in-content images for an article from your
|
|
1014
|
+
* prompts. Wraps `Articles.generateArticleImages`.
|
|
1015
|
+
*
|
|
1016
|
+
* Put `{{IMAGE_1}}`, `{{IMAGE_2}}`, ... in the content where each image
|
|
1017
|
+
* belongs, then send one prompt per marker. The project's image style,
|
|
1018
|
+
* logo, character and brand notes are added automatically.
|
|
1019
|
+
*/
|
|
1020
|
+
generateImages: (slug: string, body: GenerateArticleImagesData["body"]) => Promise<({
|
|
1021
|
+
data: ArticleImagesResponse;
|
|
1022
|
+
error: undefined;
|
|
1023
|
+
} | {
|
|
1024
|
+
data: undefined;
|
|
1025
|
+
error: ApiError;
|
|
1026
|
+
}) & {
|
|
1027
|
+
request?: Request;
|
|
1028
|
+
response?: Response;
|
|
1029
|
+
}>;
|
|
1030
|
+
};
|
|
1031
|
+
declare function createImageSettingsNamespace(client: Client): {
|
|
1032
|
+
/** Read the project's image settings. Wraps `Images.getImageSettings`. */
|
|
1033
|
+
get: () => Promise<({
|
|
1034
|
+
data: ImageSettingsResponse;
|
|
1035
|
+
error: undefined;
|
|
1036
|
+
} | {
|
|
1037
|
+
data: undefined;
|
|
1038
|
+
error: ApiError;
|
|
1039
|
+
}) & {
|
|
1040
|
+
request?: Request;
|
|
1041
|
+
response?: Response;
|
|
1042
|
+
}>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Update the image style, the logo/character toggles or the brand notes.
|
|
1045
|
+
* Wraps `Images.updateImageSettings`.
|
|
1046
|
+
*/
|
|
1047
|
+
update: (body: UpdateImageSettingsData["body"]) => Promise<({
|
|
1048
|
+
data: ImageSettingsResponse;
|
|
1049
|
+
error: undefined;
|
|
1050
|
+
} | {
|
|
1051
|
+
data: undefined;
|
|
1052
|
+
error: ApiError;
|
|
1053
|
+
}) & {
|
|
1054
|
+
request?: Request;
|
|
1055
|
+
response?: Response;
|
|
1056
|
+
}>;
|
|
783
1057
|
};
|
|
784
1058
|
|
|
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 };
|
|
1059
|
+
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).
|
|
@@ -428,6 +428,10 @@ type CreateArticleBody = {
|
|
|
428
428
|
* Defaults to `draft`.
|
|
429
429
|
*/
|
|
430
430
|
status?: "draft" | "published";
|
|
431
|
+
/**
|
|
432
|
+
* Public publish date (schema.org `datePublished`) as an ISO 8601 date-time. Can be set on a draft and is kept when the article is published, so you can back-date imported or scheduled content. `null` clears it. When it is not set, the date of the first publish is used.
|
|
433
|
+
*/
|
|
434
|
+
datePublished?: string | null;
|
|
431
435
|
/**
|
|
432
436
|
* Structured FAQ as plain-text Q/A pairs. Server trims whitespace, drops fully-empty pairs, and rejects half-filled ones (only `q` or only `a`).
|
|
433
437
|
*/
|
|
@@ -450,11 +454,125 @@ type UpdateArticleBody = {
|
|
|
450
454
|
* SEO meta description, recommended < 155 characters.
|
|
451
455
|
*/
|
|
452
456
|
metaDescription?: string;
|
|
457
|
+
/**
|
|
458
|
+
* Public publish date (schema.org `datePublished`) as an ISO 8601 date-time. Can be set on a draft and is kept when the article is published, so you can back-date imported or scheduled content. `null` clears it. When it is not set, the date of the first publish is used.
|
|
459
|
+
*/
|
|
460
|
+
datePublished?: string | null;
|
|
453
461
|
/**
|
|
454
462
|
* Replace the structured FAQ. Server trims whitespace, drops fully-empty pairs, rejects half-filled ones. Pass `[]` to remove all items. Omit to leave it unchanged.
|
|
455
463
|
*/
|
|
456
464
|
faq?: Array<FaqItem>;
|
|
457
465
|
};
|
|
466
|
+
type GenerateArticleImagesBody = {
|
|
467
|
+
cover?: CoverImagePrompt;
|
|
468
|
+
/**
|
|
469
|
+
* In-content images (16:9). Each one replaces its `{{IMAGE_N}}` marker in the article content with the generated image.
|
|
470
|
+
*/
|
|
471
|
+
inline?: Array<InlineImagePrompt>;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Cover image (16:9). Replaces the current cover when the article already has one; the previous cover is kept in the article's image gallery.
|
|
475
|
+
*/
|
|
476
|
+
type CoverImagePrompt = {
|
|
477
|
+
/**
|
|
478
|
+
* 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.
|
|
479
|
+
*/
|
|
480
|
+
prompt: string;
|
|
481
|
+
/**
|
|
482
|
+
* Alt text for the image. Also used to name the stored file, so write it the way someone would search for it.
|
|
483
|
+
*/
|
|
484
|
+
alt: string;
|
|
485
|
+
/**
|
|
486
|
+
* 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.
|
|
487
|
+
*/
|
|
488
|
+
branding?: boolean;
|
|
489
|
+
};
|
|
490
|
+
type InlineImagePrompt = {
|
|
491
|
+
/**
|
|
492
|
+
* Marker this image replaces. Put `{{IMAGE_1}}` on its own line in the article content where the image belongs, then send `id: "IMAGE_1"`.
|
|
493
|
+
*/
|
|
494
|
+
id: string;
|
|
495
|
+
/**
|
|
496
|
+
* 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.
|
|
497
|
+
*/
|
|
498
|
+
prompt: string;
|
|
499
|
+
/**
|
|
500
|
+
* Alt text for the image. Also used to name the stored file, so write it the way someone would search for it.
|
|
501
|
+
*/
|
|
502
|
+
alt: string;
|
|
503
|
+
/**
|
|
504
|
+
* 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.
|
|
505
|
+
*/
|
|
506
|
+
branding?: boolean;
|
|
507
|
+
};
|
|
508
|
+
type ArticleImagesResponse = {
|
|
509
|
+
article: Article;
|
|
510
|
+
images: GenerateArticleImagesResult;
|
|
511
|
+
};
|
|
512
|
+
type GenerateArticleImagesResult = {
|
|
513
|
+
/**
|
|
514
|
+
* Ids of the images that were generated and saved.
|
|
515
|
+
*/
|
|
516
|
+
generated: Array<string>;
|
|
517
|
+
/**
|
|
518
|
+
* 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. Every image that was generated is kept in the article's image gallery, placed or not.
|
|
519
|
+
*/
|
|
520
|
+
failed: Array<string>;
|
|
521
|
+
};
|
|
522
|
+
type ImageSettingsResponse = {
|
|
523
|
+
imageSettings: ImageSettings;
|
|
524
|
+
};
|
|
525
|
+
type ImageSettings = {
|
|
526
|
+
/**
|
|
527
|
+
* A preset id from `stylePresets`, or your own style description. Prepended to every image prompt. An empty string selects the default preset.
|
|
528
|
+
*/
|
|
529
|
+
imageStyle: "" | string;
|
|
530
|
+
/**
|
|
531
|
+
* The style text that is actually added to prompts: the preset's description, or `imageStyle` itself when it is custom.
|
|
532
|
+
*/
|
|
533
|
+
imageStyleDescription: string;
|
|
534
|
+
stylePresets: Array<StylePreset>;
|
|
535
|
+
/**
|
|
536
|
+
* Whether the project's logo is placed in generated images, once per image.
|
|
537
|
+
*/
|
|
538
|
+
logoEnabled: boolean;
|
|
539
|
+
/**
|
|
540
|
+
* The logo image attached to image prompts: the AI-specific logo variation when one is uploaded, otherwise the project logo.
|
|
541
|
+
*/
|
|
542
|
+
logoImageUrl: string | null;
|
|
543
|
+
/**
|
|
544
|
+
* Whether the project's character appears in generated images as the main character.
|
|
545
|
+
*/
|
|
546
|
+
characterEnabled: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* The character reference photo. Upload it from the dashboard's image settings.
|
|
549
|
+
*/
|
|
550
|
+
characterImageUrl: string | null;
|
|
551
|
+
/**
|
|
552
|
+
* Brand notes added to every image prompt, e.g. where the logo goes or what the character wears.
|
|
553
|
+
*/
|
|
554
|
+
instructions: string;
|
|
555
|
+
};
|
|
556
|
+
type StylePreset = {
|
|
557
|
+
id: string;
|
|
558
|
+
label: string;
|
|
559
|
+
description: string;
|
|
560
|
+
};
|
|
561
|
+
type UpdateImageSettingsBody = {
|
|
562
|
+
/**
|
|
563
|
+
* A preset id from `stylePresets`, or your own style description. Prepended to every image prompt. An empty string selects the default preset.
|
|
564
|
+
*/
|
|
565
|
+
imageStyle?: "" | string;
|
|
566
|
+
logoEnabled?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Requires a character photo on the project (`characterImageUrl`).
|
|
569
|
+
*/
|
|
570
|
+
characterEnabled?: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Brand notes added to every image prompt. Pass an empty string to clear them.
|
|
573
|
+
*/
|
|
574
|
+
instructions?: string;
|
|
575
|
+
};
|
|
458
576
|
type ArticleEvent = {
|
|
459
577
|
/**
|
|
460
578
|
* 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 +731,92 @@ type UpdateArticleResponses = {
|
|
|
613
731
|
200: ArticleResponse;
|
|
614
732
|
};
|
|
615
733
|
type UpdateArticleResponse = UpdateArticleResponses[keyof UpdateArticleResponses];
|
|
734
|
+
type GenerateArticleImagesData = {
|
|
735
|
+
body: GenerateArticleImagesBody;
|
|
736
|
+
path: {
|
|
737
|
+
slug: string;
|
|
738
|
+
};
|
|
739
|
+
query?: never;
|
|
740
|
+
url: "/articles/{slug}/images";
|
|
741
|
+
};
|
|
742
|
+
type GenerateArticleImagesErrors = {
|
|
743
|
+
/**
|
|
744
|
+
* Invalid request body, or the content has no marker for an inline image
|
|
745
|
+
*/
|
|
746
|
+
400: ApiError;
|
|
747
|
+
/**
|
|
748
|
+
* Invalid or missing API key
|
|
749
|
+
*/
|
|
750
|
+
401: ApiError;
|
|
751
|
+
/**
|
|
752
|
+
* API key lacks the required scope
|
|
753
|
+
*/
|
|
754
|
+
403: ApiError;
|
|
755
|
+
/**
|
|
756
|
+
* Article not found in this project
|
|
757
|
+
*/
|
|
758
|
+
404: ApiError;
|
|
759
|
+
};
|
|
760
|
+
type GenerateArticleImagesError = GenerateArticleImagesErrors[keyof GenerateArticleImagesErrors];
|
|
761
|
+
type GenerateArticleImagesResponses = {
|
|
762
|
+
/**
|
|
763
|
+
* Images generated and saved to the article
|
|
764
|
+
*/
|
|
765
|
+
200: ArticleImagesResponse;
|
|
766
|
+
};
|
|
767
|
+
type GenerateArticleImagesResponse = GenerateArticleImagesResponses[keyof GenerateArticleImagesResponses];
|
|
768
|
+
type GetImageSettingsData = {
|
|
769
|
+
body?: never;
|
|
770
|
+
path?: never;
|
|
771
|
+
query?: never;
|
|
772
|
+
url: "/image-settings";
|
|
773
|
+
};
|
|
774
|
+
type GetImageSettingsErrors = {
|
|
775
|
+
/**
|
|
776
|
+
* Invalid or missing API key
|
|
777
|
+
*/
|
|
778
|
+
401: ApiError;
|
|
779
|
+
/**
|
|
780
|
+
* API key lacks the required scope
|
|
781
|
+
*/
|
|
782
|
+
403: ApiError;
|
|
783
|
+
};
|
|
784
|
+
type GetImageSettingsError = GetImageSettingsErrors[keyof GetImageSettingsErrors];
|
|
785
|
+
type GetImageSettingsResponses = {
|
|
786
|
+
/**
|
|
787
|
+
* Image settings retrieved successfully
|
|
788
|
+
*/
|
|
789
|
+
200: ImageSettingsResponse;
|
|
790
|
+
};
|
|
791
|
+
type GetImageSettingsResponse = GetImageSettingsResponses[keyof GetImageSettingsResponses];
|
|
792
|
+
type UpdateImageSettingsData = {
|
|
793
|
+
body: UpdateImageSettingsBody;
|
|
794
|
+
path?: never;
|
|
795
|
+
query?: never;
|
|
796
|
+
url: "/image-settings";
|
|
797
|
+
};
|
|
798
|
+
type UpdateImageSettingsErrors = {
|
|
799
|
+
/**
|
|
800
|
+
* Invalid request body, or the character was enabled without a character photo
|
|
801
|
+
*/
|
|
802
|
+
400: ApiError;
|
|
803
|
+
/**
|
|
804
|
+
* Invalid or missing API key
|
|
805
|
+
*/
|
|
806
|
+
401: ApiError;
|
|
807
|
+
/**
|
|
808
|
+
* API key lacks the required scope
|
|
809
|
+
*/
|
|
810
|
+
403: ApiError;
|
|
811
|
+
};
|
|
812
|
+
type UpdateImageSettingsError = UpdateImageSettingsErrors[keyof UpdateImageSettingsErrors];
|
|
813
|
+
type UpdateImageSettingsResponses = {
|
|
814
|
+
/**
|
|
815
|
+
* Image settings updated
|
|
816
|
+
*/
|
|
817
|
+
200: ImageSettingsResponse;
|
|
818
|
+
};
|
|
819
|
+
type UpdateImageSettingsResponse = UpdateImageSettingsResponses[keyof UpdateImageSettingsResponses];
|
|
616
820
|
/**
|
|
617
821
|
* Event payload
|
|
618
822
|
*/
|
|
@@ -682,6 +886,26 @@ declare class Articles {
|
|
|
682
886
|
* Update editable fields on an article — currently `content` and `metaDescription`. Send only the fields you want to change. Returns the full updated article.
|
|
683
887
|
*/
|
|
684
888
|
static updateArticle<ThrowOnError extends boolean = false>(options: Options<UpdateArticleData, ThrowOnError>): RequestResult<UpdateArticleResponses, UpdateArticleErrors, ThrowOnError, "fields">;
|
|
889
|
+
/**
|
|
890
|
+
* Generate article images
|
|
891
|
+
*
|
|
892
|
+
* 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.
|
|
893
|
+
*/
|
|
894
|
+
static generateArticleImages<ThrowOnError extends boolean = false>(options: Options<GenerateArticleImagesData, ThrowOnError>): RequestResult<GenerateArticleImagesResponses, GenerateArticleImagesErrors, ThrowOnError, "fields">;
|
|
895
|
+
}
|
|
896
|
+
declare class Images {
|
|
897
|
+
/**
|
|
898
|
+
* Get image settings
|
|
899
|
+
*
|
|
900
|
+
* 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.
|
|
901
|
+
*/
|
|
902
|
+
static getImageSettings<ThrowOnError extends boolean = false>(options?: Options<GetImageSettingsData, ThrowOnError>): RequestResult<GetImageSettingsResponses, GetImageSettingsErrors, ThrowOnError, "fields">;
|
|
903
|
+
/**
|
|
904
|
+
* Update image settings
|
|
905
|
+
*
|
|
906
|
+
* 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.
|
|
907
|
+
*/
|
|
908
|
+
static updateImageSettings<ThrowOnError extends boolean = false>(options: Options<UpdateImageSettingsData, ThrowOnError>): RequestResult<UpdateImageSettingsResponses, UpdateImageSettingsErrors, ThrowOnError, "fields">;
|
|
685
909
|
}
|
|
686
910
|
|
|
687
911
|
interface ArticlesQOptions {
|
|
@@ -719,6 +943,11 @@ declare class ArticlesQ {
|
|
|
719
943
|
* key is scoped to.
|
|
720
944
|
*/
|
|
721
945
|
readonly articles: ReturnType<typeof createArticlesNamespace>;
|
|
946
|
+
/**
|
|
947
|
+
* The project's image settings: style, logo, character and brand notes
|
|
948
|
+
* that ArticlesQ adds to every generated image.
|
|
949
|
+
*/
|
|
950
|
+
readonly imageSettings: ReturnType<typeof createImageSettingsNamespace>;
|
|
722
951
|
constructor(options: ArticlesQOptions);
|
|
723
952
|
}
|
|
724
953
|
declare function createArticlesNamespace(client: Client): {
|
|
@@ -780,6 +1009,51 @@ declare function createArticlesNamespace(client: Client): {
|
|
|
780
1009
|
request?: Request;
|
|
781
1010
|
response?: Response;
|
|
782
1011
|
}>;
|
|
1012
|
+
/**
|
|
1013
|
+
* Generate the cover and in-content images for an article from your
|
|
1014
|
+
* prompts. Wraps `Articles.generateArticleImages`.
|
|
1015
|
+
*
|
|
1016
|
+
* Put `{{IMAGE_1}}`, `{{IMAGE_2}}`, ... in the content where each image
|
|
1017
|
+
* belongs, then send one prompt per marker. The project's image style,
|
|
1018
|
+
* logo, character and brand notes are added automatically.
|
|
1019
|
+
*/
|
|
1020
|
+
generateImages: (slug: string, body: GenerateArticleImagesData["body"]) => Promise<({
|
|
1021
|
+
data: ArticleImagesResponse;
|
|
1022
|
+
error: undefined;
|
|
1023
|
+
} | {
|
|
1024
|
+
data: undefined;
|
|
1025
|
+
error: ApiError;
|
|
1026
|
+
}) & {
|
|
1027
|
+
request?: Request;
|
|
1028
|
+
response?: Response;
|
|
1029
|
+
}>;
|
|
1030
|
+
};
|
|
1031
|
+
declare function createImageSettingsNamespace(client: Client): {
|
|
1032
|
+
/** Read the project's image settings. Wraps `Images.getImageSettings`. */
|
|
1033
|
+
get: () => Promise<({
|
|
1034
|
+
data: ImageSettingsResponse;
|
|
1035
|
+
error: undefined;
|
|
1036
|
+
} | {
|
|
1037
|
+
data: undefined;
|
|
1038
|
+
error: ApiError;
|
|
1039
|
+
}) & {
|
|
1040
|
+
request?: Request;
|
|
1041
|
+
response?: Response;
|
|
1042
|
+
}>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Update the image style, the logo/character toggles or the brand notes.
|
|
1045
|
+
* Wraps `Images.updateImageSettings`.
|
|
1046
|
+
*/
|
|
1047
|
+
update: (body: UpdateImageSettingsData["body"]) => Promise<({
|
|
1048
|
+
data: ImageSettingsResponse;
|
|
1049
|
+
error: undefined;
|
|
1050
|
+
} | {
|
|
1051
|
+
data: undefined;
|
|
1052
|
+
error: ApiError;
|
|
1053
|
+
}) & {
|
|
1054
|
+
request?: Request;
|
|
1055
|
+
response?: Response;
|
|
1056
|
+
}>;
|
|
783
1057
|
};
|
|
784
1058
|
|
|
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 };
|
|
1059
|
+
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 };
|