@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/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import axios, { isAxiosError } from 'axios';
2
- import { z } from 'zod';
2
+ import { PostsListSchema, JwtTokenResponseSchema, CategorySchema, CategoriesListSchema, MediaSchema, PostSchema, UserSchema, CurrentUserSchema } from '@atomic-solutions/schemas/wordpress';
3
+ export { AvatarUrlsSchema, CategoriesListSchema, CategoryParamsSchema, CategorySchema, CurrentUserSchema, EmbeddedPostSchema, EmbeddedPostsListSchema, GuidSchema, HalLinkItemSchema, HalLinksSchema, ImageMetaSchema, JwtErrorResponseSchema, JwtLoginInputSchema, JwtTokenResponseSchema, JwtValidateResponseSchema, MediaDetailsSchema, MediaListSchema, MediaSchema, MediaSizeSchema, MediaSizesSchema, PostParamsSchema, PostSchema, PostStatusSchema, PostsListSchema, RenderedContentSchema, TagSchema, TagsListSchema, UserSchema, UsersListSchema, WordPressBaseSchema } from '@atomic-solutions/schemas/wordpress';
4
+ export { addressSchema as AddressSchema, moneySchema as MoneySchema, paginationParamsSchema as PaginationParamsSchema } from '@atomic-solutions/schemas/common';
3
5
 
4
6
  // src/client/createClient.ts
5
7
 
@@ -692,377 +694,6 @@ var setupErrorInterceptor = (axiosInstance, config, client) => {
692
694
  }
693
695
  );
694
696
  };
695
- var addressSchema = z.object({
696
- /** First name */
697
- first_name: z.string().min(1, "First name is required"),
698
- /** Last name */
699
- last_name: z.string().min(1, "Last name is required"),
700
- /** Company name (optional) */
701
- company: z.string(),
702
- /** Address line 1 */
703
- address_1: z.string().min(1, "Address is required"),
704
- /** Address line 2 (optional) */
705
- address_2: z.string(),
706
- /** City */
707
- city: z.string().min(1, "City is required"),
708
- /** State/Province/Region */
709
- state: z.string(),
710
- /** Postal code */
711
- postcode: z.string().min(1, "Postal code is required"),
712
- /** Country code (ISO 3166-1 alpha-2) */
713
- country: z.string(),
714
- /** Phone number */
715
- phone: z.string().min(1, "Phone number is required")
716
- });
717
- var addressSchemaNonMandatory = z.object({
718
- /** First name */
719
- first_name: z.string(),
720
- /** Last name */
721
- last_name: z.string(),
722
- /** Company name (optional) */
723
- company: z.string(),
724
- /** Address line 1 */
725
- address_1: z.string(),
726
- /** Address line 2 (optional) */
727
- address_2: z.string(),
728
- /** City */
729
- city: z.string(),
730
- /** State/Province/Region */
731
- state: z.string(),
732
- /** Postal code */
733
- postcode: z.string(),
734
- /** Country code (ISO 3166-1 alpha-2) */
735
- country: z.string(),
736
- /** Phone number */
737
- phone: z.string()
738
- });
739
- addressSchema.extend({
740
- /** Email address (required for billing) */
741
- email: z.string().email("Valid email is required")
742
- });
743
- addressSchemaNonMandatory.extend({
744
- /** Email address (can be null for guest carts) */
745
- email: z.string().nullable()
746
- });
747
- var moneySchema = z.object({
748
- /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
749
- currency_code: z.string(),
750
- /** Currency symbol (e.g., '$', '€', 'KM') */
751
- currency_symbol: z.string(),
752
- /** Number of decimal places (e.g., 2 for dollars/euros) */
753
- currency_minor_unit: z.number(),
754
- /** Decimal separator character (e.g., '.', ',') */
755
- currency_decimal_separator: z.string(),
756
- /** Thousands separator character (e.g., ',', '.') */
757
- currency_thousand_separator: z.string(),
758
- /** Currency symbol prefix (empty if symbol is suffix) */
759
- currency_prefix: z.string(),
760
- /** Currency symbol suffix (empty if symbol is prefix) */
761
- currency_suffix: z.string()
762
- });
763
- var paginationParamsSchema = z.object({
764
- /** Current page number */
765
- page: z.number().int().positive().optional(),
766
- /** Items per page */
767
- per_page: z.number().int().positive().max(100).optional(),
768
- /** Offset for pagination */
769
- offset: z.number().int().nonnegative().optional(),
770
- /** Sort order */
771
- order: z.enum(["asc", "desc"]).optional(),
772
- /** Field to sort by */
773
- orderby: z.string().optional()
774
- });
775
- z.object({
776
- /** Total number of items */
777
- total: z.number(),
778
- /** Total number of pages */
779
- totalPages: z.number(),
780
- /** Current page */
781
- currentPage: z.number(),
782
- /** Items per page */
783
- perPage: z.number()
784
- });
785
- var JwtLoginInputSchema = z.object({
786
- username: z.string(),
787
- password: z.string()
788
- });
789
- var JwtTokenResponseSchema = z.object({
790
- token: z.string(),
791
- user_email: z.string(),
792
- user_nicename: z.string(),
793
- user_display_name: z.string()
794
- });
795
- var JwtValidateResponseSchema = z.object({
796
- code: z.string(),
797
- data: z.object({
798
- status: z.number()
799
- })
800
- });
801
- var JwtErrorResponseSchema = z.object({
802
- code: z.string(),
803
- message: z.string(),
804
- data: z.object({
805
- status: z.number()
806
- }).optional()
807
- });
808
- var RenderedContentSchema = z.object({
809
- rendered: z.string(),
810
- protected: z.boolean().optional()
811
- });
812
- var GuidSchema = z.object({
813
- rendered: z.string()
814
- });
815
- var PostStatusSchema = z.enum([
816
- "publish",
817
- "future",
818
- "draft",
819
- "pending",
820
- "private",
821
- "trash",
822
- "auto-draft",
823
- "inherit"
824
- ]);
825
- var HalLinkItemSchema = z.object({
826
- href: z.string(),
827
- embeddable: z.boolean().optional(),
828
- templated: z.boolean().optional()
829
- });
830
- var HalLinksSchema = z.object({
831
- self: z.array(HalLinkItemSchema).optional(),
832
- collection: z.array(HalLinkItemSchema).optional(),
833
- about: z.array(HalLinkItemSchema).optional(),
834
- author: z.array(HalLinkItemSchema).optional(),
835
- replies: z.array(HalLinkItemSchema).optional(),
836
- "wp:featuredmedia": z.array(HalLinkItemSchema).optional(),
837
- "wp:attachment": z.array(HalLinkItemSchema).optional(),
838
- "wp:term": z.array(HalLinkItemSchema).optional(),
839
- "wp:post_type": z.array(HalLinkItemSchema).optional(),
840
- curies: z.array(
841
- z.object({
842
- name: z.string(),
843
- href: z.string(),
844
- templated: z.boolean()
845
- })
846
- ).optional()
847
- }).passthrough();
848
- var WordPressBaseSchema = z.object({
849
- id: z.number(),
850
- date: z.string(),
851
- date_gmt: z.string(),
852
- modified: z.string(),
853
- modified_gmt: z.string(),
854
- slug: z.string(),
855
- status: z.string(),
856
- type: z.string(),
857
- link: z.string(),
858
- _links: HalLinksSchema.optional()
859
- });
860
- var CategorySchema = z.object({
861
- id: z.number(),
862
- count: z.number(),
863
- description: z.string().optional(),
864
- link: z.string(),
865
- name: z.string(),
866
- slug: z.string(),
867
- taxonomy: z.string(),
868
- parent: z.number(),
869
- meta: z.any().optional(),
870
- _links: HalLinksSchema.optional()
871
- });
872
- var CategoriesListSchema = z.array(CategorySchema);
873
- var CategoryParamsSchema = paginationParamsSchema.extend({
874
- context: z.enum(["view", "embed", "edit"]).optional(),
875
- search: z.string().optional(),
876
- exclude: z.array(z.number()).optional(),
877
- include: z.array(z.number()).optional(),
878
- hide_empty: z.boolean().optional(),
879
- parent: z.number().optional(),
880
- post: z.number().optional(),
881
- slug: z.string().optional()
882
- });
883
- var TagSchema = z.object({
884
- id: z.number(),
885
- count: z.number(),
886
- description: z.string().optional(),
887
- link: z.string(),
888
- name: z.string(),
889
- slug: z.string(),
890
- taxonomy: z.string(),
891
- meta: z.any().optional(),
892
- _links: HalLinksSchema.optional()
893
- });
894
- var TagsListSchema = z.array(TagSchema);
895
- var MediaSizeSchema = z.object({
896
- file: z.string(),
897
- width: z.number(),
898
- height: z.number(),
899
- filesize: z.number().optional(),
900
- mime_type: z.string(),
901
- source_url: z.string()
902
- });
903
- var MediaSizesSchema = z.object({
904
- thumbnail: MediaSizeSchema.optional(),
905
- medium: MediaSizeSchema.optional(),
906
- medium_large: MediaSizeSchema.optional(),
907
- large: MediaSizeSchema.optional(),
908
- full: MediaSizeSchema.optional()
909
- }).passthrough();
910
- var ImageMetaSchema = z.object({
911
- aperture: z.string().optional(),
912
- credit: z.string().optional(),
913
- camera: z.string().optional(),
914
- caption: z.string().optional(),
915
- created_timestamp: z.string().optional(),
916
- copyright: z.string().optional(),
917
- focal_length: z.string().optional(),
918
- iso: z.string().optional(),
919
- shutter_speed: z.string().optional(),
920
- title: z.string().optional(),
921
- orientation: z.string().optional(),
922
- keywords: z.array(z.string()).optional()
923
- });
924
- var MediaDetailsSchema = z.object({
925
- width: z.number(),
926
- height: z.number(),
927
- file: z.string(),
928
- filesize: z.number().optional(),
929
- sizes: MediaSizesSchema,
930
- image_meta: ImageMetaSchema.optional()
931
- });
932
- var MediaSchema = z.object({
933
- id: z.number(),
934
- date: z.string(),
935
- date_gmt: z.string(),
936
- guid: GuidSchema,
937
- modified: z.string(),
938
- modified_gmt: z.string(),
939
- slug: z.string(),
940
- status: z.string(),
941
- type: z.string(),
942
- link: z.string(),
943
- title: RenderedContentSchema,
944
- author: z.number(),
945
- comment_status: z.string(),
946
- ping_status: z.string(),
947
- template: z.string().optional(),
948
- meta: z.any().optional(),
949
- description: RenderedContentSchema,
950
- caption: RenderedContentSchema,
951
- alt_text: z.string(),
952
- media_type: z.string(),
953
- mime_type: z.string(),
954
- media_details: MediaDetailsSchema,
955
- post: z.number().nullable(),
956
- source_url: z.string(),
957
- _links: HalLinksSchema.optional()
958
- });
959
- var MediaListSchema = z.array(MediaSchema);
960
- var PostSchema = z.object({
961
- id: z.number(),
962
- date: z.string(),
963
- date_gmt: z.string(),
964
- guid: GuidSchema,
965
- modified: z.string(),
966
- modified_gmt: z.string(),
967
- slug: z.string(),
968
- status: z.string(),
969
- type: z.string(),
970
- link: z.string(),
971
- title: RenderedContentSchema,
972
- content: RenderedContentSchema,
973
- excerpt: RenderedContentSchema,
974
- author: z.number(),
975
- featured_media: z.number(),
976
- comment_status: z.string(),
977
- ping_status: z.string(),
978
- sticky: z.boolean(),
979
- template: z.string(),
980
- format: z.string(),
981
- meta: z.any().optional(),
982
- categories: z.array(z.number()),
983
- tags: z.array(z.number()).optional(),
984
- _links: HalLinksSchema.optional()
985
- });
986
- var PostsListSchema = z.array(PostSchema);
987
- var PostParamsSchema = paginationParamsSchema.extend({
988
- context: z.enum(["view", "embed", "edit"]).optional(),
989
- search: z.string().optional(),
990
- after: z.string().optional(),
991
- before: z.string().optional(),
992
- author: z.union([z.number(), z.array(z.number())]).optional(),
993
- author_exclude: z.array(z.number()).optional(),
994
- exclude: z.array(z.number()).optional(),
995
- include: z.array(z.number()).optional(),
996
- categories: z.union([z.number(), z.array(z.number())]).optional(),
997
- categories_exclude: z.array(z.number()).optional(),
998
- tags: z.union([z.number(), z.array(z.number())]).optional(),
999
- tags_exclude: z.array(z.number()).optional(),
1000
- sticky: z.boolean().optional()
1001
- });
1002
- var EmbeddedPostSchema = z.object({
1003
- id: z.number(),
1004
- title: z.string(),
1005
- content: z.string(),
1006
- featured_image: z.string().optional(),
1007
- published_date: z.string(),
1008
- categories: z.array(
1009
- z.object({
1010
- id: z.number(),
1011
- name: z.string(),
1012
- slug: z.string(),
1013
- taxonomy: z.string().optional(),
1014
- description: z.string().optional(),
1015
- parent: z.number().optional(),
1016
- count: z.number().optional()
1017
- })
1018
- ).optional()
1019
- });
1020
- var EmbeddedPostsListSchema = z.array(EmbeddedPostSchema);
1021
- var AvatarUrlsSchema = z.object({
1022
- "24": z.string().optional(),
1023
- "48": z.string().optional(),
1024
- "96": z.string().optional()
1025
- });
1026
- var UserSchema = z.object({
1027
- id: z.number(),
1028
- username: z.string().optional(),
1029
- // Only in edit context
1030
- name: z.string(),
1031
- first_name: z.string().optional(),
1032
- last_name: z.string().optional(),
1033
- email: z.string().optional(),
1034
- // Only for current user or admin
1035
- url: z.string(),
1036
- description: z.string(),
1037
- link: z.string(),
1038
- locale: z.string().optional(),
1039
- // Only for current user
1040
- nickname: z.string().optional(),
1041
- // Only in edit context
1042
- slug: z.string(),
1043
- registered_date: z.string().optional(),
1044
- // Only in edit context
1045
- roles: z.array(z.string()).optional(),
1046
- // Only in edit context
1047
- capabilities: z.record(z.boolean()).optional(),
1048
- // Only in edit context
1049
- extra_capabilities: z.record(z.boolean()).optional(),
1050
- // Only in edit context
1051
- avatar_urls: AvatarUrlsSchema.optional(),
1052
- meta: z.any().optional(),
1053
- _links: HalLinksSchema.optional()
1054
- });
1055
- var UsersListSchema = z.array(UserSchema);
1056
- var CurrentUserSchema = UserSchema.extend({
1057
- username: z.string(),
1058
- email: z.string(),
1059
- locale: z.string(),
1060
- nickname: z.string(),
1061
- registered_date: z.string(),
1062
- roles: z.array(z.string())
1063
- });
1064
-
1065
- // src/api/auth.ts
1066
697
  var createAuthAPI = (axios2, options) => ({
1067
698
  /**
1068
699
  * Login with username/password and get JWT token
@@ -1085,8 +716,6 @@ var createAuthAPI = (axios2, options) => ({
1085
716
  }
1086
717
  }
1087
718
  });
1088
-
1089
- // src/api/categories.ts
1090
719
  var createCategoriesAPI = (axios2, options) => ({
1091
720
  /**
1092
721
  * Get list of categories with pagination
@@ -1103,8 +732,6 @@ var createCategoriesAPI = (axios2, options) => ({
1103
732
  return handleApiResponse(response, CategorySchema, options);
1104
733
  }
1105
734
  });
1106
-
1107
- // src/api/media.ts
1108
735
  var createMediaAPI = (axios2, options) => ({
1109
736
  /**
1110
737
  * Get single media item by ID
@@ -1114,8 +741,6 @@ var createMediaAPI = (axios2, options) => ({
1114
741
  return handleApiResponse(response, MediaSchema, options);
1115
742
  }
1116
743
  });
1117
-
1118
- // src/api/posts.ts
1119
744
  var createPostsAPI = (axios2, options) => ({
1120
745
  /**
1121
746
  * Get list of posts with pagination
@@ -1142,8 +767,6 @@ var createPostsAPI = (axios2, options) => ({
1142
767
  return posts[0] || null;
1143
768
  }
1144
769
  });
1145
-
1146
- // src/api/users.ts
1147
770
  var createUsersAPI = (axios2, options) => ({
1148
771
  /**
1149
772
  * Get current authenticated user
@@ -1200,6 +823,6 @@ var createClient = (config) => {
1200
823
  return client;
1201
824
  };
1202
825
 
1203
- export { addressSchema as AddressSchema, AvatarUrlsSchema, BaseError, CategoriesListSchema, CategoryParamsSchema, CategorySchema, CurrentUserSchema, ENDPOINTS, EmbeddedPostSchema, EmbeddedPostsListSchema, GuidSchema, HalLinkItemSchema, HalLinksSchema, ImageMetaSchema, JwtErrorResponseSchema, JwtLoginInputSchema, JwtTokenResponseSchema, JwtValidateResponseSchema, MediaDetailsSchema, MediaListSchema, MediaSchema, MediaSizeSchema, MediaSizesSchema, moneySchema as MoneySchema, paginationParamsSchema as PaginationParamsSchema, PostParamsSchema, PostSchema, PostStatusSchema, PostsListSchema, RenderedContentSchema, TagSchema, TagsListSchema, UserSchema, UsersListSchema, WordPressApiError, WordPressBaseSchema, WordPressDataValidationError, calculatePagination, createClient, getPaginationMeta, mapWordPressCode };
826
+ export { BaseError, ENDPOINTS, WordPressApiError, WordPressDataValidationError, calculatePagination, createClient, getPaginationMeta, mapWordPressCode };
1204
827
  //# sourceMappingURL=index.js.map
1205
828
  //# sourceMappingURL=index.js.map