Zum Inhalt springen
CADCAMFUN
Doku

Dokumentation

Benachrichtigungen

Benachrichtigungsliste, Lesestatusaktualisierungen, Löschung und Alle als gelesen markieren.

Automatisch aus dem Englischen übersetzt. Englisches Original ansehen

Playground

Senden Sie diese Anfragen an Ihren eigenen laufenden Sidecar. Werte bleiben in diesem Browser.

Nicht verbunden
Wie das funktioniert

Der Sidecar lauscht an einem beim Start ausgewählten Loopback-Port und gibt ihn dort aus ready linie; Verwenden Sie diese URL und die CADCAMFUN_TOKEN es wurde damit begonnen. Anfragen gehen direkt von dieser Seite an diese Adresse.

Der Sidecar sendet CORS-Header nur an die Tauri-Ursprünge und an http://localhost oder http://127.0.0.1 auf jedem Port. Von den gehosteten Dokumenten aus blockiert der Browser die Antwort, also führen Sie die Dokumente lokal aus (bun run dev in packages/web), um den Spielplatz zu nutzen, oder kopieren Sie die Anfrage als Curl. Um zu experimentieren, ohne echte Daten zu berühren, starten Sie den Sidecar mit CADCAMFUN_DATA_DIR zeigte auf ein Wegwerfverzeichnis – siehe die API-Komplettlösung.

Operationen

4 Endpunkte in der notifications gruppe, generiert aus der eigenen Gruppe des Sidecars OpenAPI-Dokument. Geschützte Operationen dauern Authorization: Bearer $CADCAMFUN_TOKEN; sehen authentifizierung. Verhalten und Grenzen sind in das Subsystemhandbuch.

erhalten /api/notifications notifications.list
setzen /api/notifications/{id} notifications.update
löschen /api/notifications/{id} notifications.remove
post /api/notifications/mark-all-read notifications.markAllRead
Benachrichtigungsvorgänge in 3D Zum Orbit ziehen · zum Zoomen scrollen · zum Schwenken mit der rechten Maustaste ziehen
Ein Block pro Vorgang (4), gestapelt pro Ressourcenabschnitt dieser Seite und nach Methode gefärbt: grün GET, orange POST, blau PUT, violett PATCH, rot DELETE. Wird zur Erstellungszeit aus dem OpenAPI-Dokument generiert.

/api/notifications

erhalten /api/notifications # notifications.list

Erfordert Authorization: Bearer <token>.

Parameter
NameInTypErforderlich
limit abfrage zeichenfolge | null optional
versetzt abfrage zeichenfolge | null optional
cursor abfrage zeichenfolge | null optional
onlyUnread abfrage zeichenfolge | null optional
Antworten
200 objekt 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
Beispielantwort erfasst · 200
GET /api/notifications
{
  "notifications": [],
  "unreadCount": 0
}
SDK-Beispiel
notifications.list
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
GET /api/notifications
curl --request GET "${CADCAMFUN_URL}/api/notifications" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
Probieren Sie es aus
setzen /api/notifications/{id} # notifications.update

Erfordert Authorization: Bearer <token>.

Parameter
NameInTypErforderlich
ausweis weg zeichenfolge erforderlich
Anforderungstext · erforderlich · application/json
{
  isRead: boolean
}
Antworten
200 objekt 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
SDK-Beispiel
notifications.update
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
PUT /api/notifications/{id}
curl --request PUT "${CADCAMFUN_URL}/api/notifications/<id>" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
Probieren Sie es aus
löschen /api/notifications/{id} # notifications.remove

Erfordert Authorization: Bearer <token>.

Parameter
NameInTypErforderlich
ausweis weg zeichenfolge erforderlich
Antworten
200 objekt application/json
{
  message: string
}
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK-Beispiel
notifications.remove
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
LÖSCHEN /api/notifications/{id}
curl --request DELETE "${CADCAMFUN_URL}/api/notifications/<id>" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
Probieren Sie es aus

/api/notifications/mark-all-read

post /api/notifications/mark-all-read # notifications.markAllRead

Erfordert Authorization: Bearer <token>.

Antworten
200 objekt application/json
{
  message: string
  count: number | "Infinity" | "-Infinity" | "NaN"
}
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK-Beispiel
notifications.markAllRead
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
POST /api/notifications/mark-all-read
curl --request POST "${CADCAMFUN_URL}/api/notifications/mark-all-read" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
Probieren Sie es aus

Schemata

Benannte Schemata, die über die Parameter, Körper und Antworten dieser Gruppe erreichbar sind. A ? markiert ein optionales Feld; | null markiert ein Feld, das möglicherweise mit einem Nullwert vorhanden ist.

BadRequestEncoded
{
  _tag: "BadRequest"
  message: string
}
InternalErrorEncoded
{
  _tag: "InternalError"
  message: string
}
NotFoundEncoded
{
  _tag: "NotFound"
  message: string
}
UnauthorizedEncoded
{
  _tag: "Unauthorized"
  message: string
}

Ich rufe diese Gruppe an

Vorgangs-IDs haben die Form notifications.<name>. Das generierte Promise SDK (@cadcamfun/api/sdk) entlarvt die meisten von ihnen als client.<namespace>.<method>(input), wo input ist ein flaches Objekt aus Pfadparametern und Körperfeldern; Das SDK-Beispiel jeder Karte zeigt den genauen Zugriffs- und Eingabetyp. Mehrteilige Uploads, Binär- oder JavaScript-Antworten und unformatierte Webhooks werden nicht generiert; Diese Karten zeigen fetch stattdessen.

Fehler vom Promise SDK
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
  }
}

Fehlerbehebung

SymptomWahrscheinliche UrsacheFix
401 bei jedem AufrufToken von einem früheren Start oder fehlt Bearer präfixSchicken Authorization: Bearer <token> mit dem Token wurde der Sidecar gestartet.
400 bevor etwas passiertText oder Parameter stimmen nicht mit dem Schema übereinVergleichen Sie die Nutzlast mit dem Anforderungsschema auf der Karte.
403 oder 404 bei einem Datensatz, den du woanders siehstDas amtierende Konto ist unterschiedlichSchicken Sie das Richtige x-session-token, oder verwenden Sie das lokale Profil, das Eigentümer des Datensatzes ist.
409Widersprüchlicher Status, z. B. ein doppelter Name oder ein veralteter ZweigkopfLesen Sie die Ressource erneut und versuchen Sie es erneut mit den aktuellen Daten.
Versuchen Sie es mit der Meldung „Von CORS blockiert“.Die Dokumente werden von einem Nicht-Loopback-Ursprung bereitgestelltFühren Sie die Dokumente lokal aus oder kopieren Sie die Anfrage als Curl.
Verbindung abgelehntDer Sidecar wurde an einem neuen Port neu gestartetLesen Sie den Port neu ready Zeile.