katanakit-js 3.1.3 → 3.2.2
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/README.md +559 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/notion/index.d.ts +3 -0
- package/dist/adapters/notion/index.d.ts.map +1 -0
- package/dist/adapters/notion/index.js +2 -0
- package/dist/adapters/notion/index.js.map +1 -0
- package/dist/adapters/notion/notion.service.d.ts +397 -0
- package/dist/adapters/notion/notion.service.d.ts.map +1 -0
- package/dist/adapters/notion/notion.service.js +604 -0
- package/dist/adapters/notion/notion.service.js.map +1 -0
- package/dist/adapters/wordpress/index.d.ts +3 -0
- package/dist/adapters/wordpress/index.d.ts.map +1 -0
- package/dist/adapters/wordpress/index.js +2 -0
- package/dist/adapters/wordpress/index.js.map +1 -0
- package/dist/adapters/wordpress/wordpress.service.d.ts +685 -0
- package/dist/adapters/wordpress/wordpress.service.d.ts.map +1 -0
- package/dist/adapters/wordpress/wordpress.service.js +1100 -0
- package/dist/adapters/wordpress/wordpress.service.js.map +1 -0
- package/dist/types/index.d.ts +767 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +14 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -661,4 +661,771 @@ export type ProductType = {
|
|
|
661
661
|
name: string;
|
|
662
662
|
price: number;
|
|
663
663
|
};
|
|
664
|
+
/** Configuration for the Notion API integration. */
|
|
665
|
+
export interface NotionConfig {
|
|
666
|
+
/** Notion integration token (starts with "ntn_" or "secret_"). */
|
|
667
|
+
token: string;
|
|
668
|
+
/** API version header (default: "2022-06-28"). */
|
|
669
|
+
apiVersion?: string;
|
|
670
|
+
/** Custom base URL (default: "https://api.notion.com/v1"). */
|
|
671
|
+
apiBaseUrl?: string;
|
|
672
|
+
}
|
|
673
|
+
/** Rich text object used in Notion blocks and properties. */
|
|
674
|
+
export interface NotionRichText {
|
|
675
|
+
type: "text";
|
|
676
|
+
text: {
|
|
677
|
+
content: string;
|
|
678
|
+
link?: {
|
|
679
|
+
url: string;
|
|
680
|
+
} | null;
|
|
681
|
+
};
|
|
682
|
+
annotations?: {
|
|
683
|
+
bold?: boolean;
|
|
684
|
+
italic?: boolean;
|
|
685
|
+
strikethrough?: boolean;
|
|
686
|
+
underline?: boolean;
|
|
687
|
+
code?: boolean;
|
|
688
|
+
color?: string;
|
|
689
|
+
};
|
|
690
|
+
plain_text?: string;
|
|
691
|
+
href?: string | null;
|
|
692
|
+
}
|
|
693
|
+
/** A Notion page object. */
|
|
694
|
+
export interface NotionPage {
|
|
695
|
+
object: "page";
|
|
696
|
+
id: string;
|
|
697
|
+
created_time: string;
|
|
698
|
+
last_edited_time: string;
|
|
699
|
+
created_by: {
|
|
700
|
+
object: "user";
|
|
701
|
+
id: string;
|
|
702
|
+
};
|
|
703
|
+
last_edited_by: {
|
|
704
|
+
object: "user";
|
|
705
|
+
id: string;
|
|
706
|
+
};
|
|
707
|
+
parent: NotionParent;
|
|
708
|
+
archived: boolean;
|
|
709
|
+
url: string;
|
|
710
|
+
properties: Record<string, NotionProperty>;
|
|
711
|
+
icon?: NotionIcon | null;
|
|
712
|
+
cover?: NotionCover | null;
|
|
713
|
+
}
|
|
714
|
+
/** Parent reference for pages and databases. */
|
|
715
|
+
export type NotionParent = {
|
|
716
|
+
type: "database_id";
|
|
717
|
+
database_id: string;
|
|
718
|
+
} | {
|
|
719
|
+
type: "page_id";
|
|
720
|
+
page_id: string;
|
|
721
|
+
} | {
|
|
722
|
+
type: "workspace";
|
|
723
|
+
workspace: true;
|
|
724
|
+
};
|
|
725
|
+
/** Property value on a Notion page. */
|
|
726
|
+
export interface NotionProperty {
|
|
727
|
+
id?: string;
|
|
728
|
+
type: string;
|
|
729
|
+
title?: NotionRichText[];
|
|
730
|
+
rich_text?: NotionRichText[];
|
|
731
|
+
number?: number;
|
|
732
|
+
select?: {
|
|
733
|
+
id: string;
|
|
734
|
+
name: string;
|
|
735
|
+
color?: string;
|
|
736
|
+
} | null;
|
|
737
|
+
multi_select?: Array<{
|
|
738
|
+
id: string;
|
|
739
|
+
name: string;
|
|
740
|
+
color?: string;
|
|
741
|
+
}>;
|
|
742
|
+
date?: {
|
|
743
|
+
start: string;
|
|
744
|
+
end?: string | null;
|
|
745
|
+
} | null;
|
|
746
|
+
checkbox?: boolean;
|
|
747
|
+
url?: string | null;
|
|
748
|
+
email?: string | null;
|
|
749
|
+
phone_number?: string | null;
|
|
750
|
+
formula?: {
|
|
751
|
+
type: string;
|
|
752
|
+
string?: string;
|
|
753
|
+
number?: number;
|
|
754
|
+
boolean?: boolean;
|
|
755
|
+
};
|
|
756
|
+
relation?: Array<{
|
|
757
|
+
id: string;
|
|
758
|
+
}>;
|
|
759
|
+
rollup?: {
|
|
760
|
+
type: string;
|
|
761
|
+
number?: number;
|
|
762
|
+
};
|
|
763
|
+
status?: {
|
|
764
|
+
id: string;
|
|
765
|
+
name: string;
|
|
766
|
+
color?: string;
|
|
767
|
+
} | null;
|
|
768
|
+
[key: string]: unknown;
|
|
769
|
+
}
|
|
770
|
+
/** Icon on a page or database (emoji or file). */
|
|
771
|
+
export type NotionIcon = {
|
|
772
|
+
type: "emoji";
|
|
773
|
+
emoji: string;
|
|
774
|
+
} | {
|
|
775
|
+
type: "file";
|
|
776
|
+
file: {
|
|
777
|
+
url: string;
|
|
778
|
+
};
|
|
779
|
+
};
|
|
780
|
+
/** Cover image on a page. */
|
|
781
|
+
export type NotionCover = {
|
|
782
|
+
type: "external";
|
|
783
|
+
external: {
|
|
784
|
+
url: string;
|
|
785
|
+
};
|
|
786
|
+
} | {
|
|
787
|
+
type: "file";
|
|
788
|
+
file: {
|
|
789
|
+
url: string;
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
/** A Notion block object. */
|
|
793
|
+
export interface NotionBlock {
|
|
794
|
+
object: "block";
|
|
795
|
+
id: string;
|
|
796
|
+
type: string;
|
|
797
|
+
created_time?: string;
|
|
798
|
+
last_edited_time?: string;
|
|
799
|
+
has_children?: boolean;
|
|
800
|
+
archived?: boolean;
|
|
801
|
+
[key: string]: unknown;
|
|
802
|
+
}
|
|
803
|
+
/** Result of listing block children (paginated). */
|
|
804
|
+
export interface NotionBlockList {
|
|
805
|
+
object: "list";
|
|
806
|
+
results: NotionBlock[];
|
|
807
|
+
has_more: boolean;
|
|
808
|
+
next_cursor: string | null;
|
|
809
|
+
type: "block";
|
|
810
|
+
block: Record<string, unknown>;
|
|
811
|
+
}
|
|
812
|
+
/** A Notion database object. */
|
|
813
|
+
export interface NotionDatabase {
|
|
814
|
+
object: "database";
|
|
815
|
+
id: string;
|
|
816
|
+
created_time: string;
|
|
817
|
+
last_edited_time: string;
|
|
818
|
+
title: NotionRichText[];
|
|
819
|
+
description: NotionRichText[];
|
|
820
|
+
parent: NotionParent;
|
|
821
|
+
url: string;
|
|
822
|
+
icon?: NotionIcon | null;
|
|
823
|
+
cover?: NotionCover | null;
|
|
824
|
+
properties: Record<string, NotionPropertySchema>;
|
|
825
|
+
archived?: boolean;
|
|
826
|
+
}
|
|
827
|
+
/** Schema definition for a database property. */
|
|
828
|
+
export interface NotionPropertySchema {
|
|
829
|
+
id?: string;
|
|
830
|
+
name?: string;
|
|
831
|
+
type: string;
|
|
832
|
+
[key: string]: unknown;
|
|
833
|
+
}
|
|
834
|
+
/** Filter for querying a Notion database. */
|
|
835
|
+
export interface NotionFilter {
|
|
836
|
+
and?: NotionFilter[];
|
|
837
|
+
or?: NotionFilter[];
|
|
838
|
+
property?: string;
|
|
839
|
+
[key: string]: unknown;
|
|
840
|
+
}
|
|
841
|
+
/** Sort option for querying a Notion database. */
|
|
842
|
+
export interface NotionSort {
|
|
843
|
+
property?: string;
|
|
844
|
+
timestamp?: "created_time" | "last_edited_time";
|
|
845
|
+
direction: "ascending" | "descending";
|
|
846
|
+
}
|
|
847
|
+
/** Query options for a Notion database. */
|
|
848
|
+
export interface NotionDatabaseQuery {
|
|
849
|
+
filter?: NotionFilter;
|
|
850
|
+
sorts?: NotionSort[];
|
|
851
|
+
start_cursor?: string;
|
|
852
|
+
page_size?: number;
|
|
853
|
+
}
|
|
854
|
+
/** Result of querying a Notion database (paginated). */
|
|
855
|
+
export interface NotionPageList {
|
|
856
|
+
object: "list";
|
|
857
|
+
results: NotionPage[];
|
|
858
|
+
has_more: boolean;
|
|
859
|
+
next_cursor: string | null;
|
|
860
|
+
type: "page";
|
|
861
|
+
page: Record<string, unknown>;
|
|
862
|
+
}
|
|
863
|
+
/** A Notion user object. */
|
|
864
|
+
export interface NotionUser {
|
|
865
|
+
object: "user";
|
|
866
|
+
id: string;
|
|
867
|
+
type: "person" | "bot";
|
|
868
|
+
name?: string;
|
|
869
|
+
avatar_url?: string;
|
|
870
|
+
person?: {
|
|
871
|
+
email?: string;
|
|
872
|
+
};
|
|
873
|
+
bot?: {
|
|
874
|
+
owner: {
|
|
875
|
+
type: string;
|
|
876
|
+
};
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
/** Paginated list of Notion users. */
|
|
880
|
+
export interface NotionUserList {
|
|
881
|
+
object: "list";
|
|
882
|
+
results: NotionUser[];
|
|
883
|
+
has_more: boolean;
|
|
884
|
+
next_cursor: string | null;
|
|
885
|
+
}
|
|
886
|
+
/** Search query options for the Notion API. */
|
|
887
|
+
export interface NotionSearchQuery {
|
|
888
|
+
query?: string;
|
|
889
|
+
filter?: {
|
|
890
|
+
value: "database" | "page";
|
|
891
|
+
property: "object";
|
|
892
|
+
};
|
|
893
|
+
sort?: {
|
|
894
|
+
direction: "ascending" | "descending";
|
|
895
|
+
timestamp: "last_edited_time";
|
|
896
|
+
};
|
|
897
|
+
start_cursor?: string;
|
|
898
|
+
page_size?: number;
|
|
899
|
+
}
|
|
900
|
+
/** Result of a Notion search (paginated). */
|
|
901
|
+
export interface NotionSearchResult {
|
|
902
|
+
object: "list";
|
|
903
|
+
results: Array<NotionPage | NotionDatabase>;
|
|
904
|
+
has_more: boolean;
|
|
905
|
+
next_cursor: string | null;
|
|
906
|
+
}
|
|
907
|
+
/** Contract of the Notion adapter facade. */
|
|
908
|
+
export interface INotionService {
|
|
909
|
+
useInitNotion(config: NotionConfig): void;
|
|
910
|
+
useNotionGetPage(pageId: string): Promise<FetchResult<NotionPage>>;
|
|
911
|
+
useNotionCreatePage(parent: NotionParent, properties: Record<string, unknown>, children?: unknown[]): Promise<FetchResult<NotionPage>>;
|
|
912
|
+
useNotionUpdatePage(pageId: string, properties: Record<string, unknown>): Promise<FetchResult<NotionPage>>;
|
|
913
|
+
useNotionArchivePage(pageId: string): Promise<FetchResult<NotionPage>>;
|
|
914
|
+
useNotionGetBlock(blockId: string): Promise<FetchResult<NotionBlock>>;
|
|
915
|
+
useNotionGetBlockChildren(blockId: string, options?: {
|
|
916
|
+
start_cursor?: string;
|
|
917
|
+
page_size?: number;
|
|
918
|
+
}): Promise<FetchResult<NotionBlockList>>;
|
|
919
|
+
useNotionAppendBlocks(blockId: string, children: unknown[]): Promise<FetchResult<NotionBlock>>;
|
|
920
|
+
useNotionUpdateBlock(blockId: string, content: Record<string, unknown>): Promise<FetchResult<NotionBlock>>;
|
|
921
|
+
useNotionDeleteBlock(blockId: string): Promise<FetchResult<NotionBlock>>;
|
|
922
|
+
useNotionGetDatabase(databaseId: string): Promise<FetchResult<NotionDatabase>>;
|
|
923
|
+
useNotionQueryDatabase(databaseId: string, query?: NotionDatabaseQuery): Promise<FetchResult<NotionPageList>>;
|
|
924
|
+
useNotionCreateDatabase(parent: NotionParent, title: NotionRichText[], properties: Record<string, NotionPropertySchema>): Promise<FetchResult<NotionDatabase>>;
|
|
925
|
+
useNotionUpdateDatabase(databaseId: string, title: NotionRichText[], properties?: Record<string, NotionPropertySchema>): Promise<FetchResult<NotionDatabase>>;
|
|
926
|
+
useNotionGetUser(userId: string): Promise<FetchResult<NotionUser>>;
|
|
927
|
+
useNotionListUsers(options?: {
|
|
928
|
+
start_cursor?: string;
|
|
929
|
+
page_size?: number;
|
|
930
|
+
}): Promise<FetchResult<NotionUserList>>;
|
|
931
|
+
useNotionSearchContent(query: NotionSearchQuery): Promise<FetchResult<NotionSearchResult>>;
|
|
932
|
+
useNotionListAllBlockChildren(blockId: string): Promise<FetchResult<NotionBlock[]>>;
|
|
933
|
+
useNotionListAllDatabasePages(databaseId: string, filter?: NotionFilter, sorts?: NotionSort[]): Promise<FetchResult<NotionPage[]>>;
|
|
934
|
+
}
|
|
935
|
+
/** Configuration for the WordPress REST API integration. */
|
|
936
|
+
export interface WordPressConfig {
|
|
937
|
+
/** WordPress site base URL (e.g. "https://mysite.com"). */
|
|
938
|
+
baseUrl: string;
|
|
939
|
+
/** Authentication credentials (choose one method). */
|
|
940
|
+
auth?: WordPressAuth;
|
|
941
|
+
/** Custom API namespace (default: "wp/v2"). */
|
|
942
|
+
apiNamespace?: string;
|
|
943
|
+
}
|
|
944
|
+
/** Authentication methods for WordPress. */
|
|
945
|
+
export type WordPressAuth = {
|
|
946
|
+
type: "application-passwords";
|
|
947
|
+
username: string;
|
|
948
|
+
password: string;
|
|
949
|
+
} | {
|
|
950
|
+
type: "jwt";
|
|
951
|
+
token: string;
|
|
952
|
+
} | {
|
|
953
|
+
type: "basic";
|
|
954
|
+
username: string;
|
|
955
|
+
password: string;
|
|
956
|
+
} | {
|
|
957
|
+
type: "nonce";
|
|
958
|
+
nonce: string;
|
|
959
|
+
cookie: string;
|
|
960
|
+
};
|
|
961
|
+
/** Base fields shared by all WordPress entities. */
|
|
962
|
+
export interface WpBaseEntity {
|
|
963
|
+
id: number;
|
|
964
|
+
date: string;
|
|
965
|
+
date_gmt: string;
|
|
966
|
+
modified: string;
|
|
967
|
+
modified_gmt: string;
|
|
968
|
+
slug: string;
|
|
969
|
+
status: string;
|
|
970
|
+
link: string;
|
|
971
|
+
}
|
|
972
|
+
/** A WordPress post. */
|
|
973
|
+
export interface WpPost extends WpBaseEntity {
|
|
974
|
+
title: {
|
|
975
|
+
rendered: string;
|
|
976
|
+
};
|
|
977
|
+
content: {
|
|
978
|
+
rendered: string;
|
|
979
|
+
protected: boolean;
|
|
980
|
+
};
|
|
981
|
+
excerpt: {
|
|
982
|
+
rendered: string;
|
|
983
|
+
protected: boolean;
|
|
984
|
+
};
|
|
985
|
+
author: number;
|
|
986
|
+
featured_media: number;
|
|
987
|
+
comment_status: string;
|
|
988
|
+
ping_status: string;
|
|
989
|
+
sticky: boolean;
|
|
990
|
+
template: string;
|
|
991
|
+
format: string;
|
|
992
|
+
categories: number[];
|
|
993
|
+
tags: number[];
|
|
994
|
+
meta: Record<string, unknown>;
|
|
995
|
+
/** ACF (Advanced Custom Fields) data. Available when using ACF plugin. */
|
|
996
|
+
acf?: WpAcfFields;
|
|
997
|
+
/** Embedded resources (author, featured media, terms). Available when using `_embed`. */
|
|
998
|
+
_embedded?: WpEmbedded;
|
|
999
|
+
}
|
|
1000
|
+
/** Payload for creating a WordPress post. */
|
|
1001
|
+
export interface WpPostCreate {
|
|
1002
|
+
title: string;
|
|
1003
|
+
content?: string;
|
|
1004
|
+
excerpt?: string;
|
|
1005
|
+
author?: number;
|
|
1006
|
+
featured_media?: number;
|
|
1007
|
+
comment_status?: "open" | "closed";
|
|
1008
|
+
ping_status?: "open" | "closed";
|
|
1009
|
+
sticky?: boolean;
|
|
1010
|
+
format?: string;
|
|
1011
|
+
categories?: number[];
|
|
1012
|
+
tags?: number[];
|
|
1013
|
+
meta?: Record<string, unknown>;
|
|
1014
|
+
status?: "publish" | "future" | "draft" | "pending" | "private";
|
|
1015
|
+
slug?: string;
|
|
1016
|
+
date?: string;
|
|
1017
|
+
template?: string;
|
|
1018
|
+
}
|
|
1019
|
+
/** Payload for updating a WordPress post. */
|
|
1020
|
+
export type WpPostUpdate = Partial<WpPostCreate>;
|
|
1021
|
+
/** A WordPress page. */
|
|
1022
|
+
export interface WpPage extends WpBaseEntity {
|
|
1023
|
+
title: {
|
|
1024
|
+
rendered: string;
|
|
1025
|
+
};
|
|
1026
|
+
content: {
|
|
1027
|
+
rendered: string;
|
|
1028
|
+
protected: boolean;
|
|
1029
|
+
};
|
|
1030
|
+
excerpt: {
|
|
1031
|
+
rendered: string;
|
|
1032
|
+
protected: boolean;
|
|
1033
|
+
};
|
|
1034
|
+
author: number;
|
|
1035
|
+
featured_media: number;
|
|
1036
|
+
parent: number;
|
|
1037
|
+
menu_order: number;
|
|
1038
|
+
comment_status: string;
|
|
1039
|
+
ping_status: string;
|
|
1040
|
+
template: string;
|
|
1041
|
+
meta: Record<string, unknown>;
|
|
1042
|
+
/** ACF (Advanced Custom Fields) data. Available when using ACF plugin. */
|
|
1043
|
+
acf?: WpAcfFields;
|
|
1044
|
+
/** Embedded resources (author, featured media). Available when using `_embed`. */
|
|
1045
|
+
_embedded?: WpEmbedded;
|
|
1046
|
+
}
|
|
1047
|
+
/** Payload for creating a WordPress page. */
|
|
1048
|
+
export interface WpPageCreate {
|
|
1049
|
+
title: string;
|
|
1050
|
+
content?: string;
|
|
1051
|
+
excerpt?: string;
|
|
1052
|
+
author?: number;
|
|
1053
|
+
featured_media?: number;
|
|
1054
|
+
parent?: number;
|
|
1055
|
+
menu_order?: number;
|
|
1056
|
+
comment_status?: "open" | "closed";
|
|
1057
|
+
ping_status?: "open" | "closed";
|
|
1058
|
+
status?: "publish" | "future" | "draft" | "pending" | "private";
|
|
1059
|
+
slug?: string;
|
|
1060
|
+
date?: string;
|
|
1061
|
+
template?: string;
|
|
1062
|
+
meta?: Record<string, unknown>;
|
|
1063
|
+
}
|
|
1064
|
+
/** Payload for updating a WordPress page. */
|
|
1065
|
+
export type WpPageUpdate = Partial<WpPageCreate>;
|
|
1066
|
+
/** A WordPress media item (attachment). */
|
|
1067
|
+
export interface WpMedia extends WpBaseEntity {
|
|
1068
|
+
title: {
|
|
1069
|
+
rendered: string;
|
|
1070
|
+
};
|
|
1071
|
+
author: number;
|
|
1072
|
+
media_type: string;
|
|
1073
|
+
mime_type: string;
|
|
1074
|
+
media_details: {
|
|
1075
|
+
width?: number;
|
|
1076
|
+
height?: number;
|
|
1077
|
+
file?: string;
|
|
1078
|
+
/** File size in bytes. */
|
|
1079
|
+
filesize?: number;
|
|
1080
|
+
/** Image metadata from EXIF data. */
|
|
1081
|
+
image_meta?: {
|
|
1082
|
+
aperture?: string;
|
|
1083
|
+
credit?: string;
|
|
1084
|
+
camera?: string;
|
|
1085
|
+
caption?: string;
|
|
1086
|
+
created_timestamp?: string;
|
|
1087
|
+
copyright?: string;
|
|
1088
|
+
focal_length?: string;
|
|
1089
|
+
iso?: string;
|
|
1090
|
+
orientation?: string;
|
|
1091
|
+
shutter_speed?: string;
|
|
1092
|
+
title?: string;
|
|
1093
|
+
[key: string]: unknown;
|
|
1094
|
+
};
|
|
1095
|
+
sizes?: Record<string, {
|
|
1096
|
+
source_url: string;
|
|
1097
|
+
file: string;
|
|
1098
|
+
width: number;
|
|
1099
|
+
height: number;
|
|
1100
|
+
mime_type: string;
|
|
1101
|
+
filesize?: number;
|
|
1102
|
+
}>;
|
|
1103
|
+
};
|
|
1104
|
+
source_url: string;
|
|
1105
|
+
alt_text: string;
|
|
1106
|
+
caption: {
|
|
1107
|
+
rendered: string;
|
|
1108
|
+
};
|
|
1109
|
+
description: {
|
|
1110
|
+
rendered: string;
|
|
1111
|
+
};
|
|
1112
|
+
post: number | null;
|
|
1113
|
+
meta: Record<string, unknown>;
|
|
1114
|
+
/** ACF (Advanced Custom Fields) data. Available when using ACF plugin. */
|
|
1115
|
+
acf?: WpAcfFields;
|
|
1116
|
+
/** Embedded resources (author, post). Available when using `_embed`. */
|
|
1117
|
+
_embedded?: WpEmbedded;
|
|
1118
|
+
}
|
|
1119
|
+
/** Metadata for a media upload. */
|
|
1120
|
+
export interface WpMediaMeta {
|
|
1121
|
+
title?: string;
|
|
1122
|
+
alt_text?: string;
|
|
1123
|
+
caption?: string;
|
|
1124
|
+
description?: string;
|
|
1125
|
+
post?: number;
|
|
1126
|
+
slug?: string;
|
|
1127
|
+
}
|
|
1128
|
+
/** Payload for updating a WordPress media item. */
|
|
1129
|
+
export interface WpMediaUpdate extends Partial<WpMediaMeta> {
|
|
1130
|
+
status?: string;
|
|
1131
|
+
}
|
|
1132
|
+
/** A WordPress category. */
|
|
1133
|
+
export interface WpCategory {
|
|
1134
|
+
id: number;
|
|
1135
|
+
count: number;
|
|
1136
|
+
description: string;
|
|
1137
|
+
link: string;
|
|
1138
|
+
name: string;
|
|
1139
|
+
slug: string;
|
|
1140
|
+
parent: number;
|
|
1141
|
+
meta: Record<string, unknown>;
|
|
1142
|
+
}
|
|
1143
|
+
/** Payload for creating a WordPress category. */
|
|
1144
|
+
export interface WpCategoryCreate {
|
|
1145
|
+
name: string;
|
|
1146
|
+
description?: string;
|
|
1147
|
+
slug?: string;
|
|
1148
|
+
parent?: number;
|
|
1149
|
+
meta?: Record<string, unknown>;
|
|
1150
|
+
}
|
|
1151
|
+
/** Payload for updating a WordPress category. */
|
|
1152
|
+
export type WpCategoryUpdate = Partial<WpCategoryCreate>;
|
|
1153
|
+
/** A WordPress tag. */
|
|
1154
|
+
export interface WpTag {
|
|
1155
|
+
id: number;
|
|
1156
|
+
count: number;
|
|
1157
|
+
description: string;
|
|
1158
|
+
link: string;
|
|
1159
|
+
name: string;
|
|
1160
|
+
slug: string;
|
|
1161
|
+
meta: Record<string, unknown>;
|
|
1162
|
+
}
|
|
1163
|
+
/** Payload for creating a WordPress tag. */
|
|
1164
|
+
export interface WpTagCreate {
|
|
1165
|
+
name: string;
|
|
1166
|
+
description?: string;
|
|
1167
|
+
slug?: string;
|
|
1168
|
+
meta?: Record<string, unknown>;
|
|
1169
|
+
}
|
|
1170
|
+
/** Payload for updating a WordPress tag. */
|
|
1171
|
+
export type WpTagUpdate = Partial<WpTagCreate>;
|
|
1172
|
+
/** A WordPress comment. */
|
|
1173
|
+
export interface WpComment {
|
|
1174
|
+
id: number;
|
|
1175
|
+
post: number;
|
|
1176
|
+
parent: number;
|
|
1177
|
+
author: number;
|
|
1178
|
+
author_name: string;
|
|
1179
|
+
author_email: string;
|
|
1180
|
+
author_url: string;
|
|
1181
|
+
date: string;
|
|
1182
|
+
date_gmt: string;
|
|
1183
|
+
content: {
|
|
1184
|
+
rendered: string;
|
|
1185
|
+
};
|
|
1186
|
+
link: string;
|
|
1187
|
+
status: string;
|
|
1188
|
+
type: string;
|
|
1189
|
+
author_avatar_urls: Record<string, string>;
|
|
1190
|
+
meta: Record<string, unknown>;
|
|
1191
|
+
}
|
|
1192
|
+
/** Payload for creating a WordPress comment. */
|
|
1193
|
+
export interface WpCommentCreate {
|
|
1194
|
+
post: number;
|
|
1195
|
+
parent?: number;
|
|
1196
|
+
content: string;
|
|
1197
|
+
author?: number;
|
|
1198
|
+
author_name?: string;
|
|
1199
|
+
author_email?: string;
|
|
1200
|
+
author_url?: string;
|
|
1201
|
+
status?: string;
|
|
1202
|
+
meta?: Record<string, unknown>;
|
|
1203
|
+
}
|
|
1204
|
+
/** Payload for updating a WordPress comment. */
|
|
1205
|
+
export type WpCommentUpdate = Partial<WpCommentCreate>;
|
|
1206
|
+
/** A WordPress user. */
|
|
1207
|
+
export interface WpUser {
|
|
1208
|
+
id: number;
|
|
1209
|
+
username: string;
|
|
1210
|
+
name: string;
|
|
1211
|
+
first_name: string;
|
|
1212
|
+
last_name: string;
|
|
1213
|
+
email: string;
|
|
1214
|
+
url: string;
|
|
1215
|
+
description: string;
|
|
1216
|
+
link: string;
|
|
1217
|
+
locale: string;
|
|
1218
|
+
nickname: string;
|
|
1219
|
+
slug: string;
|
|
1220
|
+
roles: string[];
|
|
1221
|
+
avatar_urls: Record<string, string>;
|
|
1222
|
+
meta: Record<string, unknown>;
|
|
1223
|
+
}
|
|
1224
|
+
/** Payload for creating a WordPress user. */
|
|
1225
|
+
export interface WpUserCreate {
|
|
1226
|
+
username: string;
|
|
1227
|
+
name?: string;
|
|
1228
|
+
first_name?: string;
|
|
1229
|
+
last_name?: string;
|
|
1230
|
+
email: string;
|
|
1231
|
+
url?: string;
|
|
1232
|
+
description?: string;
|
|
1233
|
+
locale?: string;
|
|
1234
|
+
nickname?: string;
|
|
1235
|
+
slug?: string;
|
|
1236
|
+
roles?: string[];
|
|
1237
|
+
password?: string;
|
|
1238
|
+
meta?: Record<string, unknown>;
|
|
1239
|
+
}
|
|
1240
|
+
/** Payload for updating a WordPress user. */
|
|
1241
|
+
export type WpUserUpdate = Partial<WpUserCreate>;
|
|
1242
|
+
/** Common query parameters for WordPress REST API list endpoints. */
|
|
1243
|
+
export interface WpQueryParams {
|
|
1244
|
+
/** Current page (default: 1). */
|
|
1245
|
+
page?: number;
|
|
1246
|
+
/** Items per page (default: 10, max: 100). */
|
|
1247
|
+
per_page?: number;
|
|
1248
|
+
/** Search term. */
|
|
1249
|
+
search?: string;
|
|
1250
|
+
/** Sort order. */
|
|
1251
|
+
order?: "asc" | "desc";
|
|
1252
|
+
/** Order by field. */
|
|
1253
|
+
orderby?: string;
|
|
1254
|
+
/** Offset for pagination. */
|
|
1255
|
+
offset?: number;
|
|
1256
|
+
/** Include specific IDs. */
|
|
1257
|
+
include?: number[];
|
|
1258
|
+
/** Exclude specific IDs. */
|
|
1259
|
+
exclude?: number[];
|
|
1260
|
+
/** Filter by slug. */
|
|
1261
|
+
slug?: string;
|
|
1262
|
+
/** Filter by status. */
|
|
1263
|
+
status?: string | string[];
|
|
1264
|
+
/** Filter by author. */
|
|
1265
|
+
author?: number | number[];
|
|
1266
|
+
/** Filter by categories. */
|
|
1267
|
+
categories?: number | number[];
|
|
1268
|
+
/** Filter by tags. */
|
|
1269
|
+
tags?: number | number[];
|
|
1270
|
+
/**
|
|
1271
|
+
* Limit response fields to reduce payload size.
|
|
1272
|
+
* Use comma-separated field names: "id,title,link" or nested: "id,title.rendered,acf.custom_field".
|
|
1273
|
+
* Reduces response size by 60-80% — essential for list views.
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```ts
|
|
1277
|
+
* useWpGetPosts({ _fields: "id,title,link,slug,date" });
|
|
1278
|
+
* useWpGetPosts({ _fields: "id,title.rendered,acf.hero_image,acf.subtitle" }); // with ACF
|
|
1279
|
+
* ```
|
|
1280
|
+
*/
|
|
1281
|
+
_fields?: string;
|
|
1282
|
+
/**
|
|
1283
|
+
* Embed related resources in the response (author, featured media, terms, replies).
|
|
1284
|
+
* Accepts `true` to embed all, or comma-separated resource names.
|
|
1285
|
+
*
|
|
1286
|
+
* @example
|
|
1287
|
+
* ```ts
|
|
1288
|
+
* useWpGetPosts({ _embed: true }); // embed all
|
|
1289
|
+
* useWpGetPosts({ _embed: "author,wp:featuredmedia" }); // embed specific
|
|
1290
|
+
* ```
|
|
1291
|
+
*/
|
|
1292
|
+
_embed?: boolean | string;
|
|
1293
|
+
/** Custom query params. */
|
|
1294
|
+
[key: string]: unknown;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Container for ACF (Advanced Custom Fields) fields on a WordPress entity.
|
|
1298
|
+
*
|
|
1299
|
+
* ACF fields appear on posts, pages, media, taxonomies, users, and options.
|
|
1300
|
+
* Field names and types are defined by the site's ACF configuration.
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* ```ts
|
|
1304
|
+
* const post = await useWpGetPost(42, { _fields: "id,title,acf" });
|
|
1305
|
+
* if (post.ok && post.data.acf) {
|
|
1306
|
+
* console.log(post.data.acf.hero_image); // image field
|
|
1307
|
+
* console.log(post.data.acf.subtitle); // text field
|
|
1308
|
+
* console.log(post.data.acf.gallery); // gallery field (array)
|
|
1309
|
+
* }
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
export interface WpAcfFields {
|
|
1313
|
+
[key: string]: unknown;
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Embedded resources returned by WordPress when `_embed` is used.
|
|
1317
|
+
*
|
|
1318
|
+
* Contains related entities: author, featured media, terms, replies.
|
|
1319
|
+
* Access with `post._embedded?.["wp:featuredmedia"]?.[0]`.
|
|
1320
|
+
*
|
|
1321
|
+
* @example
|
|
1322
|
+
* ```ts
|
|
1323
|
+
* const result = await useWpGetPosts({ _embed: "author,wp:featuredmedia" });
|
|
1324
|
+
* if (result.ok) {
|
|
1325
|
+
* for (const post of result.data) {
|
|
1326
|
+
* const author = post._embedded?.author?.[0]?.name;
|
|
1327
|
+
* const image = post._embedded?.["wp:featuredmedia"]?.[0]?.source_url;
|
|
1328
|
+
* }
|
|
1329
|
+
* }
|
|
1330
|
+
* ```
|
|
1331
|
+
*/
|
|
1332
|
+
export interface WpEmbedded {
|
|
1333
|
+
author?: Array<{
|
|
1334
|
+
id: number;
|
|
1335
|
+
name: string;
|
|
1336
|
+
url: string;
|
|
1337
|
+
description: string;
|
|
1338
|
+
link: string;
|
|
1339
|
+
slug: string;
|
|
1340
|
+
avatar_urls: Record<string, string>;
|
|
1341
|
+
acf?: WpAcfFields;
|
|
1342
|
+
[key: string]: unknown;
|
|
1343
|
+
}>;
|
|
1344
|
+
"wp:featuredmedia"?: WpMedia[];
|
|
1345
|
+
"wp:term"?: Array<Array<{
|
|
1346
|
+
id: number;
|
|
1347
|
+
name: string;
|
|
1348
|
+
slug: string;
|
|
1349
|
+
_taxonomy: string;
|
|
1350
|
+
link: string;
|
|
1351
|
+
count?: number;
|
|
1352
|
+
[key: string]: unknown;
|
|
1353
|
+
}>>;
|
|
1354
|
+
replies?: Array<Array<{
|
|
1355
|
+
id: number;
|
|
1356
|
+
parent: number;
|
|
1357
|
+
author: number;
|
|
1358
|
+
author_name: string;
|
|
1359
|
+
content: {
|
|
1360
|
+
rendered: string;
|
|
1361
|
+
};
|
|
1362
|
+
date: string;
|
|
1363
|
+
[key: string]: unknown;
|
|
1364
|
+
}>>;
|
|
1365
|
+
[key: string]: unknown;
|
|
1366
|
+
}
|
|
1367
|
+
/** A batch operation for the WordPress REST API. */
|
|
1368
|
+
export interface WpBatchOperation {
|
|
1369
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
1370
|
+
path: string;
|
|
1371
|
+
body?: Record<string, unknown>;
|
|
1372
|
+
}
|
|
1373
|
+
/** Result of a WordPress batch operation. */
|
|
1374
|
+
export interface WpBatchResult {
|
|
1375
|
+
/** Responses for each operation in the batch. */
|
|
1376
|
+
responses: Array<{
|
|
1377
|
+
status: number;
|
|
1378
|
+
body: unknown;
|
|
1379
|
+
headers: Record<string, string>;
|
|
1380
|
+
}>;
|
|
1381
|
+
}
|
|
1382
|
+
/** Contract of the WordPress adapter facade. */
|
|
1383
|
+
export interface IWordPressService {
|
|
1384
|
+
useInitWordPress(config: WordPressConfig): void;
|
|
1385
|
+
useWpGetPosts(options?: WpQueryParams): Promise<FetchResult<WpPost[]>>;
|
|
1386
|
+
useWpGetPost(id: number, options?: WpQueryParams): Promise<FetchResult<WpPost>>;
|
|
1387
|
+
useWpCreatePost(data: WpPostCreate): Promise<FetchResult<WpPost>>;
|
|
1388
|
+
useWpUpdatePost(id: number, data: WpPostUpdate): Promise<FetchResult<WpPost>>;
|
|
1389
|
+
useWpDeletePost(id: number, force?: boolean): Promise<FetchResult<WpPost>>;
|
|
1390
|
+
useWpGetPages(options?: WpQueryParams): Promise<FetchResult<WpPage[]>>;
|
|
1391
|
+
useWpGetPage(id: number, options?: WpQueryParams): Promise<FetchResult<WpPage>>;
|
|
1392
|
+
useWpCreatePage(data: WpPageCreate): Promise<FetchResult<WpPage>>;
|
|
1393
|
+
useWpUpdatePage(id: number, data: WpPageUpdate): Promise<FetchResult<WpPage>>;
|
|
1394
|
+
useWpDeletePage(id: number, force?: boolean): Promise<FetchResult<WpPage>>;
|
|
1395
|
+
useWpGetMedia(options?: WpQueryParams): Promise<FetchResult<WpMedia[]>>;
|
|
1396
|
+
useWpGetMediaItem(id: number): Promise<FetchResult<WpMedia>>;
|
|
1397
|
+
useWpUploadMedia(file: File | Blob | Buffer, meta?: WpMediaMeta): Promise<FetchResult<WpMedia>>;
|
|
1398
|
+
useWpUpdateMedia(id: number, data: WpMediaUpdate): Promise<FetchResult<WpMedia>>;
|
|
1399
|
+
useWpDeleteMedia(id: number, force?: boolean): Promise<FetchResult<WpMedia>>;
|
|
1400
|
+
useWpGetCategories(options?: WpQueryParams): Promise<FetchResult<WpCategory[]>>;
|
|
1401
|
+
useWpGetCategory(id: number): Promise<FetchResult<WpCategory>>;
|
|
1402
|
+
useWpCreateCategory(data: WpCategoryCreate): Promise<FetchResult<WpCategory>>;
|
|
1403
|
+
useWpUpdateCategory(id: number, data: WpCategoryUpdate): Promise<FetchResult<WpCategory>>;
|
|
1404
|
+
useWpDeleteCategory(id: number, force?: boolean): Promise<FetchResult<WpCategory>>;
|
|
1405
|
+
useWpGetTags(options?: WpQueryParams): Promise<FetchResult<WpTag[]>>;
|
|
1406
|
+
useWpGetTag(id: number): Promise<FetchResult<WpTag>>;
|
|
1407
|
+
useWpCreateTag(data: WpTagCreate): Promise<FetchResult<WpTag>>;
|
|
1408
|
+
useWpUpdateTag(id: number, data: WpTagUpdate): Promise<FetchResult<WpTag>>;
|
|
1409
|
+
useWpDeleteTag(id: number, force?: boolean): Promise<FetchResult<WpTag>>;
|
|
1410
|
+
useWpGetComments(options?: WpQueryParams): Promise<FetchResult<WpComment[]>>;
|
|
1411
|
+
useWpGetComment(id: number): Promise<FetchResult<WpComment>>;
|
|
1412
|
+
useWpCreateComment(data: WpCommentCreate): Promise<FetchResult<WpComment>>;
|
|
1413
|
+
useWpUpdateComment(id: number, data: WpCommentUpdate): Promise<FetchResult<WpComment>>;
|
|
1414
|
+
useWpDeleteComment(id: number, force?: boolean): Promise<FetchResult<WpComment>>;
|
|
1415
|
+
useWpGetUsers(options?: WpQueryParams): Promise<FetchResult<WpUser[]>>;
|
|
1416
|
+
useWpGetUser(id: number): Promise<FetchResult<WpUser>>;
|
|
1417
|
+
useWpGetCurrentUser(): Promise<FetchResult<WpUser>>;
|
|
1418
|
+
useWpCreateUser(data: WpUserCreate): Promise<FetchResult<WpUser>>;
|
|
1419
|
+
useWpUpdateUser(id: number, data: WpUserUpdate): Promise<FetchResult<WpUser>>;
|
|
1420
|
+
useWpDeleteUser(id: number, reassign?: number): Promise<FetchResult<WpUser>>;
|
|
1421
|
+
useWpGetCustomPosts(postType: string, options?: WpQueryParams): Promise<FetchResult<unknown[]>>;
|
|
1422
|
+
useWpGetCustomPost(postType: string, id: number, options?: WpQueryParams): Promise<FetchResult<unknown>>;
|
|
1423
|
+
useWpCreateCustomPost(postType: string, data: Record<string, unknown>): Promise<FetchResult<unknown>>;
|
|
1424
|
+
useWpUpdateCustomPost(postType: string, id: number, data: Record<string, unknown>): Promise<FetchResult<unknown>>;
|
|
1425
|
+
useWpDeleteCustomPost(postType: string, id: number, force?: boolean): Promise<FetchResult<unknown>>;
|
|
1426
|
+
useWpBatch(operations: WpBatchOperation[]): Promise<FetchResult<WpBatchResult>>;
|
|
1427
|
+
useWpListAllPosts(options?: WpQueryParams): Promise<FetchResult<WpPost[]>>;
|
|
1428
|
+
useWpSearchAllPosts(query: string, options?: WpQueryParams): Promise<FetchResult<WpPost[]>>;
|
|
1429
|
+
useWpFindPostBySlug(slug: string): Promise<FetchResult<WpPost | null>>;
|
|
1430
|
+
}
|
|
664
1431
|
//# sourceMappingURL=index.d.ts.map
|