@coveo/relay 0.3.1 → 0.3.2
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/lib/relay.cjs +39 -18
- package/lib/relay.js +39 -18
- package/lib/relay.mjs +39 -18
- package/lib/types/config/config.d.ts +14 -0
- package/lib/types/config/config.d.ts.map +1 -0
- package/lib/types/event/meta/meta.d.ts +4 -4
- package/lib/types/event/meta/meta.d.ts.map +1 -1
- package/lib/types/event/relay-event.d.ts +2 -2
- package/lib/types/event/relay-event.d.ts.map +1 -1
- package/lib/types/event-api-call/event-api-caller.d.ts +3 -4
- package/lib/types/event-api-call/event-api-caller.d.ts.map +1 -1
- package/lib/types/relay.d.ts +4 -10
- package/lib/types/relay.d.ts.map +1 -1
- package/lib/types/validate/validate.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/relay.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var crypto = require('crypto');
|
|
4
4
|
|
|
5
|
-
async function callEventApi({ event,
|
|
6
|
-
const { token, host, organizationId } =
|
|
5
|
+
async function callEventApi({ event, config, environment, }) {
|
|
6
|
+
const { token, host, organizationId } = config;
|
|
7
7
|
const headers = {
|
|
8
8
|
"Content-Type": "application/json",
|
|
9
9
|
Authorization: `Bearer ${token}`,
|
|
10
10
|
};
|
|
11
|
-
const response = await environment.fetch(`${host}/rest/organizations/${organizationId}/events/v1${
|
|
11
|
+
const response = await environment.fetch(`${host}/rest/organizations/${organizationId}/events/v1${config.mode == "validate" ? "/validate" : ""}`, {
|
|
12
12
|
method: "POST",
|
|
13
13
|
body: JSON.stringify([event]),
|
|
14
14
|
headers,
|
|
@@ -134,22 +134,22 @@ function isBrowser() {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
const version = "0.3.
|
|
137
|
+
const version = "0.3.2" ;
|
|
138
138
|
|
|
139
|
-
function
|
|
140
|
-
const { trackingId } =
|
|
139
|
+
function getEventConfig(config) {
|
|
140
|
+
const { trackingId } = config;
|
|
141
141
|
return { trackingId };
|
|
142
142
|
}
|
|
143
143
|
function getSource() {
|
|
144
144
|
return `relay@${version}`;
|
|
145
145
|
}
|
|
146
|
-
function createMeta(type,
|
|
146
|
+
function createMeta(type, config, environment, clientIdManager) {
|
|
147
147
|
const { getReferrerUrl, getUrl, getUserAgent } = environment;
|
|
148
|
-
const
|
|
148
|
+
const eventConfig = getEventConfig(config);
|
|
149
149
|
const { clientId } = clientIdManager;
|
|
150
150
|
return Object.freeze({
|
|
151
151
|
type,
|
|
152
|
-
config,
|
|
152
|
+
config: eventConfig,
|
|
153
153
|
ts: Date.now(),
|
|
154
154
|
source: getSource(),
|
|
155
155
|
clientId,
|
|
@@ -159,10 +159,10 @@ function createMeta(type, options, environment, clientIdManager) {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
function createRelayEvent(type, payload,
|
|
162
|
+
function createRelayEvent(type, payload, config, environment, clientIdManager) {
|
|
163
163
|
return {
|
|
164
164
|
...payload,
|
|
165
|
-
meta: createMeta(type,
|
|
165
|
+
meta: createMeta(type, config, environment, clientIdManager),
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -227,32 +227,53 @@ function createListenerManager() {
|
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
function
|
|
230
|
+
function pick({ host, organizationId, token, trackingId, ...rest }) {
|
|
231
|
+
return Object.freeze({
|
|
232
|
+
host,
|
|
233
|
+
organizationId,
|
|
234
|
+
token,
|
|
235
|
+
trackingId,
|
|
236
|
+
...(!!rest.mode && { mode: rest.mode }),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function createConfigManager(initialConfig) {
|
|
240
|
+
let _config = pick(initialConfig);
|
|
241
|
+
return {
|
|
242
|
+
get: () => _config,
|
|
243
|
+
update: (updatedConfig) => {
|
|
244
|
+
_config = pick({ ..._config, ...updatedConfig });
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function createRelay(initialConfig) {
|
|
231
250
|
const environment = currentEnvironment();
|
|
232
251
|
const clientIdManager = createClientIdManager(environment);
|
|
252
|
+
const configManager = createConfigManager(initialConfig);
|
|
233
253
|
const { add, call, remove } = createListenerManager();
|
|
234
254
|
return {
|
|
235
255
|
validate: (type, payload) => {
|
|
236
|
-
const event = createRelayEvent(type, payload,
|
|
256
|
+
const event = createRelayEvent(type, payload, configManager.get(), environment, clientIdManager);
|
|
237
257
|
call(event);
|
|
238
258
|
return validate({
|
|
239
|
-
|
|
259
|
+
config: configManager.get(),
|
|
240
260
|
environment,
|
|
241
|
-
event
|
|
261
|
+
event,
|
|
242
262
|
});
|
|
243
263
|
},
|
|
244
264
|
emit: (type, payload) => {
|
|
245
|
-
const event = createRelayEvent(type, payload,
|
|
265
|
+
const event = createRelayEvent(type, payload, configManager.get(), environment, clientIdManager);
|
|
246
266
|
call(event);
|
|
247
267
|
return emit({
|
|
248
|
-
|
|
268
|
+
config: configManager.get(),
|
|
249
269
|
environment,
|
|
250
270
|
event,
|
|
251
271
|
});
|
|
252
272
|
},
|
|
253
|
-
getMeta: (type) => createMeta(type,
|
|
273
|
+
getMeta: (type) => createMeta(type, configManager.get(), environment, clientIdManager),
|
|
254
274
|
on: (type, callback) => add({ type, callback }),
|
|
255
275
|
off: (type, callback) => remove(type, callback),
|
|
276
|
+
updateConfig: (config) => configManager.update(config),
|
|
256
277
|
version,
|
|
257
278
|
};
|
|
258
279
|
}
|
package/lib/relay.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
async function callEventApi({ event,
|
|
2
|
-
const { token, host, organizationId } =
|
|
1
|
+
async function callEventApi({ event, config, environment, }) {
|
|
2
|
+
const { token, host, organizationId } = config;
|
|
3
3
|
const headers = {
|
|
4
4
|
"Content-Type": "application/json",
|
|
5
5
|
Authorization: `Bearer ${token}`,
|
|
6
6
|
};
|
|
7
|
-
const response = await environment.fetch(`${host}/rest/organizations/${organizationId}/events/v1${
|
|
7
|
+
const response = await environment.fetch(`${host}/rest/organizations/${organizationId}/events/v1${config.mode == "validate" ? "/validate" : ""}`, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
body: JSON.stringify([event]),
|
|
10
10
|
headers,
|
|
@@ -138,22 +138,22 @@ function isBrowser() {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const version = "0.3.
|
|
141
|
+
const version = "0.3.2" ;
|
|
142
142
|
|
|
143
|
-
function
|
|
144
|
-
const { trackingId } =
|
|
143
|
+
function getEventConfig(config) {
|
|
144
|
+
const { trackingId } = config;
|
|
145
145
|
return { trackingId };
|
|
146
146
|
}
|
|
147
147
|
function getSource() {
|
|
148
148
|
return `relay@${version}`;
|
|
149
149
|
}
|
|
150
|
-
function createMeta(type,
|
|
150
|
+
function createMeta(type, config, environment, clientIdManager) {
|
|
151
151
|
const { getReferrerUrl, getUrl, getUserAgent } = environment;
|
|
152
|
-
const
|
|
152
|
+
const eventConfig = getEventConfig(config);
|
|
153
153
|
const { clientId } = clientIdManager;
|
|
154
154
|
return Object.freeze({
|
|
155
155
|
type,
|
|
156
|
-
config,
|
|
156
|
+
config: eventConfig,
|
|
157
157
|
ts: Date.now(),
|
|
158
158
|
source: getSource(),
|
|
159
159
|
clientId,
|
|
@@ -163,10 +163,10 @@ function createMeta(type, options, environment, clientIdManager) {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
function createRelayEvent(type, payload,
|
|
166
|
+
function createRelayEvent(type, payload, config, environment, clientIdManager) {
|
|
167
167
|
return {
|
|
168
168
|
...payload,
|
|
169
|
-
meta: createMeta(type,
|
|
169
|
+
meta: createMeta(type, config, environment, clientIdManager),
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -231,32 +231,53 @@ function createListenerManager() {
|
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
function
|
|
234
|
+
function pick({ host, organizationId, token, trackingId, ...rest }) {
|
|
235
|
+
return Object.freeze({
|
|
236
|
+
host,
|
|
237
|
+
organizationId,
|
|
238
|
+
token,
|
|
239
|
+
trackingId,
|
|
240
|
+
...(!!rest.mode && { mode: rest.mode }),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function createConfigManager(initialConfig) {
|
|
244
|
+
let _config = pick(initialConfig);
|
|
245
|
+
return {
|
|
246
|
+
get: () => _config,
|
|
247
|
+
update: (updatedConfig) => {
|
|
248
|
+
_config = pick({ ..._config, ...updatedConfig });
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function createRelay(initialConfig) {
|
|
235
254
|
const environment = currentEnvironment();
|
|
236
255
|
const clientIdManager = createClientIdManager(environment);
|
|
256
|
+
const configManager = createConfigManager(initialConfig);
|
|
237
257
|
const { add, call, remove } = createListenerManager();
|
|
238
258
|
return {
|
|
239
259
|
validate: (type, payload) => {
|
|
240
|
-
const event = createRelayEvent(type, payload,
|
|
260
|
+
const event = createRelayEvent(type, payload, configManager.get(), environment, clientIdManager);
|
|
241
261
|
call(event);
|
|
242
262
|
return validate({
|
|
243
|
-
|
|
263
|
+
config: configManager.get(),
|
|
244
264
|
environment,
|
|
245
|
-
event
|
|
265
|
+
event,
|
|
246
266
|
});
|
|
247
267
|
},
|
|
248
268
|
emit: (type, payload) => {
|
|
249
|
-
const event = createRelayEvent(type, payload,
|
|
269
|
+
const event = createRelayEvent(type, payload, configManager.get(), environment, clientIdManager);
|
|
250
270
|
call(event);
|
|
251
271
|
return emit({
|
|
252
|
-
|
|
272
|
+
config: configManager.get(),
|
|
253
273
|
environment,
|
|
254
274
|
event,
|
|
255
275
|
});
|
|
256
276
|
},
|
|
257
|
-
getMeta: (type) => createMeta(type,
|
|
277
|
+
getMeta: (type) => createMeta(type, configManager.get(), environment, clientIdManager),
|
|
258
278
|
on: (type, callback) => add({ type, callback }),
|
|
259
279
|
off: (type, callback) => remove(type, callback),
|
|
280
|
+
updateConfig: (config) => configManager.update(config),
|
|
260
281
|
version,
|
|
261
282
|
};
|
|
262
283
|
}
|
package/lib/relay.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import crypto from 'crypto';
|
|
2
2
|
|
|
3
|
-
async function callEventApi({ event,
|
|
4
|
-
const { token, host, organizationId } =
|
|
3
|
+
async function callEventApi({ event, config, environment, }) {
|
|
4
|
+
const { token, host, organizationId } = config;
|
|
5
5
|
const headers = {
|
|
6
6
|
"Content-Type": "application/json",
|
|
7
7
|
Authorization: `Bearer ${token}`,
|
|
8
8
|
};
|
|
9
|
-
const response = await environment.fetch(`${host}/rest/organizations/${organizationId}/events/v1${
|
|
9
|
+
const response = await environment.fetch(`${host}/rest/organizations/${organizationId}/events/v1${config.mode == "validate" ? "/validate" : ""}`, {
|
|
10
10
|
method: "POST",
|
|
11
11
|
body: JSON.stringify([event]),
|
|
12
12
|
headers,
|
|
@@ -132,22 +132,22 @@ function isBrowser() {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const version = "0.3.
|
|
135
|
+
const version = "0.3.2" ;
|
|
136
136
|
|
|
137
|
-
function
|
|
138
|
-
const { trackingId } =
|
|
137
|
+
function getEventConfig(config) {
|
|
138
|
+
const { trackingId } = config;
|
|
139
139
|
return { trackingId };
|
|
140
140
|
}
|
|
141
141
|
function getSource() {
|
|
142
142
|
return `relay@${version}`;
|
|
143
143
|
}
|
|
144
|
-
function createMeta(type,
|
|
144
|
+
function createMeta(type, config, environment, clientIdManager) {
|
|
145
145
|
const { getReferrerUrl, getUrl, getUserAgent } = environment;
|
|
146
|
-
const
|
|
146
|
+
const eventConfig = getEventConfig(config);
|
|
147
147
|
const { clientId } = clientIdManager;
|
|
148
148
|
return Object.freeze({
|
|
149
149
|
type,
|
|
150
|
-
config,
|
|
150
|
+
config: eventConfig,
|
|
151
151
|
ts: Date.now(),
|
|
152
152
|
source: getSource(),
|
|
153
153
|
clientId,
|
|
@@ -157,10 +157,10 @@ function createMeta(type, options, environment, clientIdManager) {
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
function createRelayEvent(type, payload,
|
|
160
|
+
function createRelayEvent(type, payload, config, environment, clientIdManager) {
|
|
161
161
|
return {
|
|
162
162
|
...payload,
|
|
163
|
-
meta: createMeta(type,
|
|
163
|
+
meta: createMeta(type, config, environment, clientIdManager),
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -225,32 +225,53 @@ function createListenerManager() {
|
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
function
|
|
228
|
+
function pick({ host, organizationId, token, trackingId, ...rest }) {
|
|
229
|
+
return Object.freeze({
|
|
230
|
+
host,
|
|
231
|
+
organizationId,
|
|
232
|
+
token,
|
|
233
|
+
trackingId,
|
|
234
|
+
...(!!rest.mode && { mode: rest.mode }),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function createConfigManager(initialConfig) {
|
|
238
|
+
let _config = pick(initialConfig);
|
|
239
|
+
return {
|
|
240
|
+
get: () => _config,
|
|
241
|
+
update: (updatedConfig) => {
|
|
242
|
+
_config = pick({ ..._config, ...updatedConfig });
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function createRelay(initialConfig) {
|
|
229
248
|
const environment = currentEnvironment();
|
|
230
249
|
const clientIdManager = createClientIdManager(environment);
|
|
250
|
+
const configManager = createConfigManager(initialConfig);
|
|
231
251
|
const { add, call, remove } = createListenerManager();
|
|
232
252
|
return {
|
|
233
253
|
validate: (type, payload) => {
|
|
234
|
-
const event = createRelayEvent(type, payload,
|
|
254
|
+
const event = createRelayEvent(type, payload, configManager.get(), environment, clientIdManager);
|
|
235
255
|
call(event);
|
|
236
256
|
return validate({
|
|
237
|
-
|
|
257
|
+
config: configManager.get(),
|
|
238
258
|
environment,
|
|
239
|
-
event
|
|
259
|
+
event,
|
|
240
260
|
});
|
|
241
261
|
},
|
|
242
262
|
emit: (type, payload) => {
|
|
243
|
-
const event = createRelayEvent(type, payload,
|
|
263
|
+
const event = createRelayEvent(type, payload, configManager.get(), environment, clientIdManager);
|
|
244
264
|
call(event);
|
|
245
265
|
return emit({
|
|
246
|
-
|
|
266
|
+
config: configManager.get(),
|
|
247
267
|
environment,
|
|
248
268
|
event,
|
|
249
269
|
});
|
|
250
270
|
},
|
|
251
|
-
getMeta: (type) => createMeta(type,
|
|
271
|
+
getMeta: (type) => createMeta(type, configManager.get(), environment, clientIdManager),
|
|
252
272
|
on: (type, callback) => add({ type, callback }),
|
|
253
273
|
off: (type, callback) => remove(type, callback),
|
|
274
|
+
updateConfig: (config) => configManager.update(config),
|
|
254
275
|
version,
|
|
255
276
|
};
|
|
256
277
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type RelayMode = "emit" | "validate";
|
|
2
|
+
export interface RelayConfig {
|
|
3
|
+
host: string;
|
|
4
|
+
organizationId: string;
|
|
5
|
+
token: string;
|
|
6
|
+
trackingId: string;
|
|
7
|
+
mode?: RelayMode;
|
|
8
|
+
}
|
|
9
|
+
export interface ConfigManager {
|
|
10
|
+
get: () => Readonly<RelayConfig>;
|
|
11
|
+
update: (updatedConfig: Partial<RelayConfig>) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function createConfigManager(initialConfig: RelayConfig): Readonly<ConfigManager>;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,MAAM,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACvD;AAkBD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,WAAW,GACzB,QAAQ,CAAC,aAAa,CAAC,CASzB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ClientIdManager } from "../../client-id/client-id";
|
|
2
2
|
import { Environment } from "../../environment/environment";
|
|
3
|
-
import {
|
|
4
|
-
interface
|
|
3
|
+
import { RelayConfig } from "../../config/config";
|
|
4
|
+
interface EventConfig {
|
|
5
5
|
trackingId: string;
|
|
6
6
|
}
|
|
7
7
|
export interface Meta {
|
|
8
8
|
type: string;
|
|
9
|
-
config:
|
|
9
|
+
config: EventConfig;
|
|
10
10
|
ts: number;
|
|
11
11
|
source: string;
|
|
12
12
|
clientId: string;
|
|
@@ -14,6 +14,6 @@ export interface Meta {
|
|
|
14
14
|
referrerUrl: string | null;
|
|
15
15
|
url: string | null;
|
|
16
16
|
}
|
|
17
|
-
export declare function createMeta(type: string,
|
|
17
|
+
export declare function createMeta(type: string, config: RelayConfig, environment: Environment, clientIdManager: ClientIdManager): Readonly<Meta>;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/event/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/event/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAWD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,GAC/B,QAAQ,CAAC,IAAI,CAAC,CAehB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ClientIdManager } from "../client-id/client-id";
|
|
2
2
|
import { Environment } from "../environment/environment";
|
|
3
|
-
import {
|
|
3
|
+
import { RelayConfig, RelayPayload } from "../relay";
|
|
4
4
|
import { Meta } from "./meta/meta";
|
|
5
5
|
export interface RelayEvent extends RelayPayload {
|
|
6
6
|
meta: Readonly<Meta>;
|
|
7
7
|
}
|
|
8
|
-
export declare function createRelayEvent(type: string, payload: RelayPayload,
|
|
8
|
+
export declare function createRelayEvent(type: string, payload: RelayPayload, config: RelayConfig, environment: Environment, clientIdManager: ClientIdManager): Readonly<RelayEvent>;
|
|
9
9
|
//# sourceMappingURL=relay-event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-event.d.ts","sourceRoot":"","sources":["../../../src/event/relay-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"relay-event.d.ts","sourceRoot":"","sources":["../../../src/event/relay-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAc,IAAI,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,GAC/B,QAAQ,CAAC,UAAU,CAAC,CAKtB"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Environment } from "../environment/environment";
|
|
2
|
-
import { RelayOptions } from "../relay";
|
|
3
2
|
import { RelayEvent } from "../event/relay-event";
|
|
3
|
+
import { RelayConfig } from "../config/config";
|
|
4
4
|
export interface EventApiCallParams {
|
|
5
|
-
|
|
5
|
+
config: RelayConfig;
|
|
6
6
|
environment: Environment;
|
|
7
7
|
event: Readonly<RelayEvent>;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
export declare function callEventApi({ event, options, environment, }: EventApiCallParams): Promise<any>;
|
|
9
|
+
export declare function callEventApi({ event, config, environment, }: EventApiCallParams): Promise<any>;
|
|
11
10
|
//# sourceMappingURL=event-api-caller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-api-caller.d.ts","sourceRoot":"","sources":["../../../src/event-api-call/event-api-caller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"event-api-caller.d.ts","sourceRoot":"","sources":["../../../src/event-api-call/event-api-caller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAC7B;AAED,wBAAsB,YAAY,CAAC,EACjC,KAAK,EACL,MAAM,EACN,WAAW,GACZ,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,CA2BnC"}
|
package/lib/types/relay.d.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { ValidationError, ValidationResponse } from "./validate/validate";
|
|
2
|
-
import { RelayMode } from "./event-api-call/event-api-caller";
|
|
3
2
|
import { Meta } from "./event/meta/meta";
|
|
4
3
|
import { EventCallback } from "./listener/listener";
|
|
4
|
+
import { RelayConfig } from "./config/config";
|
|
5
5
|
type RelayPayload = Record<string, unknown>;
|
|
6
6
|
type Off = () => void;
|
|
7
|
-
interface RelayOptions {
|
|
8
|
-
host: string;
|
|
9
|
-
organizationId: string;
|
|
10
|
-
token: string;
|
|
11
|
-
trackingId: string;
|
|
12
|
-
mode?: RelayMode;
|
|
13
|
-
}
|
|
14
7
|
interface Relay {
|
|
15
8
|
validate: (type: string, payload: RelayPayload) => Promise<ValidationResponse>;
|
|
16
9
|
emit: (type: string, payload: RelayPayload) => Promise<void>;
|
|
17
10
|
getMeta: (type: string) => Meta;
|
|
18
11
|
on: (type: string, callback: EventCallback) => Off;
|
|
19
12
|
off: (type: string, callback?: EventCallback) => void;
|
|
13
|
+
updateConfig: (config: Partial<RelayConfig>) => void;
|
|
20
14
|
version: string;
|
|
21
15
|
}
|
|
22
|
-
export declare function createRelay(
|
|
23
|
-
export type { RelayPayload,
|
|
16
|
+
export declare function createRelay(initialConfig: RelayConfig): Relay;
|
|
17
|
+
export type { RelayPayload, RelayConfig, ValidationError, ValidationResponse };
|
|
24
18
|
//# sourceMappingURL=relay.d.ts.map
|
package/lib/types/relay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,eAAe,EACf,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,eAAe,EACf,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAc,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAyB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAuB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnE,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,KAAK,GAAG,GAAG,MAAM,IAAI,CAAC;AAEtB,UAAU,KAAK;IACb,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,KAClB,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,KAAK,GAAG,CAAC;IACnD,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACtD,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACrD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,aAAa,EAAE,WAAW,GAAG,KAAK,CAiD7D;AAED,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/validate/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/validate/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EACnB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAMvC"}
|