@webiny/app 6.6.0-alpha.11 → 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.
- package/features/recordChanges/RecordChangeMessages.d.ts +12 -0
- package/features/recordChanges/RecordChangeMessages.js +23 -0
- package/features/recordChanges/RecordChangeMessages.js.map +1 -0
- package/features/recordChanges/RecordChangedEvent.d.ts +20 -0
- package/features/recordChanges/RecordChangedEvent.js +13 -0
- package/features/recordChanges/RecordChangedEvent.js.map +1 -0
- package/features/recordChanges/abstractions.d.ts +11 -0
- package/features/recordChanges/abstractions.js +5 -0
- package/features/recordChanges/abstractions.js.map +1 -0
- package/features/recordChanges/feature.d.ts +5 -0
- package/features/recordChanges/feature.js +11 -0
- package/features/recordChanges/feature.js.map +1 -0
- package/features/recordChanges/index.d.ts +4 -0
- package/features/recordChanges/index.js +3 -0
- package/package.json +8 -8
|
@@ -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 @@
|
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
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.
|
|
24
|
-
"@webiny/i18n": "6.6.0-alpha.
|
|
25
|
-
"@webiny/i18n-react": "6.6.0-alpha.
|
|
26
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
27
|
-
"@webiny/react-composition": "6.6.0-alpha.
|
|
28
|
-
"@webiny/react-properties": "6.6.0-alpha.
|
|
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.
|
|
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",
|