@aurora-interactive/sensei-productivity 1.2.0 → 1.4.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 (255) hide show
  1. package/README.md +28 -0
  2. package/dist/commonjs/funcs/users-friends-accept.d.ts +14 -0
  3. package/dist/commonjs/funcs/users-friends-accept.d.ts.map +1 -0
  4. package/dist/commonjs/funcs/users-friends-accept.js +127 -0
  5. package/dist/commonjs/funcs/users-friends-accept.js.map +1 -0
  6. package/dist/commonjs/funcs/users-friends-list.d.ts +14 -0
  7. package/dist/commonjs/funcs/users-friends-list.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/users-friends-list.js +128 -0
  9. package/dist/commonjs/funcs/users-friends-list.js.map +1 -0
  10. package/dist/commonjs/funcs/users-friends-pending.d.ts +14 -0
  11. package/dist/commonjs/funcs/users-friends-pending.d.ts.map +1 -0
  12. package/dist/commonjs/funcs/users-friends-pending.js +113 -0
  13. package/dist/commonjs/funcs/users-friends-pending.js.map +1 -0
  14. package/dist/commonjs/funcs/users-friends-reject.d.ts +14 -0
  15. package/dist/commonjs/funcs/users-friends-reject.d.ts.map +1 -0
  16. package/dist/commonjs/funcs/users-friends-reject.js +127 -0
  17. package/dist/commonjs/funcs/users-friends-reject.js.map +1 -0
  18. package/dist/commonjs/funcs/users-friends-remove.d.ts +14 -0
  19. package/dist/commonjs/funcs/users-friends-remove.d.ts.map +1 -0
  20. package/dist/commonjs/funcs/users-friends-remove.js +127 -0
  21. package/dist/commonjs/funcs/users-friends-remove.js.map +1 -0
  22. package/dist/commonjs/funcs/users-friends-send-request.d.ts +14 -0
  23. package/dist/commonjs/funcs/users-friends-send-request.d.ts.map +1 -0
  24. package/dist/commonjs/funcs/users-friends-send-request.js +127 -0
  25. package/dist/commonjs/funcs/users-friends-send-request.js.map +1 -0
  26. package/dist/commonjs/funcs/users-posts-delete.d.ts +14 -0
  27. package/dist/commonjs/funcs/users-posts-delete.d.ts.map +1 -0
  28. package/dist/commonjs/funcs/users-posts-delete.js +127 -0
  29. package/dist/commonjs/funcs/users-posts-delete.js.map +1 -0
  30. package/dist/commonjs/funcs/users-posts-feed.d.ts +14 -0
  31. package/dist/commonjs/funcs/users-posts-feed.d.ts.map +1 -0
  32. package/dist/commonjs/funcs/users-posts-feed.js +127 -0
  33. package/dist/commonjs/funcs/users-posts-feed.js.map +1 -0
  34. package/dist/commonjs/funcs/users-posts-get-by-post-id.d.ts +14 -0
  35. package/dist/commonjs/funcs/users-posts-get-by-post-id.d.ts.map +1 -0
  36. package/dist/commonjs/funcs/users-posts-get-by-post-id.js +128 -0
  37. package/dist/commonjs/funcs/users-posts-get-by-post-id.js.map +1 -0
  38. package/dist/commonjs/funcs/users-posts-get-by-user-id.d.ts +14 -0
  39. package/dist/commonjs/funcs/users-posts-get-by-user-id.d.ts.map +1 -0
  40. package/dist/commonjs/funcs/users-posts-get-by-user-id.js +128 -0
  41. package/dist/commonjs/funcs/users-posts-get-by-user-id.js.map +1 -0
  42. package/dist/commonjs/funcs/users-posts-update.d.ts +14 -0
  43. package/dist/commonjs/funcs/users-posts-update.d.ts.map +1 -0
  44. package/dist/commonjs/funcs/users-posts-update.js +129 -0
  45. package/dist/commonjs/funcs/users-posts-update.js.map +1 -0
  46. package/dist/commonjs/lib/config.d.ts +4 -4
  47. package/dist/commonjs/lib/config.js +4 -4
  48. package/dist/commonjs/models/operations/accept-friend-request.d.ts +15 -0
  49. package/dist/commonjs/models/operations/accept-friend-request.d.ts.map +1 -0
  50. package/dist/commonjs/models/operations/accept-friend-request.js +49 -0
  51. package/dist/commonjs/models/operations/accept-friend-request.js.map +1 -0
  52. package/dist/commonjs/models/operations/delete-post.d.ts +12 -0
  53. package/dist/commonjs/models/operations/delete-post.d.ts.map +1 -0
  54. package/dist/commonjs/models/operations/delete-post.js +49 -0
  55. package/dist/commonjs/models/operations/delete-post.js.map +1 -0
  56. package/dist/commonjs/models/operations/get-feed.d.ts +49 -0
  57. package/dist/commonjs/models/operations/get-feed.d.ts.map +1 -0
  58. package/dist/commonjs/models/operations/get-feed.js +85 -0
  59. package/dist/commonjs/models/operations/get-feed.js.map +1 -0
  60. package/dist/commonjs/models/operations/get-post-by-id.d.ts +38 -0
  61. package/dist/commonjs/models/operations/get-post-by-id.d.ts.map +1 -0
  62. package/dist/commonjs/models/operations/get-post-by-id.js +73 -0
  63. package/dist/commonjs/models/operations/get-post-by-id.js.map +1 -0
  64. package/dist/commonjs/models/operations/get-user-posts.d.ts +35 -0
  65. package/dist/commonjs/models/operations/get-user-posts.d.ts.map +1 -0
  66. package/dist/commonjs/models/operations/get-user-posts.js +73 -0
  67. package/dist/commonjs/models/operations/get-user-posts.js.map +1 -0
  68. package/dist/commonjs/models/operations/index.d.ts +11 -0
  69. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  70. package/dist/commonjs/models/operations/index.js +11 -0
  71. package/dist/commonjs/models/operations/index.js.map +1 -1
  72. package/dist/commonjs/models/operations/list-friends.d.ts +26 -0
  73. package/dist/commonjs/models/operations/list-friends.d.ts.map +1 -0
  74. package/dist/commonjs/models/operations/list-friends.js +65 -0
  75. package/dist/commonjs/models/operations/list-friends.js.map +1 -0
  76. package/dist/commonjs/models/operations/pending-friend-requests.d.ts +16 -0
  77. package/dist/commonjs/models/operations/pending-friend-requests.d.ts.map +1 -0
  78. package/dist/commonjs/models/operations/pending-friend-requests.js +57 -0
  79. package/dist/commonjs/models/operations/pending-friend-requests.js.map +1 -0
  80. package/dist/commonjs/models/operations/reject-friend-request.d.ts +15 -0
  81. package/dist/commonjs/models/operations/reject-friend-request.d.ts.map +1 -0
  82. package/dist/commonjs/models/operations/reject-friend-request.js +49 -0
  83. package/dist/commonjs/models/operations/reject-friend-request.js.map +1 -0
  84. package/dist/commonjs/models/operations/remove-friend.d.ts +12 -0
  85. package/dist/commonjs/models/operations/remove-friend.d.ts.map +1 -0
  86. package/dist/commonjs/models/operations/remove-friend.js +49 -0
  87. package/dist/commonjs/models/operations/remove-friend.js.map +1 -0
  88. package/dist/commonjs/models/operations/send-friend-request.d.ts +12 -0
  89. package/dist/commonjs/models/operations/send-friend-request.d.ts.map +1 -0
  90. package/dist/commonjs/models/operations/send-friend-request.js +49 -0
  91. package/dist/commonjs/models/operations/send-friend-request.js.map +1 -0
  92. package/dist/commonjs/models/operations/update-post.d.ts +60 -0
  93. package/dist/commonjs/models/operations/update-post.d.ts.map +1 -0
  94. package/dist/commonjs/models/operations/update-post.js +90 -0
  95. package/dist/commonjs/models/operations/update-post.js.map +1 -0
  96. package/dist/commonjs/sdk/friends.d.ts +29 -0
  97. package/dist/commonjs/sdk/friends.d.ts.map +1 -0
  98. package/dist/commonjs/sdk/friends.js +54 -0
  99. package/dist/commonjs/sdk/friends.js.map +1 -0
  100. package/dist/commonjs/sdk/posts.d.ts +25 -0
  101. package/dist/commonjs/sdk/posts.d.ts.map +1 -0
  102. package/dist/commonjs/sdk/posts.js +47 -0
  103. package/dist/commonjs/sdk/posts.js.map +1 -0
  104. package/dist/commonjs/sdk/users.d.ts +6 -0
  105. package/dist/commonjs/sdk/users.d.ts.map +1 -1
  106. package/dist/commonjs/sdk/users.js +8 -0
  107. package/dist/commonjs/sdk/users.js.map +1 -1
  108. package/dist/esm/funcs/users-friends-accept.d.ts +14 -0
  109. package/dist/esm/funcs/users-friends-accept.d.ts.map +1 -0
  110. package/dist/esm/funcs/users-friends-accept.js +91 -0
  111. package/dist/esm/funcs/users-friends-accept.js.map +1 -0
  112. package/dist/esm/funcs/users-friends-list.d.ts +14 -0
  113. package/dist/esm/funcs/users-friends-list.d.ts.map +1 -0
  114. package/dist/esm/funcs/users-friends-list.js +92 -0
  115. package/dist/esm/funcs/users-friends-list.js.map +1 -0
  116. package/dist/esm/funcs/users-friends-pending.d.ts +14 -0
  117. package/dist/esm/funcs/users-friends-pending.d.ts.map +1 -0
  118. package/dist/esm/funcs/users-friends-pending.js +77 -0
  119. package/dist/esm/funcs/users-friends-pending.js.map +1 -0
  120. package/dist/esm/funcs/users-friends-reject.d.ts +14 -0
  121. package/dist/esm/funcs/users-friends-reject.d.ts.map +1 -0
  122. package/dist/esm/funcs/users-friends-reject.js +91 -0
  123. package/dist/esm/funcs/users-friends-reject.js.map +1 -0
  124. package/dist/esm/funcs/users-friends-remove.d.ts +14 -0
  125. package/dist/esm/funcs/users-friends-remove.d.ts.map +1 -0
  126. package/dist/esm/funcs/users-friends-remove.js +91 -0
  127. package/dist/esm/funcs/users-friends-remove.js.map +1 -0
  128. package/dist/esm/funcs/users-friends-send-request.d.ts +14 -0
  129. package/dist/esm/funcs/users-friends-send-request.d.ts.map +1 -0
  130. package/dist/esm/funcs/users-friends-send-request.js +91 -0
  131. package/dist/esm/funcs/users-friends-send-request.js.map +1 -0
  132. package/dist/esm/funcs/users-posts-delete.d.ts +14 -0
  133. package/dist/esm/funcs/users-posts-delete.d.ts.map +1 -0
  134. package/dist/esm/funcs/users-posts-delete.js +91 -0
  135. package/dist/esm/funcs/users-posts-delete.js.map +1 -0
  136. package/dist/esm/funcs/users-posts-feed.d.ts +14 -0
  137. package/dist/esm/funcs/users-posts-feed.d.ts.map +1 -0
  138. package/dist/esm/funcs/users-posts-feed.js +91 -0
  139. package/dist/esm/funcs/users-posts-feed.js.map +1 -0
  140. package/dist/esm/funcs/users-posts-get-by-post-id.d.ts +14 -0
  141. package/dist/esm/funcs/users-posts-get-by-post-id.d.ts.map +1 -0
  142. package/dist/esm/funcs/users-posts-get-by-post-id.js +92 -0
  143. package/dist/esm/funcs/users-posts-get-by-post-id.js.map +1 -0
  144. package/dist/esm/funcs/users-posts-get-by-user-id.d.ts +14 -0
  145. package/dist/esm/funcs/users-posts-get-by-user-id.d.ts.map +1 -0
  146. package/dist/esm/funcs/users-posts-get-by-user-id.js +92 -0
  147. package/dist/esm/funcs/users-posts-get-by-user-id.js.map +1 -0
  148. package/dist/esm/funcs/users-posts-update.d.ts +14 -0
  149. package/dist/esm/funcs/users-posts-update.d.ts.map +1 -0
  150. package/dist/esm/funcs/users-posts-update.js +93 -0
  151. package/dist/esm/funcs/users-posts-update.js.map +1 -0
  152. package/dist/esm/lib/config.d.ts +4 -4
  153. package/dist/esm/lib/config.js +4 -4
  154. package/dist/esm/models/operations/accept-friend-request.d.ts +15 -0
  155. package/dist/esm/models/operations/accept-friend-request.d.ts.map +1 -0
  156. package/dist/esm/models/operations/accept-friend-request.js +12 -0
  157. package/dist/esm/models/operations/accept-friend-request.js.map +1 -0
  158. package/dist/esm/models/operations/delete-post.d.ts +12 -0
  159. package/dist/esm/models/operations/delete-post.d.ts.map +1 -0
  160. package/dist/esm/models/operations/delete-post.js +12 -0
  161. package/dist/esm/models/operations/delete-post.js.map +1 -0
  162. package/dist/esm/models/operations/get-feed.d.ts +49 -0
  163. package/dist/esm/models/operations/get-feed.d.ts.map +1 -0
  164. package/dist/esm/models/operations/get-feed.js +46 -0
  165. package/dist/esm/models/operations/get-feed.js.map +1 -0
  166. package/dist/esm/models/operations/get-post-by-id.d.ts +38 -0
  167. package/dist/esm/models/operations/get-post-by-id.d.ts.map +1 -0
  168. package/dist/esm/models/operations/get-post-by-id.js +35 -0
  169. package/dist/esm/models/operations/get-post-by-id.js.map +1 -0
  170. package/dist/esm/models/operations/get-user-posts.d.ts +35 -0
  171. package/dist/esm/models/operations/get-user-posts.d.ts.map +1 -0
  172. package/dist/esm/models/operations/get-user-posts.js +35 -0
  173. package/dist/esm/models/operations/get-user-posts.js.map +1 -0
  174. package/dist/esm/models/operations/index.d.ts +11 -0
  175. package/dist/esm/models/operations/index.d.ts.map +1 -1
  176. package/dist/esm/models/operations/index.js +11 -0
  177. package/dist/esm/models/operations/index.js.map +1 -1
  178. package/dist/esm/models/operations/list-friends.d.ts +26 -0
  179. package/dist/esm/models/operations/list-friends.d.ts.map +1 -0
  180. package/dist/esm/models/operations/list-friends.js +27 -0
  181. package/dist/esm/models/operations/list-friends.js.map +1 -0
  182. package/dist/esm/models/operations/pending-friend-requests.d.ts +16 -0
  183. package/dist/esm/models/operations/pending-friend-requests.d.ts.map +1 -0
  184. package/dist/esm/models/operations/pending-friend-requests.js +20 -0
  185. package/dist/esm/models/operations/pending-friend-requests.js.map +1 -0
  186. package/dist/esm/models/operations/reject-friend-request.d.ts +15 -0
  187. package/dist/esm/models/operations/reject-friend-request.d.ts.map +1 -0
  188. package/dist/esm/models/operations/reject-friend-request.js +12 -0
  189. package/dist/esm/models/operations/reject-friend-request.js.map +1 -0
  190. package/dist/esm/models/operations/remove-friend.d.ts +12 -0
  191. package/dist/esm/models/operations/remove-friend.d.ts.map +1 -0
  192. package/dist/esm/models/operations/remove-friend.js +12 -0
  193. package/dist/esm/models/operations/remove-friend.js.map +1 -0
  194. package/dist/esm/models/operations/send-friend-request.d.ts +12 -0
  195. package/dist/esm/models/operations/send-friend-request.d.ts.map +1 -0
  196. package/dist/esm/models/operations/send-friend-request.js +12 -0
  197. package/dist/esm/models/operations/send-friend-request.js.map +1 -0
  198. package/dist/esm/models/operations/update-post.d.ts +60 -0
  199. package/dist/esm/models/operations/update-post.d.ts.map +1 -0
  200. package/dist/esm/models/operations/update-post.js +51 -0
  201. package/dist/esm/models/operations/update-post.js.map +1 -0
  202. package/dist/esm/sdk/friends.d.ts +29 -0
  203. package/dist/esm/sdk/friends.d.ts.map +1 -0
  204. package/dist/esm/sdk/friends.js +50 -0
  205. package/dist/esm/sdk/friends.js.map +1 -0
  206. package/dist/esm/sdk/posts.d.ts +25 -0
  207. package/dist/esm/sdk/posts.d.ts.map +1 -0
  208. package/dist/esm/sdk/posts.js +43 -0
  209. package/dist/esm/sdk/posts.js.map +1 -0
  210. package/dist/esm/sdk/users.d.ts +6 -0
  211. package/dist/esm/sdk/users.d.ts.map +1 -1
  212. package/dist/esm/sdk/users.js +8 -0
  213. package/dist/esm/sdk/users.js.map +1 -1
  214. package/jsr.json +1 -1
  215. package/package.json +1 -1
  216. package/rest-api/cypress/e2e/activity-post-endpoints.cy.js +239 -0
  217. package/rest-api/cypress/e2e/friend-endpoints.cy.js +262 -0
  218. package/rest-api/cypress/e2e/{school-endpoints.cy.ts → school-endpoints.cy.js} +1 -1
  219. package/rest-api/cypress/e2e/{user-activity-endpoints.cy.ts → user-activity-endpoints.cy.js} +8 -20
  220. package/rest-api/cypress/e2e/{user-endpoints.cy.ts → user-endpoints.cy.js} +3 -3
  221. package/rest-api/cypress.config.ts +70 -21
  222. package/rest-api/index.js +20 -7
  223. package/rest-api/lib/users.js +35 -0
  224. package/rest-api/routes/ActivityPostFunctions.js +208 -0
  225. package/rest-api/routes/FriendFunctions.js +266 -0
  226. package/rest-api/routes/UserActivityFunctions.js +2 -34
  227. package/rest-api/routes/UserFunctions.js +30 -24
  228. package/src/funcs/users-friends-accept.ts +176 -0
  229. package/src/funcs/users-friends-list.ts +182 -0
  230. package/src/funcs/users-friends-pending.ts +162 -0
  231. package/src/funcs/users-friends-reject.ts +176 -0
  232. package/src/funcs/users-friends-remove.ts +175 -0
  233. package/src/funcs/users-friends-send-request.ts +176 -0
  234. package/src/funcs/users-posts-delete.ts +175 -0
  235. package/src/funcs/users-posts-feed.ts +176 -0
  236. package/src/funcs/users-posts-get-by-post-id.ts +179 -0
  237. package/src/funcs/users-posts-get-by-user-id.ts +182 -0
  238. package/src/funcs/users-posts-update.ts +180 -0
  239. package/src/lib/config.ts +4 -4
  240. package/src/models/operations/accept-friend-request.ts +33 -0
  241. package/src/models/operations/delete-post.ts +30 -0
  242. package/src/models/operations/get-feed.ts +110 -0
  243. package/src/models/operations/get-post-by-id.ts +86 -0
  244. package/src/models/operations/get-user-posts.ts +83 -0
  245. package/src/models/operations/index.ts +11 -0
  246. package/src/models/operations/list-friends.ts +68 -0
  247. package/src/models/operations/pending-friend-requests.ts +43 -0
  248. package/src/models/operations/reject-friend-request.ts +33 -0
  249. package/src/models/operations/remove-friend.ts +30 -0
  250. package/src/models/operations/send-friend-request.ts +30 -0
  251. package/src/models/operations/update-post.ts +131 -0
  252. package/src/sdk/friends.ts +97 -0
  253. package/src/sdk/posts.ts +84 -0
  254. package/src/sdk/users.ts +12 -0
  255. /package/rest-api/cypress/e2e/{category-endpoints.cy.ts → category-endpoints.cy.js} +0 -0
@@ -3,27 +3,23 @@ import { randomBytes } from "node:crypto";
3
3
 
4
4
  async function getUserProfile(prisma, userId = null, accessToken = null) {
5
5
  return await prisma.users.findFirst({
6
- include: {
7
- school: true
8
- },
9
- // TODO: optimize this section to minimize data transfer
10
- // Ex: we don't need to select *all* of the school info
11
- // and *all* of the user info
12
- // but Prisma ORM doesn't currently allow both `select` and `include` at the same time
13
-
14
- // select: {
15
- // user_id: true,
16
- // username: true,
17
- // first_name: true,
18
- // last_name: true,
19
- // email: true,
20
- // school_id: true,
21
- // school_name: true
22
- // },
23
6
  where: {
24
- access_token: accessToken !== null ? accessToken : undefined,
25
- user_id: userId !== null ? userId : undefined,
7
+ access_token: accessToken ?? undefined,
8
+ user_id: userId ?? undefined,
26
9
  is_soft_deleted: false
10
+ },
11
+ select: {
12
+ user_id: true,
13
+ username: true,
14
+ first_name: true,
15
+ last_name: true,
16
+ email: true,
17
+ school: {
18
+ select: {
19
+ school_id: true,
20
+ school_name: true
21
+ }
22
+ }
27
23
  }
28
24
  });
29
25
  }
@@ -108,7 +104,7 @@ export async function getCurrentUserHandler(request, reply, fastify) {
108
104
  userId: user.user_id,
109
105
  firstName: user.first_name,
110
106
  lastName: user.last_name,
111
- schoolId: user.school_id,
107
+ schoolId: user.school.school_id,
112
108
  email: user.email,
113
109
  username: user.username,
114
110
  schoolName: user.school.school_name
@@ -132,7 +128,7 @@ export async function getUserByIdHandler(request, reply, fastify) {
132
128
  userId: user.user_id,
133
129
  firstName: user.first_name,
134
130
  lastName: user.last_name,
135
- schoolId: user.school_id,
131
+ schoolId: user.school.school_id,
136
132
  email: user.email,
137
133
  username: user.username,
138
134
  schoolName: user.school.school_name
@@ -158,8 +154,18 @@ export async function updateUserHandler(request, reply, fastify) {
158
154
  }
159
155
 
160
156
  const userInfo = await fastify.prisma.users.findFirst({
161
- include: {
162
- school: true
157
+ select: {
158
+ user_id: true,
159
+ username: true,
160
+ first_name: true,
161
+ last_name: true,
162
+ email: true,
163
+ school: {
164
+ select: {
165
+ school_id: true,
166
+ school_name: true,
167
+ }
168
+ }
163
169
  },
164
170
  where: {
165
171
  access_token: request.headers.authorization.substring(7)
@@ -197,7 +203,7 @@ export async function updateUserHandler(request, reply, fastify) {
197
203
  firstName: targetFirstName,
198
204
  lastName: targetLastName,
199
205
  email: userInfo.email,
200
- schoolId: userInfo.school_id,
206
+ schoolId: userInfo.school.school_id,
201
207
  schoolName: userInfo.school.school_name
202
208
  };
203
209
  }
@@ -0,0 +1,176 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { SenseiProductivityCore } from "../core.js";
7
+ import { encodeSimple } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/http-client-errors.js";
21
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
22
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
23
+ import { SenseiProductivityError } from "../models/errors/sensei-productivity-error.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Accept a pending friend request
30
+ */
31
+ export function usersFriendsAccept(
32
+ client: SenseiProductivityCore,
33
+ request: operations.AcceptFriendRequestRequest,
34
+ options?: RequestOptions,
35
+ ): APIPromise<
36
+ Result<
37
+ void,
38
+ | SenseiProductivityError
39
+ | ResponseValidationError
40
+ | ConnectionError
41
+ | RequestAbortedError
42
+ | RequestTimeoutError
43
+ | InvalidRequestError
44
+ | UnexpectedClientError
45
+ | SDKValidationError
46
+ >
47
+ > {
48
+ return new APIPromise($do(
49
+ client,
50
+ request,
51
+ options,
52
+ ));
53
+ }
54
+
55
+ async function $do(
56
+ client: SenseiProductivityCore,
57
+ request: operations.AcceptFriendRequestRequest,
58
+ options?: RequestOptions,
59
+ ): Promise<
60
+ [
61
+ Result<
62
+ void,
63
+ | SenseiProductivityError
64
+ | ResponseValidationError
65
+ | ConnectionError
66
+ | RequestAbortedError
67
+ | RequestTimeoutError
68
+ | InvalidRequestError
69
+ | UnexpectedClientError
70
+ | SDKValidationError
71
+ >,
72
+ APICall,
73
+ ]
74
+ > {
75
+ const parsed = safeParse(
76
+ request,
77
+ (value) =>
78
+ z.parse(operations.AcceptFriendRequestRequest$outboundSchema, value),
79
+ "Input validation failed",
80
+ );
81
+ if (!parsed.ok) {
82
+ return [parsed, { status: "invalid" }];
83
+ }
84
+ const payload = parsed.value;
85
+ const body = null;
86
+
87
+ const pathParams = {
88
+ id: encodeSimple("id", payload.id, {
89
+ explode: false,
90
+ charEncoding: "percent",
91
+ }),
92
+ };
93
+
94
+ const path = pathToFunc("/api/v1/friend-requests/{id}/accept")(pathParams);
95
+
96
+ const headers = new Headers(compactMap({
97
+ Accept: "*/*",
98
+ }));
99
+
100
+ const secConfig = await extractSecurity(client._options.bearerAuth);
101
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
102
+ const requestSecurity = resolveGlobalSecurity(securityInput);
103
+
104
+ const context = {
105
+ options: client._options,
106
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
107
+ operationID: "acceptFriendRequest",
108
+ oAuth2Scopes: null,
109
+
110
+ resolvedSecurity: requestSecurity,
111
+
112
+ securitySource: client._options.bearerAuth,
113
+ retryConfig: options?.retries
114
+ || client._options.retryConfig
115
+ || {
116
+ strategy: "backoff",
117
+ backoff: {
118
+ initialInterval: 1000,
119
+ maxInterval: 60000,
120
+ exponent: 1.3,
121
+ maxElapsedTime: 3600000,
122
+ },
123
+ retryConnectionErrors: true,
124
+ }
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "5XX"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "PATCH",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ errorCodes: ["429", "5XX"],
147
+ retryConfig: context.retryConfig,
148
+ retryCodes: context.retryCodes,
149
+ });
150
+ if (!doResult.ok) {
151
+ return [doResult, { status: "request-error", request: req }];
152
+ }
153
+ const response = doResult.value;
154
+
155
+ const [result] = await M.match<
156
+ void,
157
+ | SenseiProductivityError
158
+ | ResponseValidationError
159
+ | ConnectionError
160
+ | RequestAbortedError
161
+ | RequestTimeoutError
162
+ | InvalidRequestError
163
+ | UnexpectedClientError
164
+ | SDKValidationError
165
+ >(
166
+ M.nil(200, z.void()),
167
+ M.nil([401, 404], z.void()),
168
+ M.fail(429),
169
+ M.fail("5XX"),
170
+ )(response, req);
171
+ if (!result.ok) {
172
+ return [result, { status: "complete", request: req, response }];
173
+ }
174
+
175
+ return [result, { status: "complete", request: req, response }];
176
+ }
@@ -0,0 +1,182 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { SenseiProductivityCore } from "../core.js";
7
+ import { encodeSimple } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/http-client-errors.js";
21
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
22
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
23
+ import { SenseiProductivityError } from "../models/errors/sensei-productivity-error.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+ import * as types$ from "../types/primitives.js";
28
+
29
+ /**
30
+ * List a user's friends
31
+ */
32
+ export function usersFriendsList(
33
+ client: SenseiProductivityCore,
34
+ request: operations.ListFriendsRequest,
35
+ options?: RequestOptions,
36
+ ): APIPromise<
37
+ Result<
38
+ Array<operations.ListFriendsResponse> | undefined,
39
+ | SenseiProductivityError
40
+ | ResponseValidationError
41
+ | ConnectionError
42
+ | RequestAbortedError
43
+ | RequestTimeoutError
44
+ | InvalidRequestError
45
+ | UnexpectedClientError
46
+ | SDKValidationError
47
+ >
48
+ > {
49
+ return new APIPromise($do(
50
+ client,
51
+ request,
52
+ options,
53
+ ));
54
+ }
55
+
56
+ async function $do(
57
+ client: SenseiProductivityCore,
58
+ request: operations.ListFriendsRequest,
59
+ options?: RequestOptions,
60
+ ): Promise<
61
+ [
62
+ Result<
63
+ Array<operations.ListFriendsResponse> | undefined,
64
+ | SenseiProductivityError
65
+ | ResponseValidationError
66
+ | ConnectionError
67
+ | RequestAbortedError
68
+ | RequestTimeoutError
69
+ | InvalidRequestError
70
+ | UnexpectedClientError
71
+ | SDKValidationError
72
+ >,
73
+ APICall,
74
+ ]
75
+ > {
76
+ const parsed = safeParse(
77
+ request,
78
+ (value) => z.parse(operations.ListFriendsRequest$outboundSchema, value),
79
+ "Input validation failed",
80
+ );
81
+ if (!parsed.ok) {
82
+ return [parsed, { status: "invalid" }];
83
+ }
84
+ const payload = parsed.value;
85
+ const body = null;
86
+
87
+ const pathParams = {
88
+ id: encodeSimple("id", payload.id, {
89
+ explode: false,
90
+ charEncoding: "percent",
91
+ }),
92
+ };
93
+
94
+ const path = pathToFunc("/api/v1/users/{id}/friends")(pathParams);
95
+
96
+ const headers = new Headers(compactMap({
97
+ Accept: "application/json",
98
+ }));
99
+
100
+ const secConfig = await extractSecurity(client._options.bearerAuth);
101
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
102
+ const requestSecurity = resolveGlobalSecurity(securityInput);
103
+
104
+ const context = {
105
+ options: client._options,
106
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
107
+ operationID: "listFriends",
108
+ oAuth2Scopes: null,
109
+
110
+ resolvedSecurity: requestSecurity,
111
+
112
+ securitySource: client._options.bearerAuth,
113
+ retryConfig: options?.retries
114
+ || client._options.retryConfig
115
+ || {
116
+ strategy: "backoff",
117
+ backoff: {
118
+ initialInterval: 1000,
119
+ maxInterval: 60000,
120
+ exponent: 1.3,
121
+ maxElapsedTime: 3600000,
122
+ },
123
+ retryConnectionErrors: true,
124
+ }
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "5XX"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "GET",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ errorCodes: ["429", "5XX"],
147
+ retryConfig: context.retryConfig,
148
+ retryCodes: context.retryCodes,
149
+ });
150
+ if (!doResult.ok) {
151
+ return [doResult, { status: "request-error", request: req }];
152
+ }
153
+ const response = doResult.value;
154
+
155
+ const [result] = await M.match<
156
+ Array<operations.ListFriendsResponse> | undefined,
157
+ | SenseiProductivityError
158
+ | ResponseValidationError
159
+ | ConnectionError
160
+ | RequestAbortedError
161
+ | RequestTimeoutError
162
+ | InvalidRequestError
163
+ | UnexpectedClientError
164
+ | SDKValidationError
165
+ >(
166
+ M.json(
167
+ 200,
168
+ types$.optional(z.array(operations.ListFriendsResponse$inboundSchema)),
169
+ ),
170
+ M.nil(
171
+ [401, 404],
172
+ types$.optional(z.array(operations.ListFriendsResponse$inboundSchema)),
173
+ ),
174
+ M.fail(429),
175
+ M.fail("5XX"),
176
+ )(response, req);
177
+ if (!result.ok) {
178
+ return [result, { status: "complete", request: req, response }];
179
+ }
180
+
181
+ return [result, { status: "complete", request: req, response }];
182
+ }
@@ -0,0 +1,162 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { SenseiProductivityCore } from "../core.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { RequestOptions } from "../lib/sdks.js";
10
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
11
+ import { pathToFunc } from "../lib/url.js";
12
+ import {
13
+ ConnectionError,
14
+ InvalidRequestError,
15
+ RequestAbortedError,
16
+ RequestTimeoutError,
17
+ UnexpectedClientError,
18
+ } from "../models/errors/http-client-errors.js";
19
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
20
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
21
+ import { SenseiProductivityError } from "../models/errors/sensei-productivity-error.js";
22
+ import * as operations from "../models/operations/index.js";
23
+ import { APICall, APIPromise } from "../types/async.js";
24
+ import { Result } from "../types/fp.js";
25
+ import * as types$ from "../types/primitives.js";
26
+
27
+ /**
28
+ * Get all pending friend requests
29
+ */
30
+ export function usersFriendsPending(
31
+ client: SenseiProductivityCore,
32
+ options?: RequestOptions,
33
+ ): APIPromise<
34
+ Result<
35
+ Array<operations.PendingFriendRequestsResponse> | undefined,
36
+ | SenseiProductivityError
37
+ | ResponseValidationError
38
+ | ConnectionError
39
+ | RequestAbortedError
40
+ | RequestTimeoutError
41
+ | InvalidRequestError
42
+ | UnexpectedClientError
43
+ | SDKValidationError
44
+ >
45
+ > {
46
+ return new APIPromise($do(
47
+ client,
48
+ options,
49
+ ));
50
+ }
51
+
52
+ async function $do(
53
+ client: SenseiProductivityCore,
54
+ options?: RequestOptions,
55
+ ): Promise<
56
+ [
57
+ Result<
58
+ Array<operations.PendingFriendRequestsResponse> | undefined,
59
+ | SenseiProductivityError
60
+ | ResponseValidationError
61
+ | ConnectionError
62
+ | RequestAbortedError
63
+ | RequestTimeoutError
64
+ | InvalidRequestError
65
+ | UnexpectedClientError
66
+ | SDKValidationError
67
+ >,
68
+ APICall,
69
+ ]
70
+ > {
71
+ const path = pathToFunc("/api/v1/users/friends/pending")();
72
+
73
+ const headers = new Headers(compactMap({
74
+ Accept: "application/json",
75
+ }));
76
+
77
+ const secConfig = await extractSecurity(client._options.bearerAuth);
78
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
79
+ const requestSecurity = resolveGlobalSecurity(securityInput);
80
+
81
+ const context = {
82
+ options: client._options,
83
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
84
+ operationID: "pendingFriendRequests",
85
+ oAuth2Scopes: null,
86
+
87
+ resolvedSecurity: requestSecurity,
88
+
89
+ securitySource: client._options.bearerAuth,
90
+ retryConfig: options?.retries
91
+ || client._options.retryConfig
92
+ || {
93
+ strategy: "backoff",
94
+ backoff: {
95
+ initialInterval: 1000,
96
+ maxInterval: 60000,
97
+ exponent: 1.3,
98
+ maxElapsedTime: 3600000,
99
+ },
100
+ retryConnectionErrors: true,
101
+ }
102
+ || { strategy: "none" },
103
+ retryCodes: options?.retryCodes || ["429", "5XX"],
104
+ };
105
+
106
+ const requestRes = client._createRequest(context, {
107
+ security: requestSecurity,
108
+ method: "GET",
109
+ baseURL: options?.serverURL,
110
+ path: path,
111
+ headers: headers,
112
+ userAgent: client._options.userAgent,
113
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
114
+ }, options);
115
+ if (!requestRes.ok) {
116
+ return [requestRes, { status: "invalid" }];
117
+ }
118
+ const req = requestRes.value;
119
+
120
+ const doResult = await client._do(req, {
121
+ context,
122
+ errorCodes: ["429", "5XX"],
123
+ retryConfig: context.retryConfig,
124
+ retryCodes: context.retryCodes,
125
+ });
126
+ if (!doResult.ok) {
127
+ return [doResult, { status: "request-error", request: req }];
128
+ }
129
+ const response = doResult.value;
130
+
131
+ const [result] = await M.match<
132
+ Array<operations.PendingFriendRequestsResponse> | undefined,
133
+ | SenseiProductivityError
134
+ | ResponseValidationError
135
+ | ConnectionError
136
+ | RequestAbortedError
137
+ | RequestTimeoutError
138
+ | InvalidRequestError
139
+ | UnexpectedClientError
140
+ | SDKValidationError
141
+ >(
142
+ M.json(
143
+ 200,
144
+ types$.optional(
145
+ z.array(operations.PendingFriendRequestsResponse$inboundSchema),
146
+ ),
147
+ ),
148
+ M.nil(
149
+ 401,
150
+ types$.optional(
151
+ z.array(operations.PendingFriendRequestsResponse$inboundSchema),
152
+ ),
153
+ ),
154
+ M.fail(429),
155
+ M.fail("5XX"),
156
+ )(response, req);
157
+ if (!result.ok) {
158
+ return [result, { status: "complete", request: req, response }];
159
+ }
160
+
161
+ return [result, { status: "complete", request: req, response }];
162
+ }