Przejdź do treści
Biblioteka skilli
Programowanie · Integracja z narzędziem

webiny-websocket-notifications

/webiny-websocket-notifications

Wysyła powiadomienia w czasie rzeczywistym z API do aplikacji Admin przez websockety, np. postęp zadań w tle.

Repozytorium
webiny-js ↗
Licencja
MIT
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format20 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Wysyła powiadomienia w czasie rzeczywistym z API do aplikacji Admin przez websockety, np. postęp zadań w tle.

Oryginalny opis (EN)

Sending real-time notifications from the API to the Admin app over websockets, and reacting to them on the client. Use this skill when the developer wants to push a message to the user who triggered some server-side work (e.g. per-entry progress from a background task/bulk action) and show a toast, update a cache, or refresh UI in response. Requires Webiny 6.5.0 or newer.

Jak działa

  1. TL;DR
  2. API — emit
  3. Admin — listen
  4. Admin — register
  5. Related
Sekcje z nagłówków SKILL.md, w oryginale · 107 linii, 391 słów
Podgląd SKILL.md
---
name: webiny-websocket-notifications
description: >
  Sending real-time notifications from the API to the Admin app over websockets, and
  reacting to them on the client. Use this skill when the developer wants to push a
  message to the user who triggered some server-side work (e.g. per-entry progress from a
  background task/bulk action) and show a toast, update a cache, or refresh UI in response.
  Requires Webiny 6.5.0 or newer.
---

# Websocket notifications (API → Admin)

## TL;DR

On the **API**, inject `WebsocketsSendToIdentityUseCase` (`webiny/api`) + `IdentityContext`
(`webiny/api/security`) and call `sendToIdentity.execute({ id }, { action, data })`. On the
**Admin**, implement a `WebsocketEventHandler` (`webiny/admin/websockets`) that filters on
`action` and reacts (e.g. toast via `Notifications` from `webiny/admin`), registered with
`createFeature` + `RegisterFeature`.

## API — emit

```typescript
import { WebsocketsSendToIdentityUseCase } from "webiny/api";
import { IdentityContext } from "webiny/api/security";

class MyTaskOrHook {
  constructor(
    private identityContext: IdentityContext.Interface,
    private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface
  ) {}

  async notify(entry) {
    // Best-effort: a websocket failure must never fail the real work.
    try {
      const identity = this.identityContext.getIdentity();
      if (identity) {
        await this.sendToIdentity.execute(
          { id: identity.id },
          {
            action: "cms.product.discountApplied",
            data: { id: entry.entryId, price: entry.values.price }
          }
        );
      }
    } catch (ex) {
      // log & swallow
    }
  }
}
// dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]
```

- Send to the user who triggered the work — get them from `IdentityContext`. In a
  background task/bulk action, the triggering identity is available.
- Use a namespaced `action` string; put the payload in `data`.
- Sender data type: `{ action?: string; data?: T; error?: {...} }`.

## Admin — listen

```typescript
import { WebsocketEventHandler } from "webiny/admin/websockets";
import { Notifications } from "webiny/admin";

const ACTION = "cms.product.discountApplied";

class MyHandlerImpl implements WebsocketEventHandler.Interface {
  constructor(private notifications: Notifications.Interface) {}

  async handle(event: WebsocketEventHandler.Event): Promise<void> {
    const payload = event.payload as { action?: string; data?: { id: string; price: number } };
    if (payload.action !== ACTION || !payload.data) {
      return; // every handler sees every message — filter by action
    }
    this.notifications.success({
      title: "Discount applied",
      description: `New price ${payload.data.price}.`
    });
  }
}

export const MyHandler = WebsocketEventHandler.createImplementation({
  implementation: MyHandlerImpl,
  dependencies: [Notifications]
});
```

Read the message off `event.payload` — `event.payload.action` and `event.payload.data`
(the exact `{ action, data }` object the API sent).

## Admin — register

Register the handler in a feature and render it from your `Admin.Extension`:

```tsx
import { createFeature, RegisterFeature } from "webiny/admin";
import { MyHandler } from "./MyHandler.js";

const MyFeature = createFeature({
  name: "MyExtension/Notifications",
  register(container) {
    container.register(MyHandler);
  }
});

export default () => <RegisterFeature feature={MyFeature} />;
```

The websockets runner resolves every registered `WebsocketEventHandler` and calls `handle`
for each incoming message — hence the `action` filter in each handler.

## Related

- `webiny-cms-bulk-actions` — the typical emitter: a bulk action's `processData` sends a
  message per processed entry so the Admin can toast progress live.

Wersje

W bazie nie ma innych skilli o nazwie webiny-websocket-notifications.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 28.10.2026 · wersja paczki 6663f3cace20 (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95webiny-cms-bulk-actions
    Tworzy własną akcję zbiorczą dla wpisów Headless CMS w Webiny i przycisk w Admin, uruchamiany jako zadanie w tle.
  • 95webiny-full-stack-architect
    Tworzy szkielet rozszerzenia Webiny obejmującego API i Admin: punkty wejścia, warstwę domeny i deklaracje parametrów.
  • 100websocket-engineer
    Projektuje komunikację dwukierunkową w czasie rzeczywistym przez WebSockety i Socket.IO, także na dużą skalę.
  • 90FastAPI Real-Time Features
    Podaje wzorce funkcji czasu rzeczywistego we FastAPI: WebSocket, wgrywanie plików, upload do S3, wysyłka e-maili, powiadomienia push i rozsyłanie zdarzeń.
  • 100building-websocket-server
    Buduje skalowalne serwery WebSocket do dwukierunkowej komunikacji w czasie rzeczywistym.
  • 100building-websocket-server
    Buduje skalowalne serwery WebSocket do dwukierunkowej komunikacji w czasie rzeczywistym.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.