kizlo 0.1.0

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.
Files changed (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/adapters/auth.d.ts +18 -0
  4. package/dist/adapters/auth.js +15 -0
  5. package/dist/adapters/captcha.d.ts +28 -0
  6. package/dist/adapters/captcha.js +86 -0
  7. package/dist/adapters/geo.d.ts +18 -0
  8. package/dist/adapters/geo.js +18 -0
  9. package/dist/adapters/geo.vercel.d.ts +6 -0
  10. package/dist/adapters/geo.vercel.js +41 -0
  11. package/dist/adapters/logger.d.ts +31 -0
  12. package/dist/adapters/logger.js +30 -0
  13. package/dist/cli/banner.js +26 -0
  14. package/dist/cli/commands/generate.js +34 -0
  15. package/dist/cli/commands/init.js +313 -0
  16. package/dist/cli/commands/test.js +68 -0
  17. package/dist/cli/commands/watch.js +53 -0
  18. package/dist/cli/commands/wp.js +66 -0
  19. package/dist/cli/daemon/config.js +87 -0
  20. package/dist/cli/daemon/generate.js +40 -0
  21. package/dist/cli/daemon/lock.js +31 -0
  22. package/dist/cli/daemon/logger.js +8 -0
  23. package/dist/cli/daemon/watch.js +37 -0
  24. package/dist/cli/index.d.ts +1 -0
  25. package/dist/cli/index.js +22 -0
  26. package/dist/cli/presets/base.js +23 -0
  27. package/dist/cli/presets/index.js +16 -0
  28. package/dist/cli/presets/nextjs.js +39 -0
  29. package/dist/cli/utils.js +182 -0
  30. package/dist/cli/wp/bootstrap.js +114 -0
  31. package/dist/cli/wp/compose/docker-compose.yml +73 -0
  32. package/dist/cli/wp/constants.js +52 -0
  33. package/dist/cli/wp/docker.d.ts +24 -0
  34. package/dist/cli/wp/docker.js +69 -0
  35. package/dist/cli/wp/setup.js +39 -0
  36. package/dist/cli/wp/types.d.ts +72 -0
  37. package/dist/cli/wp/types.js +8 -0
  38. package/dist/cli/wp/utils.d.ts +39 -0
  39. package/dist/cli/wp/utils.js +105 -0
  40. package/dist/client.d.ts +24 -0
  41. package/dist/client.js +55 -0
  42. package/dist/comment/errors.js +47 -0
  43. package/dist/comment/index.js +138 -0
  44. package/dist/comment/schema.js +72 -0
  45. package/dist/comment/utils.js +35 -0
  46. package/dist/config.d.ts +39 -0
  47. package/dist/config.js +7 -0
  48. package/dist/context.d.ts +73 -0
  49. package/dist/context.js +145 -0
  50. package/dist/cookie.d.ts +19 -0
  51. package/dist/cookie.js +25 -0
  52. package/dist/email/service.d.ts +11 -0
  53. package/dist/email/service.interface.d.ts +8 -0
  54. package/dist/email/service.js +20 -0
  55. package/dist/index.d.ts +39 -0
  56. package/dist/index.js +31 -0
  57. package/dist/integrations/nextjs/kizlo.client.d.ts +10 -0
  58. package/dist/integrations/nextjs/kizlo.client.js +13 -0
  59. package/dist/integrations/nextjs/kizlo.server.d.ts +12 -0
  60. package/dist/integrations/nextjs/kizlo.server.js +13 -0
  61. package/dist/integrations/nextjs/utils.js +11 -0
  62. package/dist/kizlo.d.ts +73 -0
  63. package/dist/kizlo.js +144 -0
  64. package/dist/menu/errors.js +16 -0
  65. package/dist/menu/fixture.d.ts +8 -0
  66. package/dist/menu/fixture.js +62 -0
  67. package/dist/menu/index.js +70 -0
  68. package/dist/menu/schema.js +70 -0
  69. package/dist/menu/utils.js +57 -0
  70. package/dist/nextjs/server.d.ts +2 -0
  71. package/dist/nextjs/server.js +3 -0
  72. package/dist/nextjs.d.ts +2 -0
  73. package/dist/nextjs.js +3 -0
  74. package/dist/package.js +5 -0
  75. package/dist/post/error.js +30 -0
  76. package/dist/post/fixture.d.ts +8 -0
  77. package/dist/post/fixture.js +71 -0
  78. package/dist/post/index.js +123 -0
  79. package/dist/post/schema.js +120 -0
  80. package/dist/post/utils.js +42 -0
  81. package/dist/post-type/service.js +48 -0
  82. package/dist/router.d.ts +624 -0
  83. package/dist/router.js +15 -0
  84. package/dist/seo/index.js +54 -0
  85. package/dist/seo/schema.d.ts +196 -0
  86. package/dist/seo/schema.js +96 -0
  87. package/dist/seo/types.d.ts +80 -0
  88. package/dist/seo/utils.js +44 -0
  89. package/dist/service.d.ts +17 -0
  90. package/dist/service.js +17 -0
  91. package/dist/shared/constants.js +10 -0
  92. package/dist/shared/contract.d.ts +21 -0
  93. package/dist/shared/contract.js +43 -0
  94. package/dist/shared/crypto.d.ts +28 -0
  95. package/dist/shared/crypto.js +34 -0
  96. package/dist/shared/error.d.ts +128 -0
  97. package/dist/shared/error.js +147 -0
  98. package/dist/shared/extension.d.ts +25 -0
  99. package/dist/shared/extension.js +7 -0
  100. package/dist/shared/identifier.d.ts +11 -0
  101. package/dist/shared/identifier.js +26 -0
  102. package/dist/shared/middleware.d.ts +29 -0
  103. package/dist/shared/procedure.d.ts +114 -0
  104. package/dist/shared/procedure.js +114 -0
  105. package/dist/shared/result.d.ts +24 -0
  106. package/dist/shared/result.js +49 -0
  107. package/dist/shared/router.d.ts +7 -0
  108. package/dist/shared/router.js +26 -0
  109. package/dist/shared/schema.d.ts +55 -0
  110. package/dist/shared/schema.js +43 -0
  111. package/dist/shared/serialize.d.ts +12 -0
  112. package/dist/shared/serialize.js +51 -0
  113. package/dist/shared/types.d.ts +35 -0
  114. package/dist/shared/utils.js +17 -0
  115. package/dist/test/auth.d.ts +7 -0
  116. package/dist/test/auth.js +15 -0
  117. package/dist/test/captcha.d.ts +7 -0
  118. package/dist/test/captcha.js +8 -0
  119. package/dist/test/client.d.ts +11 -0
  120. package/dist/test/client.js +14 -0
  121. package/dist/test/fixtures.d.ts +14 -0
  122. package/dist/test/fixtures.js +13 -0
  123. package/dist/test/server.d.ts +10 -0
  124. package/dist/test/server.js +32 -0
  125. package/dist/test/users.d.ts +14 -0
  126. package/dist/test/users.js +17 -0
  127. package/dist/test.d.ts +12 -0
  128. package/dist/test.js +13 -0
  129. package/dist/webhook/index.d.ts +38 -0
  130. package/dist/webhook/index.js +44 -0
  131. package/dist/webhook/schema.d.ts +45 -0
  132. package/dist/webhook/schema.js +72 -0
  133. package/dist/webhook/utils.js +21 -0
  134. package/dist/wordpress/comment/service.d.ts +28 -0
  135. package/dist/wordpress/comment/service.js +55 -0
  136. package/dist/wordpress/comment/types.d.ts +206 -0
  137. package/dist/wordpress/constants.d.ts +14 -0
  138. package/dist/wordpress/constants.js +13 -0
  139. package/dist/wordpress/error.d.ts +9 -0
  140. package/dist/wordpress/error.js +12 -0
  141. package/dist/wordpress/index.d.ts +15 -0
  142. package/dist/wordpress/menu/items/service.d.ts +28 -0
  143. package/dist/wordpress/menu/items/service.js +55 -0
  144. package/dist/wordpress/menu/items/types.d.ts +214 -0
  145. package/dist/wordpress/menu/service.d.ts +30 -0
  146. package/dist/wordpress/menu/service.js +58 -0
  147. package/dist/wordpress/menu/types.d.ts +115 -0
  148. package/dist/wordpress/post/service.d.ts +28 -0
  149. package/dist/wordpress/post/service.js +55 -0
  150. package/dist/wordpress/post/types.d.ts +290 -0
  151. package/dist/wordpress/service.d.ts +77 -0
  152. package/dist/wordpress/service.js +180 -0
  153. package/dist/wordpress/types.d.ts +67 -0
  154. package/dist/wordpress/user/service.d.ts +28 -0
  155. package/dist/wordpress/user/service.js +55 -0
  156. package/dist/wordpress/user/types.d.ts +221 -0
  157. package/dist/wordpress/utils.d.ts +7 -0
  158. package/dist/wordpress/utils.js +9 -0
  159. package/package.json +109 -0
@@ -0,0 +1,221 @@
1
+ import { WP_Context, WP_Link, WP_ListOrder } from "../types.js";
2
+
3
+ //#region src/wordpress/user/types.d.ts
4
+ /** Sort collection by user attribute. */
5
+ type WP_UserOrderBy = "id" | "include" | "name" | "registered_date" | "slug" | "include_slugs" | "email" | "url";
6
+ /** Limit result set to users who are considered authors. */
7
+ type WP_UserWho = "authors";
8
+ /** Avatar URLs for the user, keyed by image size in pixels (e.g. "24", "48", "96"). */
9
+ type WP_UserAvatarUrls = Record<string, string>;
10
+ /** All capabilities assigned to the user, keyed by capability name. */
11
+ type WP_UserCapabilities = Record<string, boolean>;
12
+ /** Hypermedia links for the user resource. */
13
+ interface WP_UserLinks {
14
+ self?: WP_Link[];
15
+ collection?: WP_Link[];
16
+ author?: WP_Link[];
17
+ [rel: string]: WP_Link[] | undefined;
18
+ }
19
+ interface WP_User {
20
+ /** Unique identifier for the user. */
21
+ id: number;
22
+ /** Login name for the user. */
23
+ username: string;
24
+ /** Display name for the user. */
25
+ name: string;
26
+ /** First name for the user. */
27
+ first_name: string;
28
+ /** Last name for the user. */
29
+ last_name: string;
30
+ /** The email address for the user. */
31
+ email: string;
32
+ /** URL of the user. */
33
+ url: string;
34
+ /** Description of the user. */
35
+ description: string;
36
+ /** Author URL of the user. */
37
+ link: string;
38
+ /** Locale for the user. */
39
+ locale: string;
40
+ /** The nickname for the user. */
41
+ nickname: string;
42
+ /** An alphanumeric identifier for the user. */
43
+ slug: string;
44
+ /** Registration date for the user. */
45
+ registered_date: string;
46
+ /** Roles assigned to the user. */
47
+ roles: string[];
48
+ /** All capabilities assigned to the user. */
49
+ capabilities: WP_UserCapabilities;
50
+ /** Any extra capabilities assigned to the user. */
51
+ extra_capabilities: WP_UserCapabilities;
52
+ /** Avatar URLs for the user. */
53
+ avatar_urls: WP_UserAvatarUrls;
54
+ /** Meta fields. */
55
+ meta: Record<string, unknown>;
56
+ /** Hypermedia links. */
57
+ _links?: WP_UserLinks;
58
+ }
59
+ interface WP_UserListInput {
60
+ /** Scope under which the request is made; determines fields present in response. */
61
+ context?: WP_Context;
62
+ /** Current page of the collection. */
63
+ page?: number;
64
+ /** Maximum number of items to be returned in result set. */
65
+ per_page?: number;
66
+ /** Limit results to those matching a string. */
67
+ search?: string;
68
+ /** Ensure result set excludes specific IDs. */
69
+ exclude?: number | number[];
70
+ /** Limit result set to specific IDs. */
71
+ include?: number | number[];
72
+ /** Offset the result set by a specific number of items. */
73
+ offset?: number;
74
+ /** Order sort attribute ascending or descending. */
75
+ order?: WP_ListOrder;
76
+ /** Sort collection by user attribute. */
77
+ orderby?: WP_UserOrderBy;
78
+ /** Limit result set to users with one or more specific slugs. */
79
+ slug?: string | string[];
80
+ /** Limit result set to users matching at least one specific role provided. Accepts csv list or single role. */
81
+ roles?: string | string[];
82
+ /** Limit result set to users matching at least one specific capability provided. Accepts csv list or single capability. */
83
+ capabilities?: string | string[];
84
+ /** Limit result set to users who are considered authors. */
85
+ who?: WP_UserWho;
86
+ /** Limit result set to users who have published posts. */
87
+ has_published_posts?: boolean | string[];
88
+ }
89
+ type WP_UserListErrorCode = "rest_forbidden_context" | "rest_forbidden_orderby" | "rest_forbidden_who" | "rest_user_cannot_view";
90
+ interface WP_UserCreateInput {
91
+ /** Login name for the user. */
92
+ username?: string;
93
+ /** Display name for the user. */
94
+ name?: string;
95
+ /** First name for the user. */
96
+ first_name?: string;
97
+ /** Last name for the user. */
98
+ last_name?: string;
99
+ /** The email address for the user. */
100
+ email?: string;
101
+ /** URL of the user. */
102
+ url?: string;
103
+ /** Description of the user. */
104
+ description?: string;
105
+ /** Locale for the user. */
106
+ locale?: string;
107
+ /** The nickname for the user. */
108
+ nickname?: string;
109
+ /** An alphanumeric identifier for the user. */
110
+ slug?: string;
111
+ /** Roles assigned to the user. */
112
+ roles?: string[];
113
+ /** Password for the user (never included). */
114
+ password?: string;
115
+ /** Meta fields. */
116
+ meta?: Record<string, unknown>;
117
+ }
118
+ type WP_UserCreateErrorCode = "rest_user_exists" | "rest_user_invalid_password" | "rest_user_invalid_role" | "rest_user_invalid_username" | "rest_cannot_create_user";
119
+ interface WP_UserRetrieveInput {
120
+ /** Unique identifier for the user. */
121
+ id: number;
122
+ /** Scope under which the request is made; determines fields present in response. */
123
+ context?: WP_Context;
124
+ }
125
+ type WP_UserRetrieveErrorCode = "rest_forbidden_context" | "rest_user_cannot_view" | "rest_user_invalid_id";
126
+ interface WP_UserUpdateInput {
127
+ /** Unique identifier for the user. */
128
+ id: number;
129
+ /** Login name for the user. */
130
+ username?: string;
131
+ /** Display name for the user. */
132
+ name?: string;
133
+ /** First name for the user. */
134
+ first_name?: string;
135
+ /** Last name for the user. */
136
+ last_name?: string;
137
+ /** The email address for the user. */
138
+ email?: string;
139
+ /** URL of the user. */
140
+ url?: string;
141
+ /** Description of the user. */
142
+ description?: string;
143
+ /** Locale for the user. */
144
+ locale?: string;
145
+ /** The nickname for the user. */
146
+ nickname?: string;
147
+ /** An alphanumeric identifier for the user. */
148
+ slug?: string;
149
+ /** Roles assigned to the user. */
150
+ roles?: string[];
151
+ /** Password for the user (never included). */
152
+ password?: string;
153
+ /** Meta fields. */
154
+ meta?: Record<string, unknown>;
155
+ }
156
+ type WP_UserUpdateErrorCode = "rest_user_invalid_argument" | "rest_user_invalid_email" | "rest_user_invalid_password" | "rest_user_invalid_role" | "rest_user_invalid_slug" | "rest_user_invalid_username" | "rest_cannot_edit" | "rest_cannot_edit_roles" | "rest_user_invalid_id";
157
+ interface WP_UserDeleteInput {
158
+ /** Unique identifier for the user. */
159
+ id: number;
160
+ /** Required to be true, as users do not support trashing. */
161
+ force?: boolean;
162
+ /** Reassign the deleted user's posts and links to this user ID. */
163
+ reassign?: number;
164
+ }
165
+ /**
166
+ * Response from `DELETE /wp/v2/users/<id>`.
167
+ * Users do not support trashing, so `force=true` is required and the response
168
+ * is always `{ deleted: true, previous: WP_User }`.
169
+ */
170
+ type WP_UserDeleteResponse = {
171
+ deleted: true;
172
+ previous: WP_User;
173
+ };
174
+ type WP_UserDeleteErrorCode = "rest_user_invalid_reassign" | "rest_user_cannot_delete" | "rest_user_invalid_id" | "rest_cannot_delete" | "rest_trash_not_supported";
175
+ interface WP_UserRetrieveMeInput {
176
+ /** Scope under which the request is made; determines fields present in response. */
177
+ context?: WP_Context;
178
+ }
179
+ type WP_UserRetrieveMeErrorCode = "rest_not_logged_in";
180
+ interface WP_UserUpdateMeInput {
181
+ /** Login name for the user. */
182
+ username?: string;
183
+ /** Display name for the user. */
184
+ name?: string;
185
+ /** First name for the user. */
186
+ first_name?: string;
187
+ /** Last name for the user. */
188
+ last_name?: string;
189
+ /** The email address for the user. */
190
+ email?: string;
191
+ /** URL of the user. */
192
+ url?: string;
193
+ /** Description of the user. */
194
+ description?: string;
195
+ /** Locale for the user. */
196
+ locale?: string;
197
+ /** The nickname for the user. */
198
+ nickname?: string;
199
+ /** An alphanumeric identifier for the user. */
200
+ slug?: string;
201
+ /** Roles assigned to the user. */
202
+ roles?: string[];
203
+ /** Password for the user (never included). */
204
+ password?: string;
205
+ /** Meta fields. */
206
+ meta?: Record<string, unknown>;
207
+ }
208
+ type WP_UserUpdateMeErrorCode = "rest_user_invalid_argument" | "rest_user_invalid_email" | "rest_user_invalid_password" | "rest_user_invalid_role" | "rest_user_invalid_slug" | "rest_user_invalid_username" | "rest_not_logged_in" | "rest_cannot_edit" | "rest_cannot_edit_roles";
209
+ interface WP_UserDeleteMeInput {
210
+ /** Required to be true, as users do not support trashing. */
211
+ force?: boolean;
212
+ /** Reassign the deleted user's posts and links to this user ID. */
213
+ reassign?: number;
214
+ }
215
+ type WP_UserDeleteMeResponse = {
216
+ deleted: true;
217
+ previous: WP_User;
218
+ };
219
+ type WP_UserDeleteMeErrorCode = "rest_user_invalid_reassign" | "rest_not_logged_in" | "rest_user_cannot_delete" | "rest_cannot_delete" | "rest_trash_not_supported";
220
+ //#endregion
221
+ export { WP_User, WP_UserAvatarUrls, WP_UserCapabilities, WP_UserCreateErrorCode, WP_UserCreateInput, WP_UserDeleteErrorCode, WP_UserDeleteInput, WP_UserDeleteMeErrorCode, WP_UserDeleteMeInput, WP_UserDeleteMeResponse, WP_UserDeleteResponse, WP_UserLinks, WP_UserListErrorCode, WP_UserListInput, WP_UserOrderBy, WP_UserRetrieveErrorCode, WP_UserRetrieveInput, WP_UserRetrieveMeErrorCode, WP_UserRetrieveMeInput, WP_UserUpdateErrorCode, WP_UserUpdateInput, WP_UserUpdateMeErrorCode, WP_UserUpdateMeInput, WP_UserWho };
@@ -0,0 +1,7 @@
1
+ //#region src/wordpress/utils.d.ts
2
+ declare function isWordPressResourceError<TCode extends string>(data: unknown): data is {
3
+ code: TCode;
4
+ message: string;
5
+ };
6
+ //#endregion
7
+ export { isWordPressResourceError };
@@ -0,0 +1,9 @@
1
+ //#region src/wordpress/utils.ts
2
+ function isWordPressResourceError(data) {
3
+ if (typeof data !== "object" || data === null) return false;
4
+ const record = data;
5
+ return typeof record.code === "string" && typeof record.message === "string";
6
+ }
7
+
8
+ //#endregion
9
+ export { isWordPressResourceError };
package/package.json ADDED
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "kizlo",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "A headless WordPress toolkit for TypeScript.",
6
+ "keywords": [
7
+ "wordpress",
8
+ "headless",
9
+ "headless-wordpress",
10
+ "headless-cms",
11
+ "wordpress-api",
12
+ "rest-api",
13
+ "typescript",
14
+ "nextjs",
15
+ "sdk"
16
+ ],
17
+ "license": "MIT",
18
+ "author": "Kizlo",
19
+ "homepage": "https://github.com/kizlo-io/kizlo/tree/main/packages/kizlo#readme",
20
+ "bugs": "https://github.com/kizlo-io/kizlo/issues",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/kizlo-io/kizlo.git",
24
+ "directory": "packages/kizlo"
25
+ },
26
+ "engines": {
27
+ "node": ">=22.14.0"
28
+ },
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "bin": {
33
+ "kizlo": "./dist/cli/index.js"
34
+ },
35
+ "exports": {
36
+ "./package.json": "./package.json",
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ }
42
+ },
43
+ "./config": {
44
+ "import": {
45
+ "types": "./dist/config.d.ts",
46
+ "default": "./dist/config.js"
47
+ }
48
+ },
49
+ "./test": {
50
+ "import": {
51
+ "types": "./dist/test.d.ts",
52
+ "default": "./dist/test.js"
53
+ }
54
+ },
55
+ "./nextjs": {
56
+ "import": {
57
+ "types": "./dist/nextjs.d.ts",
58
+ "default": "./dist/nextjs.js"
59
+ }
60
+ },
61
+ "./nextjs/server": {
62
+ "import": {
63
+ "types": "./dist/nextjs/server.d.ts",
64
+ "default": "./dist/nextjs/server.js"
65
+ }
66
+ }
67
+ },
68
+ "files": [
69
+ "dist"
70
+ ],
71
+ "sideEffects": [
72
+ "./dist/cli/**"
73
+ ],
74
+ "publishConfig": {
75
+ "access": "public"
76
+ },
77
+ "dependencies": {
78
+ "@clack/prompts": "^1.5.1",
79
+ "@kizlo/shared": "0.1.0",
80
+ "@orpc/client": "^1.14.3",
81
+ "@orpc/contract": "^1.14.3",
82
+ "@orpc/openapi": "^1.14.3",
83
+ "@orpc/openapi-client": "^1.14.3",
84
+ "@orpc/server": "^1.14.3",
85
+ "chokidar": "^5.0.0",
86
+ "citty": "^0.1.6",
87
+ "consola": "^3.2.3",
88
+ "cookie": "^1.0.2",
89
+ "jiti": "^2.7.0",
90
+ "jose": "6.1.0",
91
+ "zod": "^4.3.6"
92
+ },
93
+ "peerDependencies": {
94
+ "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
95
+ "react": "^18.0.0 || ^19.0.0",
96
+ "react-dom": "^18.0.0 || ^19.0.0"
97
+ },
98
+ "peerDependenciesMeta": {
99
+ "next": {
100
+ "optional": true
101
+ },
102
+ "react": {
103
+ "optional": true
104
+ },
105
+ "react-dom": {
106
+ "optional": true
107
+ }
108
+ }
109
+ }