@eventvisor/types 0.0.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/.eslintcache ADDED
@@ -0,0 +1 @@
1
+ [{"/Users/fahad/Repos/featurevisor/packages/types/src/index.ts":"1"},{"size":10214,"mtime":1706909683928,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"i57tk5","/Users/fahad/Repos/featurevisor/packages/types/src/index.ts",[],[]]
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Fahad Heylaal (https://fahad19.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @eventvisor/types
2
+
3
+ > Common TypeScript typings for Eventvisor packages
4
+
5
+ Visit [https://eventvisor.org](https://eventvisor.org) for more information.
6
+
7
+ ## License
8
+
9
+ MIT © [Fahad Heylaal](https://fahad19.com)
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@eventvisor/types",
3
+ "version": "0.0.2",
4
+ "description": "Common Typescript types for Eventvisor",
5
+ "main": "src/index.js",
6
+ "module": "src/index.js",
7
+ "types": "src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "import": "./src/index.js",
12
+ "require": "./src/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "transpile": "echo 'Nothing to transpile'",
17
+ "dist": "echo 'Nothing to dist'",
18
+ "build": "tsc ./src/index.d.ts",
19
+ "test": "echo 'Nothing to test in types package'"
20
+ },
21
+ "author": {
22
+ "name": "Fahad Heylaal",
23
+ "url": "https://fahad19.com"
24
+ },
25
+ "homepage": "https://eventvisor.org",
26
+ "keywords": [],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/eventvisor/eventvisor.git"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "registry": "https://registry.npmjs.org/"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/eventvisor/eventvisor/issues"
37
+ },
38
+ "license": "MIT",
39
+ "gitHead": "373d5c00cb6fa0d6f4baaa05a10e57e505474847"
40
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,435 @@
1
+ /**
2
+ * JSON Schema (subset)
3
+ */
4
+ export type PrimitiveValue = string | number | boolean | null | undefined;
5
+ export type ObjectValue = { [key: string]: Value };
6
+ export type Value = PrimitiveValue | ObjectValue | Value[];
7
+
8
+ export interface JSONSchema {
9
+ // Basic metadata
10
+ description?: string;
11
+
12
+ // General validation keywords
13
+ type?: "object" | "array" | "string" | "number" | "integer" | "boolean" | "null";
14
+ enum?: Value[];
15
+ const?: Value;
16
+
17
+ // Numeric validation keywords
18
+ maximum?: number;
19
+ minimum?: number;
20
+
21
+ // String validation keywords
22
+ maxLength?: number;
23
+ minLength?: number;
24
+ pattern?: string;
25
+
26
+ // Array validation keywords
27
+ items?: JSONSchema | JSONSchema[];
28
+ maxItems?: number;
29
+ minItems?: number;
30
+ uniqueItems?: boolean;
31
+
32
+ // Object validation keywords
33
+ required?: string[];
34
+ properties?: { [key: string]: JSONSchema };
35
+
36
+ // Annotations
37
+ default?: Value;
38
+ examples?: Value[];
39
+ }
40
+
41
+ /**
42
+ * Common aliases
43
+ */
44
+ export type Percentage = number; // 0 to 100 (up to 3 decimal places)
45
+
46
+ export type Tag = string;
47
+
48
+ export type Inputs = Record<string, Value>;
49
+
50
+ /**
51
+ * Persist
52
+ */
53
+ export type StorageName = string;
54
+
55
+ export type SimplePersist = StorageName;
56
+
57
+ export interface ComplexPersist {
58
+ storage: StorageName;
59
+ conditions?: Condition | Condition[];
60
+ }
61
+
62
+ export type Persist = SimplePersist | ComplexPersist | Persist[];
63
+
64
+ /**
65
+ * Source
66
+ */
67
+ export type Source = string;
68
+
69
+ export type SourceBase =
70
+ // longer dotted path
71
+ | { source: Source | Source[] }
72
+
73
+ // more specific sources
74
+ | { attribute: Source | Source[] } // can be dot-separated path
75
+ | { state: Source | Source[] } // internally in Effect's own transforms
76
+ | { effect: Source | Source[] }
77
+ | { payload: Source | Source[] } // @TODO: or more specific eventValue and attributeValue?
78
+ | { lookup: Source | Source[] };
79
+
80
+ /**
81
+ * Conditions
82
+ */
83
+ export type ConditionOperator =
84
+ | "equals"
85
+ | "notEquals"
86
+ | "exists"
87
+ | "notExists"
88
+
89
+ // numeric
90
+ | "greaterThan"
91
+ | "greaterThanOrEquals"
92
+ | "lessThan"
93
+ | "lessThanOrEquals"
94
+
95
+ // string
96
+ | "contains"
97
+ | "notContains"
98
+ | "startsWith"
99
+ | "endsWith"
100
+
101
+ // semver (string)
102
+ | "semverEquals"
103
+ | "semverNotEquals"
104
+ | "semverGreaterThan"
105
+ | "semverGreaterThanOrEquals"
106
+ | "semverLessThan"
107
+ | "semverLessThanOrEquals"
108
+
109
+ // date comparisons
110
+ | "before"
111
+ | "after"
112
+
113
+ // array of strings
114
+ | "includes"
115
+ | "notIncludes"
116
+
117
+ // regex
118
+ | "matches"
119
+ | "notMatches"
120
+
121
+ // array of strings
122
+ | "in"
123
+ | "notIn";
124
+
125
+ export type PlainCondition = SourceBase & {
126
+ operator: ConditionOperator;
127
+ value?: Value;
128
+ regexFlags?: string;
129
+ };
130
+
131
+ export interface AndCondition {
132
+ and: Condition[];
133
+ }
134
+
135
+ export interface OrCondition {
136
+ or: Condition[];
137
+ }
138
+
139
+ export interface NotCondition {
140
+ not: Condition[];
141
+ }
142
+
143
+ export type Condition = PlainCondition | AndCondition | OrCondition | NotCondition | string;
144
+
145
+ /**
146
+ * Sample
147
+ */
148
+ export type SampleBySingle = Source | SourceBase;
149
+ export type SampleByMultiple = SampleBySingle[];
150
+ export interface SampleByOr {
151
+ or: SampleByMultiple;
152
+ }
153
+ export type SampleBy = SampleBySingle | SampleByMultiple | SampleByOr;
154
+
155
+ export type SampleRange = [Percentage, Percentage];
156
+
157
+ export interface Sample {
158
+ by: SampleBy;
159
+ conditions?: Condition | Condition[];
160
+
161
+ // either of them is required
162
+ percentage?: Percentage;
163
+ range?: SampleRange;
164
+ }
165
+
166
+ /**
167
+ * Transforms
168
+ */
169
+ export type TransformType =
170
+ // mathematical
171
+ | "increment"
172
+ | "decrement"
173
+
174
+ // manipulations
175
+ | "concat" // @TODO: rename to `join`?
176
+ | "remove"
177
+ | "rename"
178
+ | "set"
179
+ | "trim"
180
+
181
+ // to
182
+ | "toInteger"
183
+ | "toDouble"
184
+ | "toString"
185
+ | "toBoolean"
186
+
187
+ // @TODO: consider later
188
+ // | "uppercase"
189
+ // | "lowercase"
190
+
191
+ // complex
192
+ | "spread"
193
+ | "append";
194
+
195
+ export type Transform = Partial<SourceBase> & {
196
+ type: TransformType;
197
+ target?: string;
198
+ targetMap?: Record<string, string> | Record<string, string>[];
199
+
200
+ value?: Value;
201
+
202
+ // additional params for certain transform types
203
+ separator?: string;
204
+ [key: string]: any;
205
+ };
206
+
207
+ /**
208
+ * Attribute
209
+ */
210
+ export type Attribute = JSONSchema & {
211
+ archived?: boolean;
212
+ deprecated?: boolean;
213
+ description?: string;
214
+ tags?: Tag[];
215
+
216
+ transforms?: Transform[];
217
+ persist?: Persist;
218
+ };
219
+
220
+ export type AttributeName = string;
221
+
222
+ /**
223
+ * Event
224
+ */
225
+ export type PlainDestinationOverride = boolean;
226
+
227
+ export interface ComplexDestinationOverride {
228
+ conditions?: Condition | Condition[];
229
+ sample?: Sample | Sample[];
230
+ transforms?: Transform[];
231
+ }
232
+
233
+ export type DestinationOverride = PlainDestinationOverride | ComplexDestinationOverride;
234
+
235
+ export type EventLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
236
+
237
+ export type Event = JSONSchema & {
238
+ archived?: boolean;
239
+ deprecated?: boolean;
240
+ description?: string;
241
+ tags?: Tag[];
242
+
243
+ // @TODO: meta
244
+
245
+ level?: EventLevel;
246
+ requiredAttributes?: string[];
247
+ conditions?: Condition | Condition[];
248
+ sample?: Sample | Sample[];
249
+ transforms?: Transform[];
250
+ destinations?: {
251
+ [key: string]: DestinationOverride;
252
+ };
253
+ };
254
+
255
+ export type EventName = string;
256
+
257
+ /**
258
+ * Destination
259
+ */
260
+ export interface Destination {
261
+ archived?: boolean;
262
+ description?: string;
263
+ tags?: Tag[];
264
+
265
+ transport: string;
266
+ conditions?: Condition | Condition[];
267
+ sample?: Sample | Sample[];
268
+ transforms?: Transform[];
269
+ }
270
+
271
+ export type DestinationName = string;
272
+
273
+ /**
274
+ * Effect
275
+ */
276
+ export type EffectOnType = "event_tracked" | "attribute_set";
277
+ interface EffectOnRecord {
278
+ event_tracked?: EventName[];
279
+ attribute_set?: AttributeName[];
280
+ }
281
+ export type EffectOn = EffectOnType[] | EffectOnRecord;
282
+
283
+ export interface Step {
284
+ description?: string;
285
+ handler?: string;
286
+ conditions?: Condition | Condition[];
287
+ params?: Record<string, any>;
288
+ transforms?: Transform[];
289
+ continueOnError?: boolean;
290
+ }
291
+
292
+ export interface Effect {
293
+ archived?: boolean;
294
+ description?: string;
295
+ tags?: Tag[];
296
+
297
+ on?: EffectOn;
298
+ state?: Value;
299
+ conditions?: Condition | Condition[];
300
+ steps?: Step[];
301
+ persist?: Persist;
302
+ }
303
+
304
+ export type EffectName = string;
305
+
306
+ /**
307
+ * Datafile
308
+ */
309
+ export interface DatafileContent {
310
+ schemaVersion: string;
311
+ revision: string;
312
+ attributes: {
313
+ [key: AttributeName]: Attribute;
314
+ };
315
+ events: {
316
+ [key: EventName]: Event;
317
+ };
318
+ destinations: {
319
+ [key: DestinationName]: Destination;
320
+ };
321
+ effects: {
322
+ [key: EffectName]: Effect;
323
+ };
324
+ }
325
+
326
+ /**
327
+ * Others
328
+ */
329
+ export type EntityType = "attribute" | "event" | "destination" | "state" | "effect" | "test";
330
+
331
+ /**
332
+ * Test
333
+ */
334
+ export interface Action {
335
+ type: "track" | "setAttribute" | "removeAttribute";
336
+ name: EventName | AttributeName;
337
+ value?: Value;
338
+ }
339
+
340
+ export type WithLookups = Record<string, Value>; // key is "<moduleName>.<additionalKey>"
341
+
342
+ // Attribute
343
+ export interface AttributeAssertion {
344
+ description?: string;
345
+ setAttribute?: Value;
346
+ withLookups?: {
347
+ [key: string]: Value;
348
+ };
349
+
350
+ expectedToBeValid?: boolean;
351
+ expectedToBeSet?: boolean;
352
+ expectedAttribute?: Value;
353
+ }
354
+
355
+ export interface AttributeTest {
356
+ attribute: AttributeName;
357
+ assertions: AttributeAssertion[];
358
+ }
359
+
360
+ // Event
361
+ export interface EventAssertion {
362
+ description?: string;
363
+ withAttributes?: {
364
+ [key: AttributeName]: Value;
365
+ };
366
+ withLookups?: WithLookups;
367
+ at?: Percentage; // @TODO: implement
368
+ track?: Value;
369
+ actions?: Action[];
370
+
371
+ expectedToBeValid?: boolean;
372
+ expectedToContinue?: boolean;
373
+ expectedEvent?: Value;
374
+ expectedDestinations?: DestinationName[];
375
+ expectedDestinationsByTag?: Record<Tag, DestinationName[]>;
376
+ }
377
+
378
+ export interface EventTest {
379
+ event: EventName;
380
+ assertions: EventAssertion[];
381
+ }
382
+
383
+ // Effect
384
+ export interface EffectAssertion {
385
+ description?: string;
386
+ withAttributes?: {
387
+ [key: AttributeName]: Value;
388
+ };
389
+ withLookups?: WithLookups;
390
+
391
+ actions?: Action[];
392
+
393
+ expectedState?: Value;
394
+ expectedToBeHandled?: boolean;
395
+ expectedToBeCalled?: {
396
+ handler: string;
397
+ times?: number;
398
+ }[];
399
+ }
400
+
401
+ export interface EffectTest {
402
+ effect: EffectName;
403
+ assertions: EffectAssertion[];
404
+ }
405
+
406
+ // Destination
407
+ export interface DestinationAssertion {
408
+ description?: string;
409
+ withAttributes?: {
410
+ [key: AttributeName]: Value;
411
+ };
412
+ withLookups?: {
413
+ [key: string]: Value;
414
+ };
415
+ actions?: Action[];
416
+ assertAfter?: number; // in ms
417
+
418
+ expectedToBeTransported?: boolean;
419
+ expectedBody?: Value;
420
+
421
+ // @TODO: batch
422
+ expectedBodies?: Value[];
423
+ expectedToBeBatched?: boolean;
424
+ expectedBatchedCount?: number;
425
+ }
426
+
427
+ export interface DestinationTest {
428
+ destination: DestinationName;
429
+ assertions: DestinationAssertion[];
430
+ }
431
+
432
+ // Combined
433
+ export type Test = EventTest | AttributeTest | EffectTest | DestinationTest;
434
+
435
+ export type TestName = string;
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ // empty
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib"
5
+ },
6
+ "include": ["./src/**/*.ts", "./src/**/*.d.ts"]
7
+ }