@enonic-types/lib-event 7.11.0-B1 → 7.11.0-B4

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.
Files changed (3) hide show
  1. package/README.md +18 -28
  2. package/event.d.ts +3 -6
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -5,67 +5,57 @@
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm i --save-dev @enonic/lib-event
8
+ npm i --save-dev @enonic-types/lib-event
9
9
  ```
10
10
 
11
11
  ## Use
12
12
 
13
- Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code.
14
-
15
- `tsconfig.json`
16
- ```json
17
- {
18
- "compilerOptions": {
19
- "types": [
20
- "@enonic-types/lib-event"
21
- ]
22
- }
23
- }
24
- ```
25
-
26
13
  ### Require and custom imports
27
14
 
28
- To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP global objects, e.g. `log`, `app`, `__`, etc, requiring library by the default path will return typed object.
15
+ To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
16
+ global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
29
17
 
30
18
  `tsconfig.json`
31
- ```diff
19
+
20
+ ```json
32
21
  {
33
22
  "compilerOptions": {
34
23
  "types": [
35
- + "@enonic-types/global"
36
- "@enonic-types/lib-event"
24
+ "@enonic-types/global"
37
25
  ]
38
26
  }
39
27
  }
40
28
  ```
41
29
 
42
30
  `example.ts`
31
+
43
32
  ```ts
44
33
  const {listener} = require('/lib/xp/event');
45
34
  ```
46
35
 
47
- More detailed explanation on how it works and how to type custom import function can be found [here](https://github.com/enonic/xp/tree/master/modules/lib/typescript/README.md).
36
+ More detailed explanation on how it works and how to type custom import function can be
37
+ found [here](https://developer.enonic.com/docs/xp/stable/api).
48
38
 
49
39
  ### ES6-style import
50
40
 
51
- If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper types mapping to your configuration.
41
+ If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper
42
+ types mapping to your configuration.
52
43
 
53
44
  `tsconfig.json`
54
- ```diff
45
+
46
+ ```json
55
47
  {
56
48
  "compilerOptions": {
57
- "types": [
58
- "@enonic-types/lib-event"
59
- ]
60
- + "baseUrl": "./",
61
- + "paths": {
62
- + "/lib/xp/event": ["node_modules/@enonic-types/lib-event"],
63
- + }
49
+ "baseUrl": "./",
50
+ "paths": {
51
+ "/lib/xp/event": ["node_modules/@enonic-types/lib-event"]
52
+ }
64
53
  }
65
54
  }
66
55
  ```
67
56
 
68
57
  `example.ts`
58
+
69
59
  ```ts
70
60
  import {listener, EnonicEvent} from '/lib/xp/event';
71
61
  ```
package/event.d.ts CHANGED
@@ -7,7 +7,7 @@ export interface ListenerParams<EventData extends object = EnonicEventData> {
7
7
  /**
8
8
  * Event type pattern
9
9
  */
10
- type: EnonicEventTypes;
10
+ type: string;
11
11
  /**
12
12
  * Callback event listener
13
13
  */
@@ -21,7 +21,7 @@ export interface SendParams {
21
21
  /**
22
22
  * Event type
23
23
  */
24
- type: EnonicEventTypes;
24
+ type: string;
25
25
  /**
26
26
  * `true` if it should be distributed in cluster
27
27
  */
@@ -32,7 +32,7 @@ export interface SendParams {
32
32
  data?: object;
33
33
  }
34
34
  export interface EnonicEvent<EventData extends object = EnonicEventData> {
35
- readonly type: EnonicEventTypes;
35
+ readonly type: string;
36
36
  readonly timestamp: number;
37
37
  readonly localOrigin: boolean;
38
38
  readonly distributed: boolean;
@@ -49,8 +49,6 @@ export interface EnonicEventDataNode {
49
49
  readonly repo: string;
50
50
  readonly newPath?: string;
51
51
  }
52
- declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
53
- export declare type EnonicEventTypes = LiteralUnion<string>;
54
52
  /**
55
53
  * Event functions.
56
54
  *
@@ -81,4 +79,3 @@ export declare function listener<EventData extends object = EnonicEventData>(par
81
79
  * @param {object} event.data Additional data for event.
82
80
  */
83
81
  export declare function send(event: SendParams): void;
84
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/lib-event",
3
- "version": "7.11.0-B1",
3
+ "version": "7.11.0-B4",
4
4
  "description": "Type definitions for lib-event.",
5
5
  "types": "event.d.ts",
6
6
  "files": [
@@ -26,6 +26,7 @@
26
26
  "url": "https://github.com/enonic/xp/issues"
27
27
  },
28
28
  "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
+ "dependencies": {},
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  }