@hawk.so/types 0.1.32-rc.1 → 0.1.32-rc.3

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.
@@ -3,10 +3,10 @@ import { AffectedUser } from './affectedUser';
3
3
  import { EventAddons } from './addons';
4
4
  import { Json } from '../../utils';
5
5
  /**
6
- * Information about event
7
- * That object will be send as 'payload' to the Collector
6
+ * Information about event (Payload of the event)
7
+ * That object will be sent as 'payload' from the Collector to the workers
8
8
  */
9
- export interface EventData<CatcherAddons extends EventAddons> {
9
+ export interface EventData<Addons extends EventAddons> {
10
10
  /**
11
11
  * Event title
12
12
  */
@@ -23,7 +23,7 @@ export interface EventData<CatcherAddons extends EventAddons> {
23
23
  /**
24
24
  * Catcher-specific information
25
25
  */
26
- addons?: CatcherAddons | string;
26
+ addons?: Addons;
27
27
  /**
28
28
  * Current release (aka version, revision) of an application
29
29
  */
@@ -41,36 +41,29 @@ export interface EventData<CatcherAddons extends EventAddons> {
41
41
  */
42
42
  catcherVersion?: string;
43
43
  }
44
- /**
45
- * Event accepted and processed by Collector.
46
- * It sets the timestamp to the event payload.
47
- */
48
- export interface EventDataAccepted<EventAddons> extends EventData<EventAddons> {
49
- }
50
44
  /**
51
45
  * Event data with decoded unsafe fields
52
46
  */
53
- export interface DecodedEventData<EventAddons> extends EventDataAccepted<EventAddons> {
47
+ export interface DecodedEventData<Addons extends EventAddons> extends EventData<Addons> {
54
48
  /**
55
- * Decoded context
49
+ * Json parsed context string
56
50
  */
57
51
  context?: EventContext;
58
52
  /**
59
- * Decoded addons
53
+ * Json parsed addons string
60
54
  */
61
- addons?: EventAddons;
55
+ addons?: Addons;
62
56
  }
63
57
  /**
64
58
  * Event data with encoded unsafe fields
65
- *
66
59
  */
67
- export interface EncodedEventData extends EventDataAccepted<EventAddons> {
60
+ export interface EncodedEventData extends EventData<EventAddons> {
68
61
  /**
69
- * Encoded context
62
+ * Stringified context object
70
63
  */
71
64
  context?: string;
72
65
  /**
73
- * Encoded addons
66
+ * Stringified addons object
74
67
  */
75
68
  addons?: string;
76
69
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Interface representing the structure of log CatcherMessage payload.
3
+ * This interface is for payload of the CatcherMessages with CatcherType 'logs/*'.
4
+ */
5
+ export interface LogData {
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Interface representing the structure of performance CatcherMessage payload.
3
+ * This interface is for payload of the CatcherMessages with CatcherType 'performance'.
4
+ */
5
+ export interface PerformanceData {
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +1,34 @@
1
- import { EventData } from "../base/event/event";
2
- import { EventAddons } from "../base/event/addons";
1
+ import { EventData } from '../base/event/event';
2
+ import { PerformanceData } from '../base/performance/performance';
3
+ import type { JavaScriptAddons, PhpAddons, NodeJSAddons, GoAddons, PythonAddons } from '../base/event/addons';
3
4
  /**
4
- * Structure describing a message sending by Catcher
5
+ * Type that represents all supported Catcher message types for events
5
6
  */
6
- export default interface CatcherMessage<CatcherAddons extends EventAddons> {
7
+ declare type ErrorsCatcherType = 'errors/javascript' | 'errors/php' | 'errors/nodejs' | 'errors/go' | 'errors/python';
8
+ /**
9
+ * Type that represents all supported Catcher message types for performance
10
+ */
11
+ declare type MetricsCatcherType = 'performance';
12
+ /**
13
+ * Union type that represents all supported Catcher message types
14
+ */
15
+ declare type CatcherMessageType = ErrorsCatcherType | MetricsCatcherType;
16
+ /**
17
+ * Type that represents the payload of a Catcher message based on its type
18
+ */
19
+ declare type CatcherMessagePayload<Type extends CatcherMessageType> = {
20
+ 'errors/javascript': EventData<JavaScriptAddons>;
21
+ 'errors/php': EventData<PhpAddons>;
22
+ 'errors/nodejs': EventData<NodeJSAddons>;
23
+ 'errors/go': EventData<GoAddons>;
24
+ 'errors/python': EventData<PythonAddons>;
25
+ 'performance': PerformanceData;
26
+ }[Type];
27
+ /**
28
+ * Interface that represents a message sent by a Catcher
29
+ * It calculates the type of the payload based on the Catcher type
30
+ */
31
+ export interface CatcherMessage<Type extends CatcherMessageType> {
7
32
  /**
8
33
  * User project's Integration Token
9
34
  */
@@ -11,9 +36,25 @@ export default interface CatcherMessage<CatcherAddons extends EventAddons> {
11
36
  /**
12
37
  * Hawk Catcher name
13
38
  */
14
- catcherType: string;
39
+ catcherType: Type;
15
40
  /**
16
41
  * All information about the event
17
42
  */
18
- payload: EventData<CatcherAddons>;
43
+ payload: CatcherMessagePayload<Type>;
19
44
  }
45
+ /**
46
+ * Type that represents a Catcher message accepted by the collector
47
+ * It omits the token field and adds projectId and timestamp
48
+ */
49
+ export declare type CatcherMessageAccepted<Type extends CatcherMessageType> = Omit<CatcherMessage<Type>, 'token'> & {
50
+ /**
51
+ * Id of the project that sent the message
52
+ */
53
+ projectId: string;
54
+ /**
55
+ * Timestamp of when the message was accepted by the collector
56
+ * This is the current time in milliseconds since the Unix epoch
57
+ */
58
+ timestamp: number;
59
+ };
60
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
- import { DecodedEventData, EncodedEventData, EventDataAccepted } from "../base/event/event";
2
+ import { DecodedEventData, EncodedEventData, EventData } from "../base/event/event";
3
3
  import { UserDBScheme } from "./user";
4
4
  import { EventAddons } from '../base/event/addons';
5
5
  /**
@@ -25,7 +25,7 @@ export interface GroupedEventDBScheme {
25
25
  /**
26
26
  * Event data
27
27
  */
28
- payload: EventDataAccepted<EventAddons>;
28
+ payload: EventData<EventAddons>;
29
29
  /**
30
30
  * How many users catch this error
31
31
  */
@@ -37,7 +37,7 @@ export interface GroupedEventDBScheme {
37
37
  /**
38
38
  * Occurrence time
39
39
  * Unix timestamp in seconds (example: 1567009247.576)
40
- * (Set by the Collector)
40
+ * (created by the Collector)
41
41
  */
42
42
  timestamp: number;
43
43
  }
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
- import { DecodedEventData, EncodedEventData, EventDataAccepted } from '../base/event/event';
2
+ import { DecodedEventData, EncodedEventData, EventData } from '../base/event/event';
3
3
  import { EventAddons } from '../base/event/addons';
4
4
  export interface RepetitionDBScheme {
5
5
  /**
@@ -12,10 +12,10 @@ export interface RepetitionDBScheme {
12
12
  groupHash: string;
13
13
  /**
14
14
  * @deprecated, use delta instead
15
- * And any of EventDataAccepted field with diff
15
+ * And any of EventData field with diff
16
16
  * except fields that used in groupHash
17
17
  */
18
- payload?: EventDataAccepted<EventAddons>;
18
+ payload?: EventData<EventAddons>;
19
19
  /**
20
20
  * Delta between original event and repetition
21
21
  */
@@ -23,7 +23,7 @@ export interface RepetitionDBScheme {
23
23
  /**
24
24
  * Occurrence time
25
25
  * Unix timestamp in seconds (example: 1567009247.576)
26
- * (Set by the Collector)
26
+ * (created by the Collector)
27
27
  */
28
28
  timestamp: number;
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawk.so/types",
3
- "version": "0.1.32-rc.1",
3
+ "version": "0.1.32-rc.3",
4
4
  "description": "TypeScript definitions for Hawk",
5
5
  "types": "build/index.d.ts",
6
6
  "main": "build/index.js",
@@ -4,10 +4,10 @@ import { EventAddons } from './addons';
4
4
  import { Json } from '../../utils';
5
5
 
6
6
  /**
7
- * Information about event
8
- * That object will be send as 'payload' to the Collector
7
+ * Information about event (Payload of the event)
8
+ * That object will be sent as 'payload' from the Collector to the workers
9
9
  */
10
- export interface EventData<CatcherAddons extends EventAddons> {
10
+ export interface EventData<Addons extends EventAddons> {
11
11
  /**
12
12
  * Event title
13
13
  */
@@ -27,7 +27,7 @@ export interface EventData<CatcherAddons extends EventAddons> {
27
27
  /**
28
28
  * Catcher-specific information
29
29
  */
30
- addons?: CatcherAddons | string;
30
+ addons?: Addons;
31
31
 
32
32
  /**
33
33
  * Current release (aka version, revision) of an application
@@ -50,40 +50,32 @@ export interface EventData<CatcherAddons extends EventAddons> {
50
50
  catcherVersion?: string;
51
51
  }
52
52
 
53
- /**
54
- * Event accepted and processed by Collector.
55
- * It sets the timestamp to the event payload.
56
- */
57
- export interface EventDataAccepted<EventAddons> extends EventData<EventAddons> {}
58
-
59
-
60
53
  /**
61
54
  * Event data with decoded unsafe fields
62
55
  */
63
- export interface DecodedEventData<EventAddons> extends EventDataAccepted<EventAddons> {
56
+ export interface DecodedEventData<Addons extends EventAddons> extends EventData<Addons> {
64
57
  /**
65
- * Decoded context
58
+ * Json parsed context string
66
59
  */
67
60
  context?: EventContext;
68
61
 
69
62
  /**
70
- * Decoded addons
63
+ * Json parsed addons string
71
64
  */
72
- addons?: EventAddons;
65
+ addons?: Addons;
73
66
  }
74
67
 
75
68
  /**
76
69
  * Event data with encoded unsafe fields
77
- *
78
70
  */
79
- export interface EncodedEventData extends EventDataAccepted<EventAddons> {
71
+ export interface EncodedEventData extends EventData<EventAddons> {
80
72
  /**
81
- * Encoded context
73
+ * Stringified context object
82
74
  */
83
75
  context?: string;
84
76
 
85
77
  /**
86
- * Encoded addons
78
+ * Stringified addons object
87
79
  */
88
80
  addons?: string;
89
81
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Interface representing the structure of performance CatcherMessage payload.
3
+ * This interface is for payload of the CatcherMessages with CatcherType 'performance'.
4
+ */
5
+ export interface PerformanceData {}
@@ -1,10 +1,46 @@
1
- import { EventData } from "../base/event/event";
2
- import { EventAddons } from "../base/event/addons";
1
+ import { EventData } from '../base/event/event';
2
+ import { PerformanceData } from '../base/performance/performance';
3
+
4
+ import type {
5
+ JavaScriptAddons,
6
+ PhpAddons,
7
+ NodeJSAddons,
8
+ GoAddons,
9
+ PythonAddons
10
+ } from '../base/event/addons';
11
+
12
+ /**
13
+ * Type that represents all supported Catcher message types for events
14
+ */
15
+ type ErrorsCatcherType = 'errors/javascript' | 'errors/php' | 'errors/nodejs' | 'errors/go' | 'errors/python';
3
16
 
4
17
  /**
5
- * Structure describing a message sending by Catcher
18
+ * Type that represents all supported Catcher message types for performance
6
19
  */
7
- export default interface CatcherMessage<CatcherAddons extends EventAddons> {
20
+ type MetricsCatcherType = 'performance';
21
+
22
+ /**
23
+ * Union type that represents all supported Catcher message types
24
+ */
25
+ type CatcherMessageType = ErrorsCatcherType | MetricsCatcherType;
26
+
27
+ /**
28
+ * Type that represents the payload of a Catcher message based on its type
29
+ */
30
+ type CatcherMessagePayload<Type extends CatcherMessageType> = {
31
+ 'errors/javascript': EventData<JavaScriptAddons>;
32
+ 'errors/php': EventData<PhpAddons>;
33
+ 'errors/nodejs': EventData<NodeJSAddons>;
34
+ 'errors/go': EventData<GoAddons>;
35
+ 'errors/python': EventData<PythonAddons>;
36
+ 'performance': PerformanceData;
37
+ }[Type];
38
+
39
+ /**
40
+ * Interface that represents a message sent by a Catcher
41
+ * It calculates the type of the payload based on the Catcher type
42
+ */
43
+ export interface CatcherMessage<Type extends CatcherMessageType> {
8
44
  /**
9
45
  * User project's Integration Token
10
46
  */
@@ -13,10 +49,27 @@ export default interface CatcherMessage<CatcherAddons extends EventAddons> {
13
49
  /**
14
50
  * Hawk Catcher name
15
51
  */
16
- catcherType: string;
52
+ catcherType: Type;
17
53
 
18
54
  /**
19
55
  * All information about the event
20
56
  */
21
- payload: EventData<CatcherAddons>;
57
+ payload: CatcherMessagePayload<Type>;
22
58
  }
59
+
60
+ /**
61
+ * Type that represents a Catcher message accepted by the collector
62
+ * It omits the token field and adds projectId and timestamp
63
+ */
64
+ export type CatcherMessageAccepted<Type extends CatcherMessageType> = Omit<CatcherMessage<Type>, 'token'> & {
65
+ /**
66
+ * Id of the project that sent the message
67
+ */
68
+ projectId: string;
69
+
70
+ /**
71
+ * Timestamp of when the message was accepted by the collector
72
+ * This is the current time in milliseconds since the Unix epoch
73
+ */
74
+ timestamp: number;
75
+ };
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
- import { DecodedEventData, EncodedEventData, EventDataAccepted } from "../base/event/event";
2
+ import { DecodedEventData, EncodedEventData, EventData } from "../base/event/event";
3
3
  import { UserDBScheme } from "./user";
4
4
  import { EventAddons } from '../base/event/addons';
5
5
 
@@ -30,7 +30,7 @@ export interface GroupedEventDBScheme {
30
30
  /**
31
31
  * Event data
32
32
  */
33
- payload: EventDataAccepted<EventAddons>;
33
+ payload: EventData<EventAddons>;
34
34
 
35
35
  /**
36
36
  * How many users catch this error
@@ -45,7 +45,7 @@ export interface GroupedEventDBScheme {
45
45
  /**
46
46
  * Occurrence time
47
47
  * Unix timestamp in seconds (example: 1567009247.576)
48
- * (Set by the Collector)
48
+ * (created by the Collector)
49
49
  */
50
50
  timestamp: number;
51
51
  }
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
- import { DecodedEventData, EncodedEventData, EventDataAccepted } from '../base/event/event';
2
+ import { DecodedEventData, EncodedEventData, EventData } from '../base/event/event';
3
3
  import { EventAddons } from '../base/event/addons';
4
4
 
5
5
  export interface RepetitionDBScheme {
@@ -15,10 +15,10 @@ export interface RepetitionDBScheme {
15
15
 
16
16
  /**
17
17
  * @deprecated, use delta instead
18
- * And any of EventDataAccepted field with diff
18
+ * And any of EventData field with diff
19
19
  * except fields that used in groupHash
20
20
  */
21
- payload?: EventDataAccepted<EventAddons>;
21
+ payload?: EventData<EventAddons>;
22
22
 
23
23
  /**
24
24
  * Delta between original event and repetition
@@ -28,7 +28,7 @@ export interface RepetitionDBScheme {
28
28
  /**
29
29
  * Occurrence time
30
30
  * Unix timestamp in seconds (example: 1567009247.576)
31
- * (Set by the Collector)
31
+ * (created by the Collector)
32
32
  */
33
33
  timestamp: number;
34
34
  }