@jitsu/protocols 0.0.1-alpha.122
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/.pnpm-debug.log +24 -0
- package/analytics.d.ts +196 -0
- package/async-request.d.ts +15 -0
- package/functions.d.ts +92 -0
- package/iso8601.d.ts +2 -0
- package/package.json +14 -0
package/.pnpm-debug.log
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"0 debug pnpm:scope": {
|
|
3
|
+
"selected": 1,
|
|
4
|
+
"workspacePrefix": "/Users/ildarnurislamov/Projects/onetag"
|
|
5
|
+
},
|
|
6
|
+
"1 info pnpm": {
|
|
7
|
+
"err": {
|
|
8
|
+
"name": "Error",
|
|
9
|
+
"message": "not found: build",
|
|
10
|
+
"code": "ENOENT",
|
|
11
|
+
"stack": "Error: not found: build\n at getNotFoundError (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:41714:51)\n at Function.whichSync [as sync] (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:41791:13)\n at getCommandAbsolutePathSync (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:43356:44)\n at default_1 (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:43365:32)\n at /opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:178485:39"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"2 error pnpm": {
|
|
15
|
+
"code": "ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL",
|
|
16
|
+
"prefix": "/Users/ildarnurislamov/Projects/onetag/types/jitsu",
|
|
17
|
+
"err": {
|
|
18
|
+
"name": "pnpm",
|
|
19
|
+
"message": "not found: build",
|
|
20
|
+
"code": "ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL",
|
|
21
|
+
"stack": "Error: not found: build\n at getNotFoundError (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:41714:51)\n at Function.whichSync [as sync] (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:41791:13)\n at getCommandAbsolutePathSync (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:43356:44)\n at default_1 (/opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:43365:32)\n at /opt/homebrew/lib/node_modules/pnpm/dist/pnpm.cjs:178485:39"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/analytics.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ISO8601Date } from "./iso8601.d";
|
|
2
|
+
|
|
3
|
+
export type ID = string | null | undefined;
|
|
4
|
+
|
|
5
|
+
export type DataLayoutType = "segment" | "jitsu-legacy" | "segment-single-table";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event coming from client library
|
|
9
|
+
*/
|
|
10
|
+
export interface AnalyticsClientEvent {
|
|
11
|
+
/**
|
|
12
|
+
* Unique message ID
|
|
13
|
+
*/
|
|
14
|
+
messageId: string;
|
|
15
|
+
timestamp?: Date | ISO8601Date;
|
|
16
|
+
type: "track" | "page" | "identify" | "group" | "alias" | "screen";
|
|
17
|
+
// page specific
|
|
18
|
+
category?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
|
|
21
|
+
properties?: {
|
|
22
|
+
[k: string]: JSONValue;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Traits can be either here, or in context.traits (depending on a library)
|
|
26
|
+
*/
|
|
27
|
+
traits?: JSONObject;
|
|
28
|
+
|
|
29
|
+
context: AnalyticsContext;
|
|
30
|
+
|
|
31
|
+
userId?: ID;
|
|
32
|
+
anonymousId?: ID;
|
|
33
|
+
groupId?: ID;
|
|
34
|
+
previousId?: ID;
|
|
35
|
+
|
|
36
|
+
event?: string;
|
|
37
|
+
writeKey?: string;
|
|
38
|
+
sentAt?: Date | ISO8601Date;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A context of an event that is added on server-side
|
|
43
|
+
*/
|
|
44
|
+
export type ServerContext = {
|
|
45
|
+
request_ip?: string;
|
|
46
|
+
receivedAt?: ISO8601Date;
|
|
47
|
+
sentAt?: ISO8601Date;
|
|
48
|
+
timestamp?: ISO8601Date;
|
|
49
|
+
userId?: ISO8601Date;
|
|
50
|
+
type?: ISO8601Date;
|
|
51
|
+
[k: string]: any;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
interface ProcessingContext {
|
|
55
|
+
$table?: string;
|
|
56
|
+
[k: `$${string}`]: any;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type AnalyticsServerEvent = AnalyticsClientEvent & ServerContext & ProcessingContext;
|
|
60
|
+
|
|
61
|
+
export type JSONPrimitive = string | number | boolean | null;
|
|
62
|
+
export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
|
63
|
+
export type JSONObject = { [member: string]: JSONValue };
|
|
64
|
+
export type JSONArray = Array<JSONValue>;
|
|
65
|
+
|
|
66
|
+
export type Integrations = {
|
|
67
|
+
All?: boolean;
|
|
68
|
+
[integration: string]: boolean | JSONObject | undefined;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type Options = {
|
|
72
|
+
integrations?: Integrations;
|
|
73
|
+
anonymousId?: ID;
|
|
74
|
+
timestamp?: Date | string;
|
|
75
|
+
context?: AnalyticsContext;
|
|
76
|
+
traits?: JSONObject;
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type CompactMetricType = "g" | "c";
|
|
83
|
+
|
|
84
|
+
export interface CompactMetric {
|
|
85
|
+
m: string; // metric name
|
|
86
|
+
v: number; // value
|
|
87
|
+
k: CompactMetricType;
|
|
88
|
+
t: string[]; // tags
|
|
89
|
+
e: number; // timestamp in unit milliseconds
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface AnalyticsContext {
|
|
93
|
+
/**
|
|
94
|
+
* Ip address of the originating request. Generally, shouldn't be set
|
|
95
|
+
* for client-side track calls.
|
|
96
|
+
*/
|
|
97
|
+
ip?: string;
|
|
98
|
+
|
|
99
|
+
page?: {
|
|
100
|
+
path?: string;
|
|
101
|
+
referrer?: string;
|
|
102
|
+
search?: string;
|
|
103
|
+
title?: string;
|
|
104
|
+
url?: string;
|
|
105
|
+
[key: string]: any;
|
|
106
|
+
};
|
|
107
|
+
metrics?: CompactMetric[];
|
|
108
|
+
|
|
109
|
+
userAgent?: string;
|
|
110
|
+
|
|
111
|
+
locale?: string;
|
|
112
|
+
|
|
113
|
+
library?: {
|
|
114
|
+
name: string;
|
|
115
|
+
version: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
traits?: { crossDomainId?: string } & JSONObject;
|
|
119
|
+
|
|
120
|
+
campaign?: {
|
|
121
|
+
name?: string;
|
|
122
|
+
term?: string;
|
|
123
|
+
source?: string;
|
|
124
|
+
medium?: string;
|
|
125
|
+
content?: string;
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
referrer?: {
|
|
130
|
+
btid?: string;
|
|
131
|
+
urid?: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
amp?: {
|
|
135
|
+
id: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
[key: string]: any;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type Context = any;
|
|
142
|
+
export type DispatchedEvent = Context;
|
|
143
|
+
|
|
144
|
+
export type Callback = (ctx: Context | undefined) => Promise<unknown> | unknown;
|
|
145
|
+
|
|
146
|
+
export interface AnalyticsInterface {
|
|
147
|
+
track(
|
|
148
|
+
eventName: string | JSONObject,
|
|
149
|
+
properties?: JSONObject | Callback,
|
|
150
|
+
options?: Options | Callback,
|
|
151
|
+
callback?: Callback
|
|
152
|
+
): Promise<DispatchedEvent>;
|
|
153
|
+
|
|
154
|
+
page(
|
|
155
|
+
category?: string | object,
|
|
156
|
+
name?: string | object | Callback,
|
|
157
|
+
properties?: object | Options | Callback | null,
|
|
158
|
+
options?: Options | Callback,
|
|
159
|
+
callback?: Callback
|
|
160
|
+
): Promise<DispatchedEvent>;
|
|
161
|
+
//Original Segment Identify, not supported yet, see a subset below
|
|
162
|
+
// identify(
|
|
163
|
+
// id?: ID | object,
|
|
164
|
+
// traits?: JSONObject | Callback | null,
|
|
165
|
+
// options?: Options | Callback,
|
|
166
|
+
// callback?: Callback,
|
|
167
|
+
// ): Promise<DispatchedEvent>;
|
|
168
|
+
|
|
169
|
+
identify(id?: ID | object, traits?: JSONObject | Callback | null, callback?: Callback): Promise<DispatchedEvent>;
|
|
170
|
+
|
|
171
|
+
reset(callback?: (...params: any[]) => any): Promise<any>;
|
|
172
|
+
|
|
173
|
+
user(): any;
|
|
174
|
+
|
|
175
|
+
//TODO: user,reset
|
|
176
|
+
|
|
177
|
+
// alias(
|
|
178
|
+
// to: string | number,
|
|
179
|
+
// from?: string | number | Options,
|
|
180
|
+
// options?: Options | Callback,
|
|
181
|
+
// callback?: Callback
|
|
182
|
+
// ): Promise<DispatchedEvent>;
|
|
183
|
+
// group(
|
|
184
|
+
// id?: ID | object,
|
|
185
|
+
// traits?: JSONObject | Callback | null,
|
|
186
|
+
// options?: Options | Callback,
|
|
187
|
+
// callback?: Callback
|
|
188
|
+
// ): Promise<DispatchedEvent>;
|
|
189
|
+
// screen(
|
|
190
|
+
// category?: string | object,
|
|
191
|
+
// name?: string | object | Callback,
|
|
192
|
+
// properties?: JSONObject | Options | Callback | null,
|
|
193
|
+
// options?: Options | Callback,
|
|
194
|
+
// callback?: Callback
|
|
195
|
+
// ): Promise<DispatchedEvent>;
|
|
196
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ISO8601Date } from "./iso8601";
|
|
2
|
+
|
|
3
|
+
export type IngestMessage = {
|
|
4
|
+
messageCreated: ISO8601Date;
|
|
5
|
+
messageId: string;
|
|
6
|
+
connectionId: string;
|
|
7
|
+
type: string;
|
|
8
|
+
origin: {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
slug?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
};
|
|
13
|
+
httpHeaders: Record<string, string>;
|
|
14
|
+
httpPayload: any;
|
|
15
|
+
};
|
package/functions.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type SetOpts = { ttlMs?: number } | { ttlSec?: number };
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A key value store that exposed to a function
|
|
5
|
+
*/
|
|
6
|
+
export type Store = {
|
|
7
|
+
get(key: string): Promise<any>;
|
|
8
|
+
del(key: string): Promise<void>;
|
|
9
|
+
set(key: string, value: any, opts?: SetOpts): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A special properties that user can set on an event to define how
|
|
14
|
+
* event will be processed further
|
|
15
|
+
*/
|
|
16
|
+
export type EventControlOpts = {
|
|
17
|
+
/**
|
|
18
|
+
* Table name to store event in. Non-SQL destinations might ignore this property
|
|
19
|
+
*/
|
|
20
|
+
JITSU_TABLE_NAME?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type AnyEvent = Record<string, any> & EventControlOpts;
|
|
24
|
+
export type AnyProps = Record<string, any>;
|
|
25
|
+
|
|
26
|
+
export type FetchResponse = {
|
|
27
|
+
status: number;
|
|
28
|
+
statusText: string;
|
|
29
|
+
text: () => Promise<string>;
|
|
30
|
+
json: () => Promise<any>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type FetchOpts = {
|
|
34
|
+
method?: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
body?: string;
|
|
37
|
+
};
|
|
38
|
+
export type GlobalContext = {
|
|
39
|
+
log: {
|
|
40
|
+
info: (message: string, ...args: any[]) => void;
|
|
41
|
+
debug: (message: string, ...args: any[]) => void;
|
|
42
|
+
error: (message: string, ...args: any[]) => void;
|
|
43
|
+
};
|
|
44
|
+
fetch: (url: string, opts?: FetchOpts) => Promise<FetchResponse>;
|
|
45
|
+
store: Store;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type EventContext = {
|
|
49
|
+
/**
|
|
50
|
+
* Headers of incoming request
|
|
51
|
+
*/
|
|
52
|
+
headers: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Source of the incoming event
|
|
55
|
+
*/
|
|
56
|
+
source?: {
|
|
57
|
+
id: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
domain?: string;
|
|
60
|
+
};
|
|
61
|
+
destination?: {
|
|
62
|
+
id: string;
|
|
63
|
+
type: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type FunctionConfigContext<P extends AnyProps = AnyProps> = {
|
|
68
|
+
props: P;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Parameters for a function
|
|
73
|
+
*/
|
|
74
|
+
export type FunctionContext<P extends AnyProps = AnyProps> = EventContext & GlobalContext & FunctionConfigContext<P>;
|
|
75
|
+
|
|
76
|
+
//equivalent to returning [] from a function
|
|
77
|
+
export type FunctionCommand = "interrupt";
|
|
78
|
+
|
|
79
|
+
export type FuncReturn = AnyEvent[] | AnyEvent | null | undefined | FunctionCommand;
|
|
80
|
+
|
|
81
|
+
export interface JitsuFunction<E extends AnyEvent = AnyEvent, P extends AnyProps = AnyProps> {
|
|
82
|
+
(event: E, ctx: FunctionContext<P>): Promise<FuncReturn> | FuncReturn;
|
|
83
|
+
|
|
84
|
+
displayName?: string;
|
|
85
|
+
//for future use - config schema of the function
|
|
86
|
+
configSchema?: any;
|
|
87
|
+
|
|
88
|
+
//It's allowed to use basic JSX
|
|
89
|
+
description?: any;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type BuiltinFunctionName = `builtin.${string}`;
|
package/iso8601.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jitsu/protocols",
|
|
3
|
+
"version": "0.0.1-alpha.122",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "Jitsu Dev Team <dev@jitsu.com>",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"private": false,
|
|
11
|
+
"devDependencies": {},
|
|
12
|
+
"dependencies": {},
|
|
13
|
+
"scripts": {}
|
|
14
|
+
}
|