@mesheshq/events 1.0.4 → 1.0.5
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/README.md +2 -2
- package/dist/index.d.ts +3 -4
- package/dist/lib/errors.d.ts +2 -2
- package/dist/types.d.ts +187 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -231,7 +231,7 @@ This client uses `fetch`. Ensure your runtime provides a global `fetch`:
|
|
|
231
231
|
|
|
232
232
|
MIT
|
|
233
233
|
|
|
234
|
-
[npm-install-size-image]: https://badgen.net/packagephobia/publish/@mesheshq/events?cache=250
|
|
234
|
+
[npm-install-size-image]: https://badgen.net/packagephobia/publish/@mesheshq/events?cache=250&v1.0.5
|
|
235
235
|
[npm-install-size-url]: https://packagephobia.com/result?p=%40mesheshq%2Fevents
|
|
236
236
|
[npm-url]: https://www.npmjs.com/package/@mesheshq/events
|
|
237
|
-
[npm-version-image]: https://badgen.net/npm/v/@mesheshq/events?cache=250
|
|
237
|
+
[npm-version-image]: https://badgen.net/npm/v/@mesheshq/events?cache=250&v1.0.5
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { MeshesEventsClient, MeshesApiError };
|
|
1
|
+
export { MeshesEventsClient, MeshesApiError } from "./client.js";
|
|
2
|
+
export { default } from "./client.js";
|
|
3
|
+
export type { MeshesEvent, MeshesErrorResponse, CreateEventResponseSingle, BulkCreateEventsResult, CallbackFunction, Headers, QueryParams, MeshesOptions, MeshesOptionalRequestOptions, MeshesRequestOptions, MeshesEventPayload, MeshesEventBody, } from "./types.js";
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @extends {Error} - Error class
|
|
4
4
|
* @param {string} message - Error message
|
|
5
5
|
* @param {unknown} data - Additional error data
|
|
6
|
-
* @
|
|
6
|
+
* @class - Meshes API Error
|
|
7
7
|
*/
|
|
8
8
|
export class MeshesApiError extends Error {
|
|
9
9
|
/**
|
|
@@ -11,7 +11,7 @@ export class MeshesApiError extends Error {
|
|
|
11
11
|
* @param {unknown} [data]
|
|
12
12
|
*/
|
|
13
13
|
constructor(message: string | undefined, data?: unknown);
|
|
14
|
-
data:
|
|
14
|
+
data: unknown;
|
|
15
15
|
/**
|
|
16
16
|
* Convert error to JSON
|
|
17
17
|
* @param {boolean} stack - Include stack trace
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typescript type definitions for Meshes Events API
|
|
3
|
+
* @module meshes-events-client
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
* @description Meshes events client for emitting events with a publishable key.
|
|
7
|
+
* @repository https://github.com/mesheshq/node-meshes-events-client
|
|
8
|
+
*/
|
|
9
|
+
export type MeshesEvent = {
|
|
10
|
+
type: "event";
|
|
11
|
+
event: string;
|
|
12
|
+
id: string;
|
|
13
|
+
workspace: string;
|
|
14
|
+
created_by: string;
|
|
15
|
+
created_at: string;
|
|
16
|
+
resource: string;
|
|
17
|
+
resource_id?: string;
|
|
18
|
+
};
|
|
19
|
+
export type MeshesErrorResponse = {
|
|
20
|
+
message: string;
|
|
21
|
+
error?: unknown;
|
|
22
|
+
};
|
|
23
|
+
export type CreateEventResponseSingle = {
|
|
24
|
+
event: MeshesEvent;
|
|
25
|
+
};
|
|
26
|
+
export type BulkCreateEventsResult = {
|
|
27
|
+
count: number;
|
|
28
|
+
records: (MeshesEvent | MeshesErrorResponse)[];
|
|
29
|
+
error_count?: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Callback function to use rather than promises
|
|
33
|
+
*/
|
|
34
|
+
export type CallbackFunction<T = unknown> = (err: MeshesApiError | null, data?: T) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Request headers
|
|
37
|
+
*/
|
|
38
|
+
export type Headers = {
|
|
39
|
+
[key: string]: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Query parameters
|
|
43
|
+
*/
|
|
44
|
+
export type QueryParams = Record<string, string | number | boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Meshes API Config Options
|
|
47
|
+
*/
|
|
48
|
+
export type MeshesOptions = {
|
|
49
|
+
/**
|
|
50
|
+
* API version
|
|
51
|
+
*/
|
|
52
|
+
version?: "v1";
|
|
53
|
+
/**
|
|
54
|
+
* Request timeout in milliseconds
|
|
55
|
+
* @constraint [1000-30000]
|
|
56
|
+
*/
|
|
57
|
+
timeout?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Additional request headers
|
|
60
|
+
*/
|
|
61
|
+
headers?: Headers;
|
|
62
|
+
/**
|
|
63
|
+
* If true, will enable debug mode.
|
|
64
|
+
*/
|
|
65
|
+
debug?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* API Base Url. This is optional and can be useful for testing.
|
|
68
|
+
* @default "https://api.meshes.io/api/v1"
|
|
69
|
+
*/
|
|
70
|
+
apiBaseUrl?: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Meshes API Optional Request Options
|
|
74
|
+
*/
|
|
75
|
+
export type MeshesOptionalRequestOptions = {
|
|
76
|
+
/**
|
|
77
|
+
* Request headers
|
|
78
|
+
*/
|
|
79
|
+
headers?: Headers;
|
|
80
|
+
/**
|
|
81
|
+
* Query parameters
|
|
82
|
+
*/
|
|
83
|
+
query?: QueryParams;
|
|
84
|
+
/**
|
|
85
|
+
* Request timeout in milliseconds
|
|
86
|
+
*/
|
|
87
|
+
timeout?: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Meshes API Request Options
|
|
91
|
+
*/
|
|
92
|
+
export type MeshesRequestOptions = {
|
|
93
|
+
method: "POST";
|
|
94
|
+
path: string;
|
|
95
|
+
body?: unknown;
|
|
96
|
+
/**
|
|
97
|
+
* Request headers
|
|
98
|
+
*/
|
|
99
|
+
headers?: Headers;
|
|
100
|
+
/**
|
|
101
|
+
* Query parameters
|
|
102
|
+
*/
|
|
103
|
+
query?: QueryParams;
|
|
104
|
+
/**
|
|
105
|
+
* Request timeout in milliseconds
|
|
106
|
+
*/
|
|
107
|
+
timeout?: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Meshes event payload structure.
|
|
111
|
+
*/
|
|
112
|
+
export type MeshesEventPayload = {
|
|
113
|
+
/**
|
|
114
|
+
* The payload email. This is required.
|
|
115
|
+
*/
|
|
116
|
+
email: string;
|
|
117
|
+
first_name?: string;
|
|
118
|
+
id?: string;
|
|
119
|
+
ip_address?: string;
|
|
120
|
+
last_name?: string;
|
|
121
|
+
name?: string;
|
|
122
|
+
phone?: string;
|
|
123
|
+
resource_url?: string;
|
|
124
|
+
} & {
|
|
125
|
+
[k: string]: unknown;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Meshes event structure.
|
|
129
|
+
*/
|
|
130
|
+
export type MeshesEventBody = {
|
|
131
|
+
/**
|
|
132
|
+
* The event type for the event.
|
|
133
|
+
*/
|
|
134
|
+
event: string;
|
|
135
|
+
/**
|
|
136
|
+
* The custom resource. Defaults to 'global'.
|
|
137
|
+
*/
|
|
138
|
+
resource?: string;
|
|
139
|
+
/**
|
|
140
|
+
* The resource ID for a custom resource.
|
|
141
|
+
*/
|
|
142
|
+
resource_id?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The event payload that will be used.
|
|
145
|
+
*/
|
|
146
|
+
payload: MeshesEventPayload;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Meshes Events API Client
|
|
150
|
+
* @class
|
|
151
|
+
* @property {Function} emit - Create (emit) a single event
|
|
152
|
+
* @property {Function} emitBatch - Create (emit) multiple events up to 100 at a time
|
|
153
|
+
*/
|
|
154
|
+
export declare class MeshesEventsClient {
|
|
155
|
+
constructor(publishableKey: string, options?: MeshesOptions);
|
|
156
|
+
/**
|
|
157
|
+
* Create (emit) a single event
|
|
158
|
+
* @param {MeshesEventBody} event - The event to emit
|
|
159
|
+
* @param {MeshesOptionalRequestOptions} options - Optional request options
|
|
160
|
+
* @param {CallbackFunction<CreateEventResponseSingle>} done - Optional callback function
|
|
161
|
+
* @returns {Promise<CreateEventResponseSingle> | undefined} - Request promise or undefined if a callback is provided
|
|
162
|
+
*/
|
|
163
|
+
emit(event: MeshesEventBody, options?: MeshesOptionalRequestOptions, done?: CallbackFunction<CreateEventResponseSingle>): Promise<CreateEventResponseSingle> | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Create (emit) multiple events up to 100 at a time
|
|
166
|
+
* @param {MeshesEventBody[]} events - The events to emit
|
|
167
|
+
* @param {MeshesOptionalRequestOptions} options - Optional request options
|
|
168
|
+
* @param {CallbackFunction<BulkCreateEventsResult>} done - Optional callback function
|
|
169
|
+
* @returns {Promise<any> | undefined} - Request promise or undefined if a callback is provided
|
|
170
|
+
*/
|
|
171
|
+
emitBatch(events: MeshesEventBody[], options?: MeshesOptionalRequestOptions, done?: CallbackFunction<BulkCreateEventsResult>): Promise<BulkCreateEventsResult> | undefined;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Meshes API Error
|
|
175
|
+
*/
|
|
176
|
+
export declare class MeshesApiError extends Error {
|
|
177
|
+
data?: any;
|
|
178
|
+
constructor(message: string, data?: any);
|
|
179
|
+
toJSON(includeStack?: boolean): {
|
|
180
|
+
name: string;
|
|
181
|
+
message: string;
|
|
182
|
+
data?: any;
|
|
183
|
+
stack?: any;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
declare const _default: typeof MeshesEventsClient;
|
|
187
|
+
export default _default;
|
package/package.json
CHANGED