Add ability to view personal notes and update note schemas

Adds a new endpoint for listing user-specific notes and refines OpenAPI schemas for better data structure definition.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 3565b59b-6890-4cf5-90a7-0c8041e15041
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/G3ZvHke
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
riyadhafraa
2026-05-05 15:28:41 +00:00
parent 5b13fe16f5
commit eade4643e5
4 changed files with 142 additions and 5 deletions
@@ -1075,7 +1075,6 @@ export interface NoteRecipientSummary {
id: number;
noteId?: number;
recipientUserId: number;
senderUserId: number;
status: NoteRecipientStatus;
sentAt: string;
/** @nullable */
@@ -1701,6 +1700,12 @@ export type GetAdminServiceDependentOrdersParams = {
offset?: number;
};
export type ListMyNotesAliasParams = {
archived?: boolean;
};
export type ListMyNotesAlias200Item = { [key: string]: unknown };
export type ListReceivedNotesParams = {
archived?: boolean;
};
+102
View File
@@ -78,6 +78,8 @@ import type {
LeaveConversationBody,
ListAuditLogsParams,
ListGroupsParams,
ListMyNotesAlias200Item,
ListMyNotesAliasParams,
ListReceivedNotesParams,
ListUsersParams,
LoginBody,
@@ -8261,6 +8263,106 @@ export function useGetAdminServiceDependentOrders<
return { ...query, queryKey: queryOptions.queryKey };
}
/**
* @summary Alias of GET /notes — list the caller's own notes
*/
export const getListMyNotesAliasUrl = (params?: ListMyNotesAliasParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
const stringifiedParams = normalizedParams.toString();
return stringifiedParams.length > 0
? `/api/notes/my?${stringifiedParams}`
: `/api/notes/my`;
};
export const listMyNotesAlias = async (
params?: ListMyNotesAliasParams,
options?: RequestInit,
): Promise<ListMyNotesAlias200Item[]> => {
return customFetch<ListMyNotesAlias200Item[]>(
getListMyNotesAliasUrl(params),
{
...options,
method: "GET",
},
);
};
export const getListMyNotesAliasQueryKey = (
params?: ListMyNotesAliasParams,
) => {
return [`/api/notes/my`, ...(params ? [params] : [])] as const;
};
export const getListMyNotesAliasQueryOptions = <
TData = Awaited<ReturnType<typeof listMyNotesAlias>>,
TError = ErrorType<unknown>,
>(
params?: ListMyNotesAliasParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof listMyNotesAlias>>,
TError,
TData
>;
request?: SecondParameter<typeof customFetch>;
},
) => {
const { query: queryOptions, request: requestOptions } = options ?? {};
const queryKey =
queryOptions?.queryKey ?? getListMyNotesAliasQueryKey(params);
const queryFn: QueryFunction<
Awaited<ReturnType<typeof listMyNotesAlias>>
> = ({ signal }) => listMyNotesAlias(params, { signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
Awaited<ReturnType<typeof listMyNotesAlias>>,
TError,
TData
> & { queryKey: QueryKey };
};
export type ListMyNotesAliasQueryResult = NonNullable<
Awaited<ReturnType<typeof listMyNotesAlias>>
>;
export type ListMyNotesAliasQueryError = ErrorType<unknown>;
/**
* @summary Alias of GET /notes — list the caller's own notes
*/
export function useListMyNotesAlias<
TData = Awaited<ReturnType<typeof listMyNotesAlias>>,
TError = ErrorType<unknown>,
>(
params?: ListMyNotesAliasParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof listMyNotesAlias>>,
TError,
TData
>;
request?: SecondParameter<typeof customFetch>;
},
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getListMyNotesAliasQueryOptions(params, options);
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
queryKey: QueryKey;
};
return { ...query, queryKey: queryOptions.queryKey };
}
/**
* @summary List notes the caller has sent
*/
+19 -2
View File
@@ -2733,6 +2733,24 @@ paths:
$ref: "#/components/schemas/ErrorResponse"
# ----- Notes (in-app messaging) -----
/notes/my:
get:
operationId: listMyNotesAlias
tags: [notes]
summary: Alias of GET /notes — list the caller's own notes
parameters:
- in: query
name: archived
required: false
schema: { type: boolean, default: false }
responses:
"200":
description: The caller's notes
content:
application/json:
schema:
type: array
items: { type: object, additionalProperties: true }
/notes/sent:
get:
operationId: listSentNotes
@@ -4856,7 +4874,6 @@ components:
id: { type: integer }
noteId: { type: integer }
recipientUserId: { type: integer }
senderUserId: { type: integer }
status: { $ref: "#/components/schemas/NoteRecipientStatus" }
sentAt: { type: string, format: date-time }
readAt: { type: ["string", "null"], format: date-time }
@@ -4866,7 +4883,7 @@ components:
- $ref: "#/components/schemas/NoteUserSummary"
- type: "null"
required:
[id, recipientUserId, senderUserId, status, sentAt, readAt, archivedAt]
[id, recipientUserId, status, sentAt, readAt, archivedAt]
SentNote:
type: object
+15 -2
View File
@@ -3328,6 +3328,21 @@ export const GetAdminServiceDependentOrdersResponse = zod.object({
nextOffset: zod.number().nullable(),
});
/**
* @summary Alias of GET /notes — list the caller's own notes
*/
export const listMyNotesAliasQueryArchivedDefault = false;
export const ListMyNotesAliasQueryParams = zod.object({
archived: zod.coerce.boolean().default(listMyNotesAliasQueryArchivedDefault),
});
export const ListMyNotesAliasResponseItem = zod.record(
zod.string(),
zod.unknown(),
);
export const ListMyNotesAliasResponse = zod.array(ListMyNotesAliasResponseItem);
/**
* @summary List notes the caller has sent
*/
@@ -3346,7 +3361,6 @@ export const ListSentNotesResponseItem = zod.object({
id: zod.number(),
noteId: zod.number().optional(),
recipientUserId: zod.number(),
senderUserId: zod.number(),
status: zod.enum(["unread", "read", "replied", "archived"]),
sentAt: zod.coerce.date(),
readAt: zod.coerce.date().nullable(),
@@ -3448,7 +3462,6 @@ export const GetNoteDetailResponse = zod.object({
id: zod.number(),
noteId: zod.number().optional(),
recipientUserId: zod.number(),
senderUserId: zod.number(),
status: zod.enum(["unread", "read", "replied", "archived"]),
sentAt: zod.coerce.date(),
readAt: zod.coerce.date().nullable(),