@atomic-solutions/wordpress-api-client 0.1.1 → 0.1.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/dist/client/index.cjs +321 -10
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.js +312 -1
- package/dist/client/index.js.map +1 -1
- package/dist/index.cjs +438 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +403 -4
- package/dist/index.js.map +1 -1
- package/dist/testing/index.cjs +321 -10
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +312 -1
- package/dist/testing/index.js.map +1 -1
- package/package.json +4 -6
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { isAxiosError } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
// src/client/createClient.ts
|
|
5
5
|
|
|
@@ -692,6 +692,309 @@ var setupErrorInterceptor = (axiosInstance, config, client) => {
|
|
|
692
692
|
}
|
|
693
693
|
);
|
|
694
694
|
};
|
|
695
|
+
z.object({
|
|
696
|
+
username: z.string(),
|
|
697
|
+
password: z.string()
|
|
698
|
+
});
|
|
699
|
+
var JwtTokenResponseSchema = z.object({
|
|
700
|
+
token: z.string(),
|
|
701
|
+
user_email: z.string(),
|
|
702
|
+
user_nicename: z.string(),
|
|
703
|
+
user_display_name: z.string()
|
|
704
|
+
});
|
|
705
|
+
z.object({
|
|
706
|
+
code: z.string(),
|
|
707
|
+
data: z.object({
|
|
708
|
+
status: z.number()
|
|
709
|
+
})
|
|
710
|
+
});
|
|
711
|
+
z.object({
|
|
712
|
+
code: z.string(),
|
|
713
|
+
message: z.string(),
|
|
714
|
+
data: z.object({
|
|
715
|
+
status: z.number()
|
|
716
|
+
}).optional()
|
|
717
|
+
});
|
|
718
|
+
var RenderedContentSchema = z.object({
|
|
719
|
+
rendered: z.string(),
|
|
720
|
+
protected: z.boolean().optional()
|
|
721
|
+
});
|
|
722
|
+
var GuidSchema = z.object({
|
|
723
|
+
rendered: z.string()
|
|
724
|
+
});
|
|
725
|
+
z.enum([
|
|
726
|
+
"publish",
|
|
727
|
+
"future",
|
|
728
|
+
"draft",
|
|
729
|
+
"pending",
|
|
730
|
+
"private",
|
|
731
|
+
"trash",
|
|
732
|
+
"auto-draft",
|
|
733
|
+
"inherit"
|
|
734
|
+
]);
|
|
735
|
+
var HalLinkItemSchema = z.object({
|
|
736
|
+
href: z.string(),
|
|
737
|
+
embeddable: z.boolean().optional(),
|
|
738
|
+
templated: z.boolean().optional()
|
|
739
|
+
});
|
|
740
|
+
var HalLinksSchema = z.object({
|
|
741
|
+
self: z.array(HalLinkItemSchema).optional(),
|
|
742
|
+
collection: z.array(HalLinkItemSchema).optional(),
|
|
743
|
+
about: z.array(HalLinkItemSchema).optional(),
|
|
744
|
+
author: z.array(HalLinkItemSchema).optional(),
|
|
745
|
+
replies: z.array(HalLinkItemSchema).optional(),
|
|
746
|
+
"wp:featuredmedia": z.array(HalLinkItemSchema).optional(),
|
|
747
|
+
"wp:attachment": z.array(HalLinkItemSchema).optional(),
|
|
748
|
+
"wp:term": z.array(HalLinkItemSchema).optional(),
|
|
749
|
+
"wp:post_type": z.array(HalLinkItemSchema).optional(),
|
|
750
|
+
curies: z.array(
|
|
751
|
+
z.object({
|
|
752
|
+
name: z.string(),
|
|
753
|
+
href: z.string(),
|
|
754
|
+
templated: z.boolean()
|
|
755
|
+
})
|
|
756
|
+
).optional()
|
|
757
|
+
}).passthrough();
|
|
758
|
+
z.object({
|
|
759
|
+
id: z.number(),
|
|
760
|
+
date: z.string(),
|
|
761
|
+
date_gmt: z.string(),
|
|
762
|
+
modified: z.string(),
|
|
763
|
+
modified_gmt: z.string(),
|
|
764
|
+
slug: z.string(),
|
|
765
|
+
status: z.string(),
|
|
766
|
+
type: z.string(),
|
|
767
|
+
link: z.string(),
|
|
768
|
+
_links: HalLinksSchema.optional()
|
|
769
|
+
});
|
|
770
|
+
var paginationParamsSchema = z.object({
|
|
771
|
+
/** Current page number */
|
|
772
|
+
page: z.number().int().positive().optional(),
|
|
773
|
+
/** Items per page */
|
|
774
|
+
per_page: z.number().int().positive().max(100).optional(),
|
|
775
|
+
/** Offset for pagination */
|
|
776
|
+
offset: z.number().int().nonnegative().optional(),
|
|
777
|
+
/** Sort order */
|
|
778
|
+
order: z.enum(["asc", "desc"]).optional(),
|
|
779
|
+
/** Field to sort by */
|
|
780
|
+
orderby: z.string().optional()
|
|
781
|
+
});
|
|
782
|
+
z.object({
|
|
783
|
+
/** Total number of items */
|
|
784
|
+
total: z.number(),
|
|
785
|
+
/** Total number of pages */
|
|
786
|
+
totalPages: z.number(),
|
|
787
|
+
/** Current page */
|
|
788
|
+
currentPage: z.number(),
|
|
789
|
+
/** Items per page */
|
|
790
|
+
perPage: z.number()
|
|
791
|
+
});
|
|
792
|
+
var CategorySchema = z.object({
|
|
793
|
+
id: z.number(),
|
|
794
|
+
count: z.number(),
|
|
795
|
+
description: z.string().optional(),
|
|
796
|
+
link: z.string(),
|
|
797
|
+
name: z.string(),
|
|
798
|
+
slug: z.string(),
|
|
799
|
+
taxonomy: z.string(),
|
|
800
|
+
parent: z.number(),
|
|
801
|
+
meta: z.any().optional(),
|
|
802
|
+
_links: HalLinksSchema.optional()
|
|
803
|
+
});
|
|
804
|
+
var CategoriesListSchema = z.array(CategorySchema);
|
|
805
|
+
paginationParamsSchema.extend({
|
|
806
|
+
context: z.enum(["view", "embed", "edit"]).optional(),
|
|
807
|
+
search: z.string().optional(),
|
|
808
|
+
exclude: z.array(z.number()).optional(),
|
|
809
|
+
include: z.array(z.number()).optional(),
|
|
810
|
+
hide_empty: z.boolean().optional(),
|
|
811
|
+
parent: z.number().optional(),
|
|
812
|
+
post: z.number().optional(),
|
|
813
|
+
slug: z.string().optional()
|
|
814
|
+
});
|
|
815
|
+
var TagSchema = z.object({
|
|
816
|
+
id: z.number(),
|
|
817
|
+
count: z.number(),
|
|
818
|
+
description: z.string().optional(),
|
|
819
|
+
link: z.string(),
|
|
820
|
+
name: z.string(),
|
|
821
|
+
slug: z.string(),
|
|
822
|
+
taxonomy: z.string(),
|
|
823
|
+
meta: z.any().optional(),
|
|
824
|
+
_links: HalLinksSchema.optional()
|
|
825
|
+
});
|
|
826
|
+
z.array(TagSchema);
|
|
827
|
+
var MediaSizeSchema = z.object({
|
|
828
|
+
file: z.string(),
|
|
829
|
+
width: z.number(),
|
|
830
|
+
height: z.number(),
|
|
831
|
+
filesize: z.number().optional(),
|
|
832
|
+
mime_type: z.string(),
|
|
833
|
+
source_url: z.string()
|
|
834
|
+
});
|
|
835
|
+
var MediaSizesSchema = z.object({
|
|
836
|
+
thumbnail: MediaSizeSchema.optional(),
|
|
837
|
+
medium: MediaSizeSchema.optional(),
|
|
838
|
+
medium_large: MediaSizeSchema.optional(),
|
|
839
|
+
large: MediaSizeSchema.optional(),
|
|
840
|
+
full: MediaSizeSchema.optional()
|
|
841
|
+
}).passthrough();
|
|
842
|
+
var ImageMetaSchema = z.object({
|
|
843
|
+
aperture: z.string().optional(),
|
|
844
|
+
credit: z.string().optional(),
|
|
845
|
+
camera: z.string().optional(),
|
|
846
|
+
caption: z.string().optional(),
|
|
847
|
+
created_timestamp: z.string().optional(),
|
|
848
|
+
copyright: z.string().optional(),
|
|
849
|
+
focal_length: z.string().optional(),
|
|
850
|
+
iso: z.string().optional(),
|
|
851
|
+
shutter_speed: z.string().optional(),
|
|
852
|
+
title: z.string().optional(),
|
|
853
|
+
orientation: z.string().optional(),
|
|
854
|
+
keywords: z.array(z.string()).optional()
|
|
855
|
+
});
|
|
856
|
+
var MediaDetailsSchema = z.object({
|
|
857
|
+
width: z.number(),
|
|
858
|
+
height: z.number(),
|
|
859
|
+
file: z.string(),
|
|
860
|
+
filesize: z.number().optional(),
|
|
861
|
+
sizes: MediaSizesSchema,
|
|
862
|
+
image_meta: ImageMetaSchema.optional()
|
|
863
|
+
});
|
|
864
|
+
var MediaSchema = z.object({
|
|
865
|
+
id: z.number(),
|
|
866
|
+
date: z.string(),
|
|
867
|
+
date_gmt: z.string(),
|
|
868
|
+
guid: GuidSchema,
|
|
869
|
+
modified: z.string(),
|
|
870
|
+
modified_gmt: z.string(),
|
|
871
|
+
slug: z.string(),
|
|
872
|
+
status: z.string(),
|
|
873
|
+
type: z.string(),
|
|
874
|
+
link: z.string(),
|
|
875
|
+
title: RenderedContentSchema,
|
|
876
|
+
author: z.number(),
|
|
877
|
+
comment_status: z.string(),
|
|
878
|
+
ping_status: z.string(),
|
|
879
|
+
template: z.string().optional(),
|
|
880
|
+
meta: z.any().optional(),
|
|
881
|
+
description: RenderedContentSchema,
|
|
882
|
+
caption: RenderedContentSchema,
|
|
883
|
+
alt_text: z.string(),
|
|
884
|
+
media_type: z.string(),
|
|
885
|
+
mime_type: z.string(),
|
|
886
|
+
media_details: MediaDetailsSchema,
|
|
887
|
+
post: z.number().nullable(),
|
|
888
|
+
source_url: z.string(),
|
|
889
|
+
_links: HalLinksSchema.optional()
|
|
890
|
+
});
|
|
891
|
+
z.array(MediaSchema);
|
|
892
|
+
var PostSchema = z.object({
|
|
893
|
+
id: z.number(),
|
|
894
|
+
date: z.string(),
|
|
895
|
+
date_gmt: z.string(),
|
|
896
|
+
guid: GuidSchema,
|
|
897
|
+
modified: z.string(),
|
|
898
|
+
modified_gmt: z.string(),
|
|
899
|
+
slug: z.string(),
|
|
900
|
+
status: z.string(),
|
|
901
|
+
type: z.string(),
|
|
902
|
+
link: z.string(),
|
|
903
|
+
title: RenderedContentSchema,
|
|
904
|
+
content: RenderedContentSchema,
|
|
905
|
+
excerpt: RenderedContentSchema,
|
|
906
|
+
author: z.number(),
|
|
907
|
+
featured_media: z.number(),
|
|
908
|
+
comment_status: z.string(),
|
|
909
|
+
ping_status: z.string(),
|
|
910
|
+
sticky: z.boolean(),
|
|
911
|
+
template: z.string(),
|
|
912
|
+
format: z.string(),
|
|
913
|
+
meta: z.any().optional(),
|
|
914
|
+
categories: z.array(z.number()),
|
|
915
|
+
tags: z.array(z.number()).optional(),
|
|
916
|
+
_links: HalLinksSchema.optional()
|
|
917
|
+
});
|
|
918
|
+
var PostsListSchema = z.array(PostSchema);
|
|
919
|
+
paginationParamsSchema.extend({
|
|
920
|
+
context: z.enum(["view", "embed", "edit"]).optional(),
|
|
921
|
+
search: z.string().optional(),
|
|
922
|
+
after: z.string().optional(),
|
|
923
|
+
before: z.string().optional(),
|
|
924
|
+
author: z.union([z.number(), z.array(z.number())]).optional(),
|
|
925
|
+
author_exclude: z.array(z.number()).optional(),
|
|
926
|
+
exclude: z.array(z.number()).optional(),
|
|
927
|
+
include: z.array(z.number()).optional(),
|
|
928
|
+
categories: z.union([z.number(), z.array(z.number())]).optional(),
|
|
929
|
+
categories_exclude: z.array(z.number()).optional(),
|
|
930
|
+
tags: z.union([z.number(), z.array(z.number())]).optional(),
|
|
931
|
+
tags_exclude: z.array(z.number()).optional(),
|
|
932
|
+
sticky: z.boolean().optional()
|
|
933
|
+
});
|
|
934
|
+
var EmbeddedPostSchema = z.object({
|
|
935
|
+
id: z.number(),
|
|
936
|
+
title: z.string(),
|
|
937
|
+
content: z.string(),
|
|
938
|
+
featured_image: z.string().optional(),
|
|
939
|
+
published_date: z.string(),
|
|
940
|
+
categories: z.array(
|
|
941
|
+
z.object({
|
|
942
|
+
id: z.number(),
|
|
943
|
+
name: z.string(),
|
|
944
|
+
slug: z.string(),
|
|
945
|
+
taxonomy: z.string().optional(),
|
|
946
|
+
description: z.string().optional(),
|
|
947
|
+
parent: z.number().optional(),
|
|
948
|
+
count: z.number().optional()
|
|
949
|
+
})
|
|
950
|
+
).optional()
|
|
951
|
+
});
|
|
952
|
+
z.array(EmbeddedPostSchema);
|
|
953
|
+
var AvatarUrlsSchema = z.object({
|
|
954
|
+
"24": z.string().optional(),
|
|
955
|
+
"48": z.string().optional(),
|
|
956
|
+
"96": z.string().optional()
|
|
957
|
+
});
|
|
958
|
+
var UserSchema = z.object({
|
|
959
|
+
id: z.number(),
|
|
960
|
+
username: z.string().optional(),
|
|
961
|
+
// Only in edit context
|
|
962
|
+
name: z.string(),
|
|
963
|
+
first_name: z.string().optional(),
|
|
964
|
+
last_name: z.string().optional(),
|
|
965
|
+
email: z.string().optional(),
|
|
966
|
+
// Only for current user or admin
|
|
967
|
+
url: z.string(),
|
|
968
|
+
description: z.string(),
|
|
969
|
+
link: z.string(),
|
|
970
|
+
locale: z.string().optional(),
|
|
971
|
+
// Only for current user
|
|
972
|
+
nickname: z.string().optional(),
|
|
973
|
+
// Only in edit context
|
|
974
|
+
slug: z.string(),
|
|
975
|
+
registered_date: z.string().optional(),
|
|
976
|
+
// Only in edit context
|
|
977
|
+
roles: z.array(z.string()).optional(),
|
|
978
|
+
// Only in edit context
|
|
979
|
+
capabilities: z.record(z.boolean()).optional(),
|
|
980
|
+
// Only in edit context
|
|
981
|
+
extra_capabilities: z.record(z.boolean()).optional(),
|
|
982
|
+
// Only in edit context
|
|
983
|
+
avatar_urls: AvatarUrlsSchema.optional(),
|
|
984
|
+
meta: z.any().optional(),
|
|
985
|
+
_links: HalLinksSchema.optional()
|
|
986
|
+
});
|
|
987
|
+
z.array(UserSchema);
|
|
988
|
+
var CurrentUserSchema = UserSchema.extend({
|
|
989
|
+
username: z.string(),
|
|
990
|
+
email: z.string(),
|
|
991
|
+
locale: z.string(),
|
|
992
|
+
nickname: z.string(),
|
|
993
|
+
registered_date: z.string(),
|
|
994
|
+
roles: z.array(z.string())
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
// src/api/auth.ts
|
|
695
998
|
var createAuthAPI = (axios2, options) => ({
|
|
696
999
|
/**
|
|
697
1000
|
* Login with username/password and get JWT token
|
|
@@ -714,6 +1017,8 @@ var createAuthAPI = (axios2, options) => ({
|
|
|
714
1017
|
}
|
|
715
1018
|
}
|
|
716
1019
|
});
|
|
1020
|
+
|
|
1021
|
+
// src/api/categories.ts
|
|
717
1022
|
var createCategoriesAPI = (axios2, options) => ({
|
|
718
1023
|
/**
|
|
719
1024
|
* Get list of categories with pagination
|
|
@@ -730,6 +1035,8 @@ var createCategoriesAPI = (axios2, options) => ({
|
|
|
730
1035
|
return handleApiResponse(response, CategorySchema, options);
|
|
731
1036
|
}
|
|
732
1037
|
});
|
|
1038
|
+
|
|
1039
|
+
// src/api/media.ts
|
|
733
1040
|
var createMediaAPI = (axios2, options) => ({
|
|
734
1041
|
/**
|
|
735
1042
|
* Get single media item by ID
|
|
@@ -739,6 +1046,8 @@ var createMediaAPI = (axios2, options) => ({
|
|
|
739
1046
|
return handleApiResponse(response, MediaSchema, options);
|
|
740
1047
|
}
|
|
741
1048
|
});
|
|
1049
|
+
|
|
1050
|
+
// src/api/posts.ts
|
|
742
1051
|
var createPostsAPI = (axios2, options) => ({
|
|
743
1052
|
/**
|
|
744
1053
|
* Get list of posts with pagination
|
|
@@ -765,6 +1074,8 @@ var createPostsAPI = (axios2, options) => ({
|
|
|
765
1074
|
return posts[0] || null;
|
|
766
1075
|
}
|
|
767
1076
|
});
|
|
1077
|
+
|
|
1078
|
+
// src/api/users.ts
|
|
768
1079
|
var createUsersAPI = (axios2, options) => ({
|
|
769
1080
|
/**
|
|
770
1081
|
* Get current authenticated user
|