@atomic-solutions/wordpress-api-client 0.1.0 → 0.1.1
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 +10 -321
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +1 -312
- package/dist/client/index.js.map +1 -1
- package/dist/http/index.d.cts +3 -3
- package/dist/http/index.d.ts +3 -3
- package/dist/index.cjs +143 -422
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -381
- package/dist/index.js.map +1 -1
- package/dist/testing/index.cjs +10 -321
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -312
- package/dist/testing/index.js.map +1 -1
- package/dist/{types-BTo088EY.d.cts → types-TIxx-tHQ.d.cts} +1 -1
- package/dist/{types-8pbwmNdu.d.ts → types-Yb4991oO.d.ts} +1 -1
- package/package.json +4 -6
- package/dist/schemas/index.cjs +0 -414
- package/dist/schemas/index.cjs.map +0 -1
- package/dist/schemas/index.d.cts +0 -1339
- package/dist/schemas/index.d.ts +0 -1339
- package/dist/schemas/index.js +0 -376
- package/dist/schemas/index.js.map +0 -1
- package/dist/user.schema-eeUHQ4sI.d.cts +0 -10614
- package/dist/user.schema-eeUHQ4sI.d.ts +0 -10614
package/dist/testing/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { isAxiosError } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { PostsListSchema, JwtTokenResponseSchema, CategorySchema, CategoriesListSchema, MediaSchema, PostSchema, UserSchema, CurrentUserSchema } from '@atomic-solutions/schemas/wordpress';
|
|
3
3
|
|
|
4
4
|
// src/client/createClient.ts
|
|
5
5
|
|
|
@@ -692,309 +692,6 @@ var setupErrorInterceptor = (axiosInstance, config, client) => {
|
|
|
692
692
|
}
|
|
693
693
|
);
|
|
694
694
|
};
|
|
695
|
-
var paginationParamsSchema = z.object({
|
|
696
|
-
/** Current page number */
|
|
697
|
-
page: z.number().int().positive().optional(),
|
|
698
|
-
/** Items per page */
|
|
699
|
-
per_page: z.number().int().positive().max(100).optional(),
|
|
700
|
-
/** Offset for pagination */
|
|
701
|
-
offset: z.number().int().nonnegative().optional(),
|
|
702
|
-
/** Sort order */
|
|
703
|
-
order: z.enum(["asc", "desc"]).optional(),
|
|
704
|
-
/** Field to sort by */
|
|
705
|
-
orderby: z.string().optional()
|
|
706
|
-
});
|
|
707
|
-
z.object({
|
|
708
|
-
/** Total number of items */
|
|
709
|
-
total: z.number(),
|
|
710
|
-
/** Total number of pages */
|
|
711
|
-
totalPages: z.number(),
|
|
712
|
-
/** Current page */
|
|
713
|
-
currentPage: z.number(),
|
|
714
|
-
/** Items per page */
|
|
715
|
-
perPage: z.number()
|
|
716
|
-
});
|
|
717
|
-
z.object({
|
|
718
|
-
username: z.string(),
|
|
719
|
-
password: z.string()
|
|
720
|
-
});
|
|
721
|
-
var JwtTokenResponseSchema = z.object({
|
|
722
|
-
token: z.string(),
|
|
723
|
-
user_email: z.string(),
|
|
724
|
-
user_nicename: z.string(),
|
|
725
|
-
user_display_name: z.string()
|
|
726
|
-
});
|
|
727
|
-
z.object({
|
|
728
|
-
code: z.string(),
|
|
729
|
-
data: z.object({
|
|
730
|
-
status: z.number()
|
|
731
|
-
})
|
|
732
|
-
});
|
|
733
|
-
z.object({
|
|
734
|
-
code: z.string(),
|
|
735
|
-
message: z.string(),
|
|
736
|
-
data: z.object({
|
|
737
|
-
status: z.number()
|
|
738
|
-
}).optional()
|
|
739
|
-
});
|
|
740
|
-
var RenderedContentSchema = z.object({
|
|
741
|
-
rendered: z.string(),
|
|
742
|
-
protected: z.boolean().optional()
|
|
743
|
-
});
|
|
744
|
-
var GuidSchema = z.object({
|
|
745
|
-
rendered: z.string()
|
|
746
|
-
});
|
|
747
|
-
z.enum([
|
|
748
|
-
"publish",
|
|
749
|
-
"future",
|
|
750
|
-
"draft",
|
|
751
|
-
"pending",
|
|
752
|
-
"private",
|
|
753
|
-
"trash",
|
|
754
|
-
"auto-draft",
|
|
755
|
-
"inherit"
|
|
756
|
-
]);
|
|
757
|
-
var HalLinkItemSchema = z.object({
|
|
758
|
-
href: z.string(),
|
|
759
|
-
embeddable: z.boolean().optional(),
|
|
760
|
-
templated: z.boolean().optional()
|
|
761
|
-
});
|
|
762
|
-
var HalLinksSchema = z.object({
|
|
763
|
-
self: z.array(HalLinkItemSchema).optional(),
|
|
764
|
-
collection: z.array(HalLinkItemSchema).optional(),
|
|
765
|
-
about: z.array(HalLinkItemSchema).optional(),
|
|
766
|
-
author: z.array(HalLinkItemSchema).optional(),
|
|
767
|
-
replies: z.array(HalLinkItemSchema).optional(),
|
|
768
|
-
"wp:featuredmedia": z.array(HalLinkItemSchema).optional(),
|
|
769
|
-
"wp:attachment": z.array(HalLinkItemSchema).optional(),
|
|
770
|
-
"wp:term": z.array(HalLinkItemSchema).optional(),
|
|
771
|
-
"wp:post_type": z.array(HalLinkItemSchema).optional(),
|
|
772
|
-
curies: z.array(
|
|
773
|
-
z.object({
|
|
774
|
-
name: z.string(),
|
|
775
|
-
href: z.string(),
|
|
776
|
-
templated: z.boolean()
|
|
777
|
-
})
|
|
778
|
-
).optional()
|
|
779
|
-
}).passthrough();
|
|
780
|
-
z.object({
|
|
781
|
-
id: z.number(),
|
|
782
|
-
date: z.string(),
|
|
783
|
-
date_gmt: z.string(),
|
|
784
|
-
modified: z.string(),
|
|
785
|
-
modified_gmt: z.string(),
|
|
786
|
-
slug: z.string(),
|
|
787
|
-
status: z.string(),
|
|
788
|
-
type: z.string(),
|
|
789
|
-
link: z.string(),
|
|
790
|
-
_links: HalLinksSchema.optional()
|
|
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
|
|
998
695
|
var createAuthAPI = (axios2, options) => ({
|
|
999
696
|
/**
|
|
1000
697
|
* Login with username/password and get JWT token
|
|
@@ -1017,8 +714,6 @@ var createAuthAPI = (axios2, options) => ({
|
|
|
1017
714
|
}
|
|
1018
715
|
}
|
|
1019
716
|
});
|
|
1020
|
-
|
|
1021
|
-
// src/api/categories.ts
|
|
1022
717
|
var createCategoriesAPI = (axios2, options) => ({
|
|
1023
718
|
/**
|
|
1024
719
|
* Get list of categories with pagination
|
|
@@ -1035,8 +730,6 @@ var createCategoriesAPI = (axios2, options) => ({
|
|
|
1035
730
|
return handleApiResponse(response, CategorySchema, options);
|
|
1036
731
|
}
|
|
1037
732
|
});
|
|
1038
|
-
|
|
1039
|
-
// src/api/media.ts
|
|
1040
733
|
var createMediaAPI = (axios2, options) => ({
|
|
1041
734
|
/**
|
|
1042
735
|
* Get single media item by ID
|
|
@@ -1046,8 +739,6 @@ var createMediaAPI = (axios2, options) => ({
|
|
|
1046
739
|
return handleApiResponse(response, MediaSchema, options);
|
|
1047
740
|
}
|
|
1048
741
|
});
|
|
1049
|
-
|
|
1050
|
-
// src/api/posts.ts
|
|
1051
742
|
var createPostsAPI = (axios2, options) => ({
|
|
1052
743
|
/**
|
|
1053
744
|
* Get list of posts with pagination
|
|
@@ -1074,8 +765,6 @@ var createPostsAPI = (axios2, options) => ({
|
|
|
1074
765
|
return posts[0] || null;
|
|
1075
766
|
}
|
|
1076
767
|
});
|
|
1077
|
-
|
|
1078
|
-
// src/api/users.ts
|
|
1079
768
|
var createUsersAPI = (axios2, options) => ({
|
|
1080
769
|
/**
|
|
1081
770
|
* Get current authenticated user
|