@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.
- package/README.md +28 -0
- package/dist/commonjs/funcs/users-friends-accept.d.ts +14 -0
- package/dist/commonjs/funcs/users-friends-accept.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-friends-accept.js +127 -0
- package/dist/commonjs/funcs/users-friends-accept.js.map +1 -0
- package/dist/commonjs/funcs/users-friends-list.d.ts +14 -0
- package/dist/commonjs/funcs/users-friends-list.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-friends-list.js +128 -0
- package/dist/commonjs/funcs/users-friends-list.js.map +1 -0
- package/dist/commonjs/funcs/users-friends-pending.d.ts +14 -0
- package/dist/commonjs/funcs/users-friends-pending.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-friends-pending.js +113 -0
- package/dist/commonjs/funcs/users-friends-pending.js.map +1 -0
- package/dist/commonjs/funcs/users-friends-reject.d.ts +14 -0
- package/dist/commonjs/funcs/users-friends-reject.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-friends-reject.js +127 -0
- package/dist/commonjs/funcs/users-friends-reject.js.map +1 -0
- package/dist/commonjs/funcs/users-friends-remove.d.ts +14 -0
- package/dist/commonjs/funcs/users-friends-remove.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-friends-remove.js +127 -0
- package/dist/commonjs/funcs/users-friends-remove.js.map +1 -0
- package/dist/commonjs/funcs/users-friends-send-request.d.ts +14 -0
- package/dist/commonjs/funcs/users-friends-send-request.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-friends-send-request.js +127 -0
- package/dist/commonjs/funcs/users-friends-send-request.js.map +1 -0
- package/dist/commonjs/funcs/users-posts-delete.d.ts +14 -0
- package/dist/commonjs/funcs/users-posts-delete.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-posts-delete.js +127 -0
- package/dist/commonjs/funcs/users-posts-delete.js.map +1 -0
- package/dist/commonjs/funcs/users-posts-feed.d.ts +14 -0
- package/dist/commonjs/funcs/users-posts-feed.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-posts-feed.js +127 -0
- package/dist/commonjs/funcs/users-posts-feed.js.map +1 -0
- package/dist/commonjs/funcs/users-posts-get-by-post-id.d.ts +14 -0
- package/dist/commonjs/funcs/users-posts-get-by-post-id.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-posts-get-by-post-id.js +128 -0
- package/dist/commonjs/funcs/users-posts-get-by-post-id.js.map +1 -0
- package/dist/commonjs/funcs/users-posts-get-by-user-id.d.ts +14 -0
- package/dist/commonjs/funcs/users-posts-get-by-user-id.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-posts-get-by-user-id.js +128 -0
- package/dist/commonjs/funcs/users-posts-get-by-user-id.js.map +1 -0
- package/dist/commonjs/funcs/users-posts-update.d.ts +14 -0
- package/dist/commonjs/funcs/users-posts-update.d.ts.map +1 -0
- package/dist/commonjs/funcs/users-posts-update.js +129 -0
- package/dist/commonjs/funcs/users-posts-update.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +4 -4
- package/dist/commonjs/lib/config.js +4 -4
- package/dist/commonjs/models/operations/accept-friend-request.d.ts +15 -0
- package/dist/commonjs/models/operations/accept-friend-request.d.ts.map +1 -0
- package/dist/commonjs/models/operations/accept-friend-request.js +49 -0
- package/dist/commonjs/models/operations/accept-friend-request.js.map +1 -0
- package/dist/commonjs/models/operations/delete-post.d.ts +12 -0
- package/dist/commonjs/models/operations/delete-post.d.ts.map +1 -0
- package/dist/commonjs/models/operations/delete-post.js +49 -0
- package/dist/commonjs/models/operations/delete-post.js.map +1 -0
- package/dist/commonjs/models/operations/get-feed.d.ts +49 -0
- package/dist/commonjs/models/operations/get-feed.d.ts.map +1 -0
- package/dist/commonjs/models/operations/get-feed.js +85 -0
- package/dist/commonjs/models/operations/get-feed.js.map +1 -0
- package/dist/commonjs/models/operations/get-post-by-id.d.ts +38 -0
- package/dist/commonjs/models/operations/get-post-by-id.d.ts.map +1 -0
- package/dist/commonjs/models/operations/get-post-by-id.js +73 -0
- package/dist/commonjs/models/operations/get-post-by-id.js.map +1 -0
- package/dist/commonjs/models/operations/get-user-posts.d.ts +35 -0
- package/dist/commonjs/models/operations/get-user-posts.d.ts.map +1 -0
- package/dist/commonjs/models/operations/get-user-posts.js +73 -0
- package/dist/commonjs/models/operations/get-user-posts.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +11 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +11 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/list-friends.d.ts +26 -0
- package/dist/commonjs/models/operations/list-friends.d.ts.map +1 -0
- package/dist/commonjs/models/operations/list-friends.js +65 -0
- package/dist/commonjs/models/operations/list-friends.js.map +1 -0
- package/dist/commonjs/models/operations/pending-friend-requests.d.ts +16 -0
- package/dist/commonjs/models/operations/pending-friend-requests.d.ts.map +1 -0
- package/dist/commonjs/models/operations/pending-friend-requests.js +57 -0
- package/dist/commonjs/models/operations/pending-friend-requests.js.map +1 -0
- package/dist/commonjs/models/operations/reject-friend-request.d.ts +15 -0
- package/dist/commonjs/models/operations/reject-friend-request.d.ts.map +1 -0
- package/dist/commonjs/models/operations/reject-friend-request.js +49 -0
- package/dist/commonjs/models/operations/reject-friend-request.js.map +1 -0
- package/dist/commonjs/models/operations/remove-friend.d.ts +12 -0
- package/dist/commonjs/models/operations/remove-friend.d.ts.map +1 -0
- package/dist/commonjs/models/operations/remove-friend.js +49 -0
- package/dist/commonjs/models/operations/remove-friend.js.map +1 -0
- package/dist/commonjs/models/operations/send-friend-request.d.ts +12 -0
- package/dist/commonjs/models/operations/send-friend-request.d.ts.map +1 -0
- package/dist/commonjs/models/operations/send-friend-request.js +49 -0
- package/dist/commonjs/models/operations/send-friend-request.js.map +1 -0
- package/dist/commonjs/models/operations/update-post.d.ts +60 -0
- package/dist/commonjs/models/operations/update-post.d.ts.map +1 -0
- package/dist/commonjs/models/operations/update-post.js +90 -0
- package/dist/commonjs/models/operations/update-post.js.map +1 -0
- package/dist/commonjs/sdk/friends.d.ts +29 -0
- package/dist/commonjs/sdk/friends.d.ts.map +1 -0
- package/dist/commonjs/sdk/friends.js +54 -0
- package/dist/commonjs/sdk/friends.js.map +1 -0
- package/dist/commonjs/sdk/posts.d.ts +25 -0
- package/dist/commonjs/sdk/posts.d.ts.map +1 -0
- package/dist/commonjs/sdk/posts.js +47 -0
- package/dist/commonjs/sdk/posts.js.map +1 -0
- package/dist/commonjs/sdk/users.d.ts +6 -0
- package/dist/commonjs/sdk/users.d.ts.map +1 -1
- package/dist/commonjs/sdk/users.js +8 -0
- package/dist/commonjs/sdk/users.js.map +1 -1
- package/dist/esm/funcs/users-friends-accept.d.ts +14 -0
- package/dist/esm/funcs/users-friends-accept.d.ts.map +1 -0
- package/dist/esm/funcs/users-friends-accept.js +91 -0
- package/dist/esm/funcs/users-friends-accept.js.map +1 -0
- package/dist/esm/funcs/users-friends-list.d.ts +14 -0
- package/dist/esm/funcs/users-friends-list.d.ts.map +1 -0
- package/dist/esm/funcs/users-friends-list.js +92 -0
- package/dist/esm/funcs/users-friends-list.js.map +1 -0
- package/dist/esm/funcs/users-friends-pending.d.ts +14 -0
- package/dist/esm/funcs/users-friends-pending.d.ts.map +1 -0
- package/dist/esm/funcs/users-friends-pending.js +77 -0
- package/dist/esm/funcs/users-friends-pending.js.map +1 -0
- package/dist/esm/funcs/users-friends-reject.d.ts +14 -0
- package/dist/esm/funcs/users-friends-reject.d.ts.map +1 -0
- package/dist/esm/funcs/users-friends-reject.js +91 -0
- package/dist/esm/funcs/users-friends-reject.js.map +1 -0
- package/dist/esm/funcs/users-friends-remove.d.ts +14 -0
- package/dist/esm/funcs/users-friends-remove.d.ts.map +1 -0
- package/dist/esm/funcs/users-friends-remove.js +91 -0
- package/dist/esm/funcs/users-friends-remove.js.map +1 -0
- package/dist/esm/funcs/users-friends-send-request.d.ts +14 -0
- package/dist/esm/funcs/users-friends-send-request.d.ts.map +1 -0
- package/dist/esm/funcs/users-friends-send-request.js +91 -0
- package/dist/esm/funcs/users-friends-send-request.js.map +1 -0
- package/dist/esm/funcs/users-posts-delete.d.ts +14 -0
- package/dist/esm/funcs/users-posts-delete.d.ts.map +1 -0
- package/dist/esm/funcs/users-posts-delete.js +91 -0
- package/dist/esm/funcs/users-posts-delete.js.map +1 -0
- package/dist/esm/funcs/users-posts-feed.d.ts +14 -0
- package/dist/esm/funcs/users-posts-feed.d.ts.map +1 -0
- package/dist/esm/funcs/users-posts-feed.js +91 -0
- package/dist/esm/funcs/users-posts-feed.js.map +1 -0
- package/dist/esm/funcs/users-posts-get-by-post-id.d.ts +14 -0
- package/dist/esm/funcs/users-posts-get-by-post-id.d.ts.map +1 -0
- package/dist/esm/funcs/users-posts-get-by-post-id.js +92 -0
- package/dist/esm/funcs/users-posts-get-by-post-id.js.map +1 -0
- package/dist/esm/funcs/users-posts-get-by-user-id.d.ts +14 -0
- package/dist/esm/funcs/users-posts-get-by-user-id.d.ts.map +1 -0
- package/dist/esm/funcs/users-posts-get-by-user-id.js +92 -0
- package/dist/esm/funcs/users-posts-get-by-user-id.js.map +1 -0
- package/dist/esm/funcs/users-posts-update.d.ts +14 -0
- package/dist/esm/funcs/users-posts-update.d.ts.map +1 -0
- package/dist/esm/funcs/users-posts-update.js +93 -0
- package/dist/esm/funcs/users-posts-update.js.map +1 -0
- package/dist/esm/lib/config.d.ts +4 -4
- package/dist/esm/lib/config.js +4 -4
- package/dist/esm/models/operations/accept-friend-request.d.ts +15 -0
- package/dist/esm/models/operations/accept-friend-request.d.ts.map +1 -0
- package/dist/esm/models/operations/accept-friend-request.js +12 -0
- package/dist/esm/models/operations/accept-friend-request.js.map +1 -0
- package/dist/esm/models/operations/delete-post.d.ts +12 -0
- package/dist/esm/models/operations/delete-post.d.ts.map +1 -0
- package/dist/esm/models/operations/delete-post.js +12 -0
- package/dist/esm/models/operations/delete-post.js.map +1 -0
- package/dist/esm/models/operations/get-feed.d.ts +49 -0
- package/dist/esm/models/operations/get-feed.d.ts.map +1 -0
- package/dist/esm/models/operations/get-feed.js +46 -0
- package/dist/esm/models/operations/get-feed.js.map +1 -0
- package/dist/esm/models/operations/get-post-by-id.d.ts +38 -0
- package/dist/esm/models/operations/get-post-by-id.d.ts.map +1 -0
- package/dist/esm/models/operations/get-post-by-id.js +35 -0
- package/dist/esm/models/operations/get-post-by-id.js.map +1 -0
- package/dist/esm/models/operations/get-user-posts.d.ts +35 -0
- package/dist/esm/models/operations/get-user-posts.d.ts.map +1 -0
- package/dist/esm/models/operations/get-user-posts.js +35 -0
- package/dist/esm/models/operations/get-user-posts.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +11 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +11 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/list-friends.d.ts +26 -0
- package/dist/esm/models/operations/list-friends.d.ts.map +1 -0
- package/dist/esm/models/operations/list-friends.js +27 -0
- package/dist/esm/models/operations/list-friends.js.map +1 -0
- package/dist/esm/models/operations/pending-friend-requests.d.ts +16 -0
- package/dist/esm/models/operations/pending-friend-requests.d.ts.map +1 -0
- package/dist/esm/models/operations/pending-friend-requests.js +20 -0
- package/dist/esm/models/operations/pending-friend-requests.js.map +1 -0
- package/dist/esm/models/operations/reject-friend-request.d.ts +15 -0
- package/dist/esm/models/operations/reject-friend-request.d.ts.map +1 -0
- package/dist/esm/models/operations/reject-friend-request.js +12 -0
- package/dist/esm/models/operations/reject-friend-request.js.map +1 -0
- package/dist/esm/models/operations/remove-friend.d.ts +12 -0
- package/dist/esm/models/operations/remove-friend.d.ts.map +1 -0
- package/dist/esm/models/operations/remove-friend.js +12 -0
- package/dist/esm/models/operations/remove-friend.js.map +1 -0
- package/dist/esm/models/operations/send-friend-request.d.ts +12 -0
- package/dist/esm/models/operations/send-friend-request.d.ts.map +1 -0
- package/dist/esm/models/operations/send-friend-request.js +12 -0
- package/dist/esm/models/operations/send-friend-request.js.map +1 -0
- package/dist/esm/models/operations/update-post.d.ts +60 -0
- package/dist/esm/models/operations/update-post.d.ts.map +1 -0
- package/dist/esm/models/operations/update-post.js +51 -0
- package/dist/esm/models/operations/update-post.js.map +1 -0
- package/dist/esm/sdk/friends.d.ts +29 -0
- package/dist/esm/sdk/friends.d.ts.map +1 -0
- package/dist/esm/sdk/friends.js +50 -0
- package/dist/esm/sdk/friends.js.map +1 -0
- package/dist/esm/sdk/posts.d.ts +25 -0
- package/dist/esm/sdk/posts.d.ts.map +1 -0
- package/dist/esm/sdk/posts.js +43 -0
- package/dist/esm/sdk/posts.js.map +1 -0
- package/dist/esm/sdk/users.d.ts +6 -0
- package/dist/esm/sdk/users.d.ts.map +1 -1
- package/dist/esm/sdk/users.js +8 -0
- package/dist/esm/sdk/users.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/rest-api/cypress/e2e/activity-post-endpoints.cy.js +239 -0
- package/rest-api/cypress/e2e/friend-endpoints.cy.js +262 -0
- package/rest-api/cypress/e2e/{school-endpoints.cy.ts → school-endpoints.cy.js} +1 -1
- package/rest-api/cypress/e2e/{user-activity-endpoints.cy.ts → user-activity-endpoints.cy.js} +8 -20
- package/rest-api/cypress/e2e/{user-endpoints.cy.ts → user-endpoints.cy.js} +3 -3
- package/rest-api/cypress.config.ts +70 -21
- package/rest-api/index.js +20 -7
- package/rest-api/lib/users.js +35 -0
- package/rest-api/routes/ActivityPostFunctions.js +208 -0
- package/rest-api/routes/FriendFunctions.js +266 -0
- package/rest-api/routes/UserActivityFunctions.js +2 -34
- package/rest-api/routes/UserFunctions.js +30 -24
- package/src/funcs/users-friends-accept.ts +176 -0
- package/src/funcs/users-friends-list.ts +182 -0
- package/src/funcs/users-friends-pending.ts +162 -0
- package/src/funcs/users-friends-reject.ts +176 -0
- package/src/funcs/users-friends-remove.ts +175 -0
- package/src/funcs/users-friends-send-request.ts +176 -0
- package/src/funcs/users-posts-delete.ts +175 -0
- package/src/funcs/users-posts-feed.ts +176 -0
- package/src/funcs/users-posts-get-by-post-id.ts +179 -0
- package/src/funcs/users-posts-get-by-user-id.ts +182 -0
- package/src/funcs/users-posts-update.ts +180 -0
- package/src/lib/config.ts +4 -4
- package/src/models/operations/accept-friend-request.ts +33 -0
- package/src/models/operations/delete-post.ts +30 -0
- package/src/models/operations/get-feed.ts +110 -0
- package/src/models/operations/get-post-by-id.ts +86 -0
- package/src/models/operations/get-user-posts.ts +83 -0
- package/src/models/operations/index.ts +11 -0
- package/src/models/operations/list-friends.ts +68 -0
- package/src/models/operations/pending-friend-requests.ts +43 -0
- package/src/models/operations/reject-friend-request.ts +33 -0
- package/src/models/operations/remove-friend.ts +30 -0
- package/src/models/operations/send-friend-request.ts +30 -0
- package/src/models/operations/update-post.ts +131 -0
- package/src/sdk/friends.ts +97 -0
- package/src/sdk/posts.ts +84 -0
- package/src/sdk/users.ts +12 -0
- /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
|
|
25
|
-
user_id: userId
|
|
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
|
-
|
|
162
|
-
|
|
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
|
+
}
|