Documentation
Notifications
Liste des notifications, mises à jour de l'état de lecture, suppression et marquage complet.
Traduit automatiquement de l'anglais. Voir l'original en anglais
Envoyez ces demandes à votre propre sidecar en cours d’exécution. Les valeurs restent dans ce navigateur.
Comment ça marche
Le sidecar écoute sur un port de bouclage choisi au démarrage et l'imprime dans son ready doubler; utilisez cette URL et le CADCAMFUN_TOKEN ça a commencé avec. Les demandes vont directement de cette page à cette adresse.
Le sidecar envoie les en-têtes CORS uniquement aux origines Tauri et à http://localhost ou http://127.0.0.1 sur n'importe quel port. À partir des documents hébergés, le navigateur bloque la réponse, exécutez donc les documents localement (bun run dev dans packages/web) pour utiliser le terrain de jeu, ou copiez la requête sous forme curl. Pour expérimenter sans toucher aux données réelles, démarrez le sidecar avec CADCAMFUN_DATA_DIR pointé vers un répertoire jetable — voir la procédure pas à pas de l'API.
Opérations
4 endpoints dans le notifications groupe, généré à partir du propre sidecar Document OpenAPI. Les opérations protégées prennent Authorization: Bearer $CADCAMFUN_TOKEN; voir authentification. Le comportement et les limites sont en place le guide du sous-système.
| obtenir | /api/notifications | notifications.list |
| mettre | /api/notifications/{id} | notifications.update |
| supprimer | /api/notifications/{id} | notifications.remove |
| poste | /api/notifications/mark-all-read | notifications.markAllRead |
/api/notifications
notifications.list Nécessite Authorization: Bearer <token>.
| Nom | Dans | Taper | Requis |
|---|---|---|---|
| limite | requête | chaîne | null | facultatif |
| compenser | requête | chaîne | null | facultatif |
| curseur | requête | chaîne | null | facultatif |
| onlyUnread | requête | chaîne | null | facultatif |
200 objet application/json
{ notifications: Array<{ id: string type: "NEW_MESSAGE" | "PROJECT_CREATED" | "COMPONENT_CREATED" | "MEMBER_JOINED" | "ORGANIZATION_INVITATION" | "PR_OPENED" | "PR_MERGED" | "PR_REVIEWED" | "AI_COMMITTED" | "WORKFLOW_FAILED" | "WORKFLOW_PASSED" title: string content: string isRead: boolean createdAt: string userId: string organizationId: string | null projectId: string | null componentId: string | null messageId: string | null linkUrl: string | null }> unreadCount: number | "Infinity" | "-Infinity" | "NaN" nextCursor: string | null }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de réponse capturé · 200
{
"notifications": [],
"unreadCount": 0
} Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// NotificationsListInput
const result = await client.notifications.list({}) curl
curl --request GET "${CADCAMFUN_URL}/api/notifications" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Essayez-le
notifications.update Nécessite Authorization: Bearer <token>.
| Nom | Dans | Taper | Requis |
|---|---|---|---|
| identifiant | chemin | chaîne | requis |
{ isRead: boolean }
200 objet application/json
{ id: string type: "NEW_MESSAGE" | "PROJECT_CREATED" | "COMPONENT_CREATED" | "MEMBER_JOINED" | "ORGANIZATION_INVITATION" | "PR_OPENED" | "PR_MERGED" | "PR_REVIEWED" | "AI_COMMITTED" | "WORKFLOW_FAILED" | "WORKFLOW_PASSED" title: string content: string isRead: boolean createdAt: string userId: string organizationId: string | null projectId: string | null componentId: string | null messageId: string | null linkUrl: string | null }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// NotificationsUpdateInput
const result = await client.notifications.update({
id: "<id>",
isRead: false
}) curl
curl --request PUT "${CADCAMFUN_URL}/api/notifications/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json Essayez-le
notifications.remove Nécessite Authorization: Bearer <token>.
| Nom | Dans | Taper | Requis |
|---|---|---|---|
| identifiant | chemin | chaîne | requis |
200 objet application/json
{ message: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// NotificationsRemoveInput
const result = await client.notifications.remove({
id: "<id>"
}) curl
curl --request DELETE "${CADCAMFUN_URL}/api/notifications/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Essayez-le
/api/notifications/mark-all-read
notifications.markAllRead Nécessite Authorization: Bearer <token>.
200 objet application/json
{ message: string count: number | "Infinity" | "-Infinity" | "NaN" }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.notifications.markAllRead() curl
curl --request POST "${CADCAMFUN_URL}/api/notifications/mark-all-read" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Essayez-le
Schémas
Schémas nommés accessibles à partir des paramètres, des corps et des réponses de ce groupe. UN ? marque un champ facultatif ; | null marque un champ qui peut être présent avec une valeur nulle.
BadRequestEncoded{ _tag: "BadRequest" message: string }
InternalErrorEncoded{ _tag: "InternalError" message: string }
NotFoundEncoded{ _tag: "NotFound" message: string }
Appel à ce groupe
Les identifiants d'opération ont la forme notifications.<name>. Le SDK Promise généré (@cadcamfun/api/sdk) expose la plupart d'entre eux comme client.<namespace>.<method>(input), où input est un objet plat composé de paramètres de chemin et de champs de corps ; L'exemple de SDK de chaque carte montre l'accesseur exact et le type d'entrée. Les téléchargements en plusieurs parties, les réponses binaires ou JavaScript et les webhooks bruts ne sont pas générés ; ces cartes montrent fetch à la place.
import { CadCam, ClientError } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
try {
await client.projects.list()
} catch (error) {
if (error instanceof ClientError) {
// Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
} else {
// a declared error body: switch on error._tag
}
} Dépannage
| Symptôme | Cause probable | Réparer |
|---|---|---|
| 401 à chaque appel | Jeton d'un lancement précédent, ou manquant Bearer préfixe | Envoyer Authorization: Bearer <token> avec le jeton avec lequel le sidecar a été démarré. |
| 400 avant que quoi que ce soit se produise | Le corps ou le paramètre ne correspond pas au schéma | Comparez la charge utile avec le schéma de demande sur la carte. |
| 403 ou 404 sur un enregistrement visible ailleurs | Le compte intérimaire diffère | Envoyez le droit x-session-token, ou utilisez le profil local propriétaire de l'enregistrement. |
| 409 | État conflictuel, tel qu'un nom en double ou un chef de succursale obsolète | Relisez la ressource et réessayez avec les données actuelles. |
| Essayez, il est écrit "bloqué par CORS" | Les documents sont servis à partir d'une origine sans bouclage | Exécutez la documentation localement ou copiez la demande en tant que curl. |
| Connexion rejetée | Le sidecar a redémarré sur un nouveau port | Lire le port du nouveau ready ligne. |