@webiny/app 6.6.0-alpha.10 → 6.6.0-alpha.12

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.
@@ -0,0 +1,12 @@
1
+ import { WebsocketEventHandler } from "../../features/websocketEvents/index.js";
2
+ import { EventPublisher } from "../../features/eventPublisher/index.js";
3
+ /** Turns the api's record-changed messages into `RecordChangedEvent`s. */
4
+ declare class RecordChangeMessagesImpl implements WebsocketEventHandler.Interface {
5
+ private eventPublisher;
6
+ constructor(eventPublisher: EventPublisher.Interface);
7
+ handle(event: WebsocketEventHandler.Event): Promise<void>;
8
+ }
9
+ export declare const RecordChangeMessages: typeof RecordChangeMessagesImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("~/features/eventPublisher/index.js").IEventHandler<import("~/features/websocketEvents/index.js").WebsocketEvent>>;
11
+ };
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import { WebsocketEventHandler } from "../websocketEvents/index.js";
2
+ import { EventPublisher } from "../eventPublisher/index.js";
3
+ import { RecordChangedEvent } from "./RecordChangedEvent.js";
4
+ const RECORD_CHANGED_ACTION = "record.changed";
5
+ class RecordChangeMessagesImpl {
6
+ constructor(eventPublisher){
7
+ this.eventPublisher = eventPublisher;
8
+ }
9
+ async handle(event) {
10
+ if (event.payload.action !== RECORD_CHANGED_ACTION) return;
11
+ const { data } = event.payload;
12
+ await this.eventPublisher.publish(new RecordChangedEvent(data));
13
+ }
14
+ }
15
+ const RecordChangeMessages = WebsocketEventHandler.createImplementation({
16
+ implementation: RecordChangeMessagesImpl,
17
+ dependencies: [
18
+ EventPublisher
19
+ ]
20
+ });
21
+ export { RecordChangeMessages };
22
+
23
+ //# sourceMappingURL=RecordChangeMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/recordChanges/RecordChangeMessages.js","sources":["../../../src/features/recordChanges/RecordChangeMessages.ts"],"sourcesContent":["import { WebsocketEventHandler } from \"~/features/websocketEvents/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { RecordChangedEvent } from \"./RecordChangedEvent.js\";\nimport type { RecordChangedPayload } from \"./RecordChangedEvent.js\";\n\n// Sent by the api when a record changes; see `NotifyRecordChangeUseCase` in @webiny/api-core.\nconst RECORD_CHANGED_ACTION = \"record.changed\";\n\n/** Turns the api's record-changed messages into `RecordChangedEvent`s. */\nclass RecordChangeMessagesImpl implements WebsocketEventHandler.Interface {\n constructor(private eventPublisher: EventPublisher.Interface) {}\n\n async handle(event: WebsocketEventHandler.Event): Promise<void> {\n if (event.payload.action !== RECORD_CHANGED_ACTION) {\n return;\n }\n\n const { data } = event.payload as unknown as { data: RecordChangedPayload };\n await this.eventPublisher.publish(new RecordChangedEvent(data));\n }\n}\n\nexport const RecordChangeMessages = WebsocketEventHandler.createImplementation({\n implementation: RecordChangeMessagesImpl,\n dependencies: [EventPublisher]\n});\n"],"names":["RECORD_CHANGED_ACTION","RecordChangeMessagesImpl","eventPublisher","event","data","RecordChangedEvent","RecordChangeMessages","WebsocketEventHandler","EventPublisher"],"mappings":";;;AAMA,MAAMA,wBAAwB;AAG9B,MAAMC;IACF,YAAoBC,cAAwC,CAAE;aAA1CA,cAAc,GAAdA;IAA2C;IAE/D,MAAM,OAAOC,KAAkC,EAAiB;QAC5D,IAAIA,MAAM,OAAO,CAAC,MAAM,KAAKH,uBACzB;QAGJ,MAAM,EAAEI,IAAI,EAAE,GAAGD,MAAM,OAAO;QAC9B,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIE,mBAAmBD;IAC7D;AACJ;AAEO,MAAME,uBAAuBC,sBAAsB,oBAAoB,CAAC;IAC3E,gBAAgBN;IAChB,cAAc;QAACO;KAAe;AAClC"}
@@ -0,0 +1,20 @@
1
+ import { BaseEvent } from "../../features/eventPublisher/index.js";
2
+ export type RecordChange = "created" | "updated" | "deleted";
3
+ export interface RecordChangedPayload {
4
+ /** Names the kind of record, such as `security.team`. */
5
+ type: string;
6
+ id: string;
7
+ /** For a record whose id only means something inside a parent, such as a CMS entry's model: the parent's id. */
8
+ scope?: string;
9
+ change: RecordChange;
10
+ }
11
+ /**
12
+ * A record changed, and what the admin holds of it may be out of date.
13
+ *
14
+ * Says nothing about where the news came from. The websocket is the source today
15
+ * (`RecordChangeMessages`); anything else can publish it and the handlers stay as they are.
16
+ */
17
+ export declare class RecordChangedEvent extends BaseEvent<RecordChangedPayload> {
18
+ readonly eventType: "App/RecordChanged";
19
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("~/features/eventPublisher/index.js").IEventHandler<RecordChangedEvent>>;
20
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseEvent } from "../eventPublisher/index.js";
2
+ import { RecordChangedEventHandler } from "./abstractions.js";
3
+ class RecordChangedEvent extends BaseEvent {
4
+ getHandlerAbstraction() {
5
+ return RecordChangedEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "App/RecordChanged";
9
+ }
10
+ }
11
+ export { RecordChangedEvent };
12
+
13
+ //# sourceMappingURL=RecordChangedEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/recordChanges/RecordChangedEvent.js","sources":["../../../src/features/recordChanges/RecordChangedEvent.ts"],"sourcesContent":["import { BaseEvent } from \"~/features/eventPublisher/index.js\";\nimport { RecordChangedEventHandler } from \"./abstractions.js\";\n\nexport type RecordChange = \"created\" | \"updated\" | \"deleted\";\n\nexport interface RecordChangedPayload {\n /** Names the kind of record, such as `security.team`. */\n type: string;\n id: string;\n /** For a record whose id only means something inside a parent, such as a CMS entry's model: the parent's id. */\n scope?: string;\n change: RecordChange;\n}\n\n/**\n * A record changed, and what the admin holds of it may be out of date.\n *\n * Says nothing about where the news came from. The websocket is the source today\n * (`RecordChangeMessages`); anything else can publish it and the handlers stay as they are.\n */\nexport class RecordChangedEvent extends BaseEvent<RecordChangedPayload> {\n readonly eventType = \"App/RecordChanged\" as const;\n\n getHandlerAbstraction() {\n return RecordChangedEventHandler;\n }\n}\n"],"names":["RecordChangedEvent","BaseEvent","RecordChangedEventHandler"],"mappings":";;AAoBO,MAAMA,2BAA2BC;IAGpC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACM,SAAS,GAAG;;AAKzB"}
@@ -0,0 +1,11 @@
1
+ import type { IEventHandler } from "../../features/eventPublisher/index.js";
2
+ import type { RecordChangedEvent } from "./RecordChangedEvent.js";
3
+ /**
4
+ * Reacts to a record changed somewhere this tab did not see: by the assistant, a background task or
5
+ * another tab. Every handler receives every change and filters on `event.payload.type`.
6
+ */
7
+ export declare const RecordChangedEventHandler: import("@webiny/di").Abstraction<IEventHandler<RecordChangedEvent>>;
8
+ export declare namespace RecordChangedEventHandler {
9
+ type Interface = IEventHandler<RecordChangedEvent>;
10
+ type Event = RecordChangedEvent;
11
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const RecordChangedEventHandler = createAbstraction("App/RecordChangedEventHandler");
3
+ export { RecordChangedEventHandler };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/recordChanges/abstractions.js","sources":["../../../src/features/recordChanges/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RecordChangedEvent } from \"./RecordChangedEvent.js\";\n\n/**\n * Reacts to a record changed somewhere this tab did not see: by the assistant, a background task or\n * another tab. Every handler receives every change and filters on `event.payload.type`.\n */\nexport const RecordChangedEventHandler = createAbstraction<IEventHandler<RecordChangedEvent>>(\n \"App/RecordChangedEventHandler\"\n);\n\nexport namespace RecordChangedEventHandler {\n export type Interface = IEventHandler<RecordChangedEvent>;\n export type Event = RecordChangedEvent;\n}\n"],"names":["RecordChangedEventHandler","createAbstraction"],"mappings":";AAQO,MAAMA,4BAA4BC,kBACrC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Publishes a `RecordChangedEvent` for every record-changed message from the api. Register it once,
3
+ * in the container the websocket bridge publishes from; registered twice, every event goes out twice.
4
+ */
5
+ export declare const RecordChangesFeature: import("@webiny/feature/admin").FeatureDefinition<any, []>;
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/admin";
2
+ import { RecordChangeMessages } from "./RecordChangeMessages.js";
3
+ const RecordChangesFeature = createFeature({
4
+ name: "App/RecordChanges",
5
+ register (container) {
6
+ container.register(RecordChangeMessages);
7
+ }
8
+ });
9
+ export { RecordChangesFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/recordChanges/feature.js","sources":["../../../src/features/recordChanges/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { RecordChangeMessages } from \"./RecordChangeMessages.js\";\n\n/**\n * Publishes a `RecordChangedEvent` for every record-changed message from the api. Register it once,\n * in the container the websocket bridge publishes from; registered twice, every event goes out twice.\n */\nexport const RecordChangesFeature = createFeature({\n name: \"App/RecordChanges\",\n register(container) {\n container.register(RecordChangeMessages);\n }\n});\n"],"names":["RecordChangesFeature","createFeature","container","RecordChangeMessages"],"mappings":";;AAOO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,4 @@
1
+ export { RecordChangesFeature } from "./feature.js";
2
+ export { RecordChangedEvent } from "./RecordChangedEvent.js";
3
+ export type { RecordChange, RecordChangedPayload } from "./RecordChangedEvent.js";
4
+ export { RecordChangedEventHandler } from "./abstractions.js";
@@ -0,0 +1,3 @@
1
+ export { RecordChangesFeature } from "./feature.js";
2
+ export { RecordChangedEvent } from "./RecordChangedEvent.js";
3
+ export { RecordChangedEventHandler } from "./abstractions.js";
@@ -0,0 +1,13 @@
1
+ import { BaseEvent } from "../../features/eventPublisher/index.js";
2
+ import type { GenericRecord } from "../../types.js";
3
+ export interface WebsocketMessageData extends GenericRecord {
4
+ action: string;
5
+ }
6
+ /**
7
+ * Published for every incoming websocket message. Carries the raw message data
8
+ * (which always includes an `action`), and routes to `WebsocketEventHandler` handlers.
9
+ */
10
+ export declare class WebsocketEvent extends BaseEvent<WebsocketMessageData> {
11
+ readonly eventType: "Websockets/MessageReceived";
12
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("~/features/eventPublisher/index.js").IEventHandler<WebsocketEvent>>;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseEvent } from "../eventPublisher/index.js";
2
+ import { WebsocketEventHandler } from "./abstractions.js";
3
+ class WebsocketEvent extends BaseEvent {
4
+ getHandlerAbstraction() {
5
+ return WebsocketEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "Websockets/MessageReceived";
9
+ }
10
+ }
11
+ export { WebsocketEvent };
12
+
13
+ //# sourceMappingURL=WebsocketEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/websocketEvents/WebsocketEvent.js","sources":["../../../src/features/websocketEvents/WebsocketEvent.ts"],"sourcesContent":["import { BaseEvent } from \"~/features/eventPublisher/index.js\";\nimport type { GenericRecord } from \"~/types.js\";\nimport { WebsocketEventHandler } from \"./abstractions.js\";\n\nexport interface WebsocketMessageData extends GenericRecord {\n action: string;\n}\n\n/**\n * Published for every incoming websocket message. Carries the raw message data\n * (which always includes an `action`), and routes to `WebsocketEventHandler` handlers.\n */\nexport class WebsocketEvent extends BaseEvent<WebsocketMessageData> {\n readonly eventType = \"Websockets/MessageReceived\" as const;\n\n getHandlerAbstraction() {\n return WebsocketEventHandler;\n }\n}\n"],"names":["WebsocketEvent","BaseEvent","WebsocketEventHandler"],"mappings":";;AAYO,MAAMA,uBAAuBC;IAGhC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACM,SAAS,GAAG;;AAKzB"}
@@ -0,0 +1,16 @@
1
+ import type { IEventHandler } from "../../features/eventPublisher/index.js";
2
+ import type { WebsocketEvent } from "./WebsocketEvent.js";
3
+ /**
4
+ * Handlers registered against this abstraction receive EVERY incoming websocket message
5
+ * (published as a `WebsocketEvent` by the websockets→EventPublisher bridge in @webiny/app-websockets).
6
+ * Each handler is responsible for filtering by `event.payload.action` and reacting to the ones it
7
+ * cares about, instead of subscribing to the websocket service directly.
8
+ *
9
+ * Lives here, next to `EventPublisher`, rather than in @webiny/app-websockets, so packages that
10
+ * app-websockets depends on (such as @webiny/app-admin) can handle messages too.
11
+ */
12
+ export declare const WebsocketEventHandler: import("@webiny/di").Abstraction<IEventHandler<WebsocketEvent>>;
13
+ export declare namespace WebsocketEventHandler {
14
+ type Interface = IEventHandler<WebsocketEvent>;
15
+ type Event = WebsocketEvent;
16
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const WebsocketEventHandler = createAbstraction("App/WebsocketEventHandler");
3
+ export { WebsocketEventHandler };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/websocketEvents/abstractions.js","sources":["../../../src/features/websocketEvents/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { WebsocketEvent } from \"./WebsocketEvent.js\";\n\n/**\n * Handlers registered against this abstraction receive EVERY incoming websocket message\n * (published as a `WebsocketEvent` by the websockets→EventPublisher bridge in @webiny/app-websockets).\n * Each handler is responsible for filtering by `event.payload.action` and reacting to the ones it\n * cares about, instead of subscribing to the websocket service directly.\n *\n * Lives here, next to `EventPublisher`, rather than in @webiny/app-websockets, so packages that\n * app-websockets depends on (such as @webiny/app-admin) can handle messages too.\n */\nexport const WebsocketEventHandler = createAbstraction<IEventHandler<WebsocketEvent>>(\n \"App/WebsocketEventHandler\"\n);\n\nexport namespace WebsocketEventHandler {\n export type Interface = IEventHandler<WebsocketEvent>;\n export type Event = WebsocketEvent;\n}\n"],"names":["WebsocketEventHandler","createAbstraction"],"mappings":";AAaO,MAAMA,wBAAwBC,kBACjC"}
@@ -0,0 +1,3 @@
1
+ export { WebsocketEventHandler } from "./abstractions.js";
2
+ export { WebsocketEvent } from "./WebsocketEvent.js";
3
+ export type { WebsocketMessageData } from "./WebsocketEvent.js";
@@ -0,0 +1,2 @@
1
+ export { WebsocketEventHandler } from "./abstractions.js";
2
+ export { WebsocketEvent } from "./WebsocketEvent.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app",
3
- "version": "6.6.0-alpha.10",
3
+ "version": "6.6.0-alpha.12",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -20,12 +20,12 @@
20
20
  "dependencies": {
21
21
  "@types/react": "19.3.0",
22
22
  "@webiny/di": "2.0.0",
23
- "@webiny/feature": "6.6.0-alpha.10",
24
- "@webiny/i18n": "6.6.0-alpha.10",
25
- "@webiny/i18n-react": "6.6.0-alpha.10",
26
- "@webiny/plugins": "6.6.0-alpha.10",
27
- "@webiny/react-composition": "6.6.0-alpha.10",
28
- "@webiny/react-properties": "6.6.0-alpha.10",
23
+ "@webiny/feature": "6.6.0-alpha.12",
24
+ "@webiny/i18n": "6.6.0-alpha.12",
25
+ "@webiny/i18n-react": "6.6.0-alpha.12",
26
+ "@webiny/plugins": "6.6.0-alpha.12",
27
+ "@webiny/react-composition": "6.6.0-alpha.12",
28
+ "@webiny/react-properties": "6.6.0-alpha.12",
29
29
  "graphql": "16.14.2",
30
30
  "history": "5.3.0",
31
31
  "invariant": "2.2.4",
@@ -39,7 +39,7 @@
39
39
  "devDependencies": {
40
40
  "@types/lodash": "4.17.27",
41
41
  "@types/warning": "3.0.4",
42
- "@webiny/build-tools": "6.6.0-alpha.10",
42
+ "@webiny/build-tools": "6.6.0-alpha.12",
43
43
  "rimraf": "6.1.3",
44
44
  "type-fest": "5.10.0",
45
45
  "typescript": "7.0.2",