Skip to content

Commit 0502595

Browse files
committed
wip
1 parent e02cff5 commit 0502595

File tree

2 files changed

+205
-1
lines changed

2 files changed

+205
-1
lines changed

packages/signals/signals-runtime/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/* eslint-disable */
2+
// These types will be used in the segment app UI for autocomplete
3+
// Generated from: @segment/[email protected]
4+
foo
5+
6+
declare interface BaseSignal {
7+
type: string;
8+
}
9+
10+
declare const EventType: Readonly<{
11+
Track: "track";
12+
Page: "page";
13+
Screen: "screen";
14+
Identify: "identify";
15+
Group: "group";
16+
Alias: "alias";
17+
}>;
18+
19+
declare interface InstrumentationData {
20+
type: 'instrumentation';
21+
rawEvent: any;
22+
}
23+
24+
declare interface InstrumentationSignal extends RawSignal<'instrumentation'> {
25+
data: InstrumentationData;
26+
}
27+
28+
declare interface InteractionData {
29+
component: string;
30+
info: string;
31+
data: any;
32+
}
33+
asfas
34+
declare interface InteractionSignal extends RawSignal<'interaction'> {
35+
type: 'interaction';
36+
data: InteractionData;
37+
}
38+
39+
/**
40+
* Interface for the Signals class (accessible via `signals` in the processSignal scope).
41+
*/
42+
declare interface ISignalsRuntime<Signal extends BaseSignal> {
43+
/**
44+
* Finds a signal of a specific type from a given signal.
45+
*
46+
* SignalType - The type of the signal to find.
47+
* @param fromSignal - The signal to search from.
48+
* @param signalType - The type of the signal to find.
49+
* @param predicate - Optional predicate function to filter the signals.
50+
* @returns The found signal of the specified type, or undefined if not found.
51+
*/
52+
find: <SignalType extends Signal['type']>(fromSignal: Signal, signalType: SignalType, predicate?: (signal: SignalOfType<Signal, SignalType>) => boolean) => SignalOfType<Signal, SignalType> | undefined;
53+
/**
54+
* Filters signals of a specific type from a given signal.
55+
* SignalType - The type of the signals to filter.
56+
* @param fromSignal - The signal to search from.
57+
* @param signalType - The type of the signals to filter.
58+
* @param predicate - Optional predicate function to filter the signals.
59+
* @returns An array of signals of the specified type.
60+
*/
61+
filter: <SignalType extends Signal['type']>(fromSignal: Signal, signalType: SignalType, predicate?: (signal: SignalOfType<Signal, SignalType>) => boolean) => SignalOfType<Signal, SignalType>[];
62+
}
63+
64+
declare type JSONArray = JSONValue[];
65+
66+
declare type JSONObject = {
67+
[member: string]: JSONValue;
68+
};
69+
70+
declare type JSONPrimitive = string | number | boolean | null;
71+
72+
declare type JSONValue = JSONPrimitive | JSONObject | JSONArray;
73+
74+
declare interface LocalData {
75+
action: LocalDataActionName;
76+
identifier: string;
77+
data: string;
78+
}
79+
80+
declare const LocalDataAction: Readonly<{
81+
Loaded: "loaded";
82+
Updated: "updated";
83+
Saved: "saved";
84+
Deleted: "deleted";
85+
Undefined: "undefined";
86+
}>;
87+
88+
declare type LocalDataActionName = 'loaded' | 'updated' | 'saved' | 'deleted' | 'undefined';
89+
90+
declare interface LocalDataSignal extends RawSignal<'localData'> {
91+
data: LocalData;
92+
}
93+
94+
declare class MobileSignalsRuntime extends SignalsRuntime<Signal> {
95+
private signalCounter;
96+
private maxBufferSize;
97+
constructor(signals?: Signal[]);
98+
add: (signal: Signal) => void;
99+
getNextIndex: () => number;
100+
}
101+
102+
declare const NavigationAction: Readonly<{
103+
Forward: "forward";
104+
Backward: "backward";
105+
Modal: "modal";
106+
Entering: "entering";
107+
Leaving: "leaving";
108+
Page: "page";
109+
Popup: "popup";
110+
}>;
111+
112+
declare type NavigationActionName = 'forward' | 'backward' | 'modal' | 'entering' | 'leaving' | 'page' | 'popup';
113+
114+
declare interface NavigationData {
115+
action: NavigationActionName;
116+
screen: string;
117+
}
118+
119+
declare interface NavigationSignal extends RawSignal<'navigation'> {
120+
data: NavigationData;
121+
}
122+
123+
declare const NetworkAction: Readonly<{
124+
Request: "request";
125+
Response: "response";
126+
}>;
127+
128+
declare type NetworkActionName = 'request' | 'response';
129+
130+
declare interface NetworkData {
131+
action: NetworkActionName;
132+
url: string;
133+
data: any;
134+
}
135+
136+
declare interface NetworkSignal extends RawSignal<'network'> {
137+
data: NetworkData;
138+
}
139+
140+
declare interface RawSignal<SignalType extends string> extends BaseSignal {
141+
type: SignalType;
142+
anonymousId: string;
143+
data: any;
144+
timestamp: string;
145+
index: any;
146+
}
147+
148+
declare interface SegmentEvent {
149+
/**
150+
* @example 'track' | 'page' | 'screen' | 'identify' | 'group' | 'alias'
151+
*/
152+
type: string;
153+
[key: string]: unknown;
154+
}
155+
156+
declare type Signal = InteractionSignal | NavigationSignal | NetworkSignal | LocalDataSignal | InstrumentationSignal | UserDefinedSignal;
157+
158+
declare type SignalOfType<AllSignals extends BaseSignal, SignalType extends AllSignals['type']> = AllSignals & {
159+
type: SignalType;
160+
};
161+
162+
declare const signals: MobileSignalsRuntime;
163+
164+
/**
165+
* Base class that provides runtime utilities for signals.
166+
*/
167+
declare abstract class SignalsRuntime<Signal extends BaseSignal = BaseSignal> implements ISignalsRuntime<Signal> {
168+
signalBuffer: Signal[];
169+
constructor(signals?: Signal[]);
170+
/**
171+
* Finds a signal of a specific type from a given signal.
172+
*
173+
* SignalType - The type of the signal to find.
174+
* @param fromSignal - The signal to search from.
175+
* @param signalType - The type of the signal to find.
176+
* @param predicate - Optional predicate function to filter the signals.
177+
* @returns The found signal of the specified type, or undefined if not found.
178+
*/
179+
find: <SignalType extends Signal["type"]>(fromSignal: Signal, signalType: SignalType, predicate?: ((signal: SignalOfType<Signal, SignalType>) => boolean) | undefined) => SignalOfType<Signal, SignalType> | undefined;
180+
/**
181+
* Filters signals of a specific type from a given signal.
182+
* SignalType - The type of the signals to filter.
183+
* @param fromSignal - The signal to search from.
184+
* @param signalType - The type of the signals to filter.
185+
* @param predicate - Optional predicate function to filter the signals.
186+
* @returns An array of signals of the specified type.
187+
*/
188+
filter: <SignalType extends Signal["type"]>(fromSignal: Signal, signalType: SignalType, predicate?: ((signal: SignalOfType<Signal, SignalType>) => boolean) | undefined) => SignalOfType<Signal, SignalType>[];
189+
}
190+
191+
declare const SignalType: Readonly<{
192+
Interaction: "interaction";
193+
Navigation: "navigation";
194+
Network: "network";
195+
LocalData: "localData";
196+
Instrumentation: "instrumentation";
197+
UserDefined: "userDefined";
198+
}>;
199+
200+
declare type SignalTypes = Signal['type'];
201+
202+
declare interface UserDefinedSignal extends RawSignal<'userDefined'> {
203+
data: any;
204+
}
205+

0 commit comments

Comments
 (0)