@eventvisor/sdk 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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/attributesManager.d.ts +36 -0
- package/dist/bucketer.d.ts +30 -0
- package/dist/compareVersions.d.ts +4 -0
- package/dist/conditions.d.ts +20 -0
- package/dist/datafileReader.d.ts +29 -0
- package/dist/effectsManager.d.ts +33 -0
- package/dist/emitter.d.ts +11 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -0
- package/dist/instance.d.ts +67 -0
- package/dist/logger.d.ts +26 -0
- package/dist/modulesManager.d.ts +67 -0
- package/dist/murmurhash.d.ts +1 -0
- package/dist/persister.d.ts +40 -0
- package/dist/sourceResolver.d.ts +31 -0
- package/dist/transformer.d.ts +21 -0
- package/dist/validator.d.ts +28 -0
- package/jest.config.js +6 -0
- package/lib/attributesManager.d.ts +36 -0
- package/lib/bucketer.d.ts +30 -0
- package/lib/compareVersions.d.ts +4 -0
- package/lib/conditions.d.ts +20 -0
- package/lib/datafileReader.d.ts +29 -0
- package/lib/effectsManager.d.ts +33 -0
- package/lib/emitter.d.ts +11 -0
- package/lib/index.d.ts +12 -0
- package/lib/instance.d.ts +67 -0
- package/lib/logger.d.ts +26 -0
- package/lib/modulesManager.d.ts +67 -0
- package/lib/murmurhash.d.ts +1 -0
- package/lib/persister.d.ts +40 -0
- package/lib/sourceResolver.d.ts +31 -0
- package/lib/transformer.d.ts +21 -0
- package/lib/validator.d.ts +28 -0
- package/package.json +45 -0
- package/src/attributesManager.ts +181 -0
- package/src/bucketer.spec.ts +156 -0
- package/src/bucketer.ts +152 -0
- package/src/compareVersions.ts +93 -0
- package/src/conditions.ts +224 -0
- package/src/datafileReader.ts +133 -0
- package/src/effectsManager.ts +214 -0
- package/src/emitter.ts +64 -0
- package/src/index.spec.ts +5 -0
- package/src/index.ts +14 -0
- package/src/instance.spec.ts +184 -0
- package/src/instance.ts +608 -0
- package/src/logger.ts +90 -0
- package/src/modulesManager.ts +276 -0
- package/src/murmurhash.ts +71 -0
- package/src/persister.ts +162 -0
- package/src/sourceResolver.spec.ts +253 -0
- package/src/sourceResolver.ts +213 -0
- package/src/transformer.ts +316 -0
- package/src/transformer_static.spec.ts +377 -0
- package/src/transformer_types.spec.ts +820 -0
- package/src/validator.spec.ts +579 -0
- package/src/validator.ts +366 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.esm.json +8 -0
- package/webpack.config.js +80 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AttributeName, Value } from "@eventvisor/types";
|
|
2
|
+
import type { GetDatafileReader } from "./datafileReader";
|
|
3
|
+
import type { GetConditionsChecker } from "./conditions";
|
|
4
|
+
import type { ModulesManager } from "./modulesManager";
|
|
5
|
+
import type { Emitter } from "./emitter";
|
|
6
|
+
import type { Logger } from "./logger";
|
|
7
|
+
import type { GetTransformer } from "./transformer";
|
|
8
|
+
import type { Validator } from "./validator";
|
|
9
|
+
export type AttributesMap = Record<AttributeName, Value>;
|
|
10
|
+
export interface AttributesManagerOptions {
|
|
11
|
+
logger: Logger;
|
|
12
|
+
emitter: Emitter;
|
|
13
|
+
getDatafileReader: GetDatafileReader;
|
|
14
|
+
getTransformer: GetTransformer;
|
|
15
|
+
getConditionsChecker: GetConditionsChecker;
|
|
16
|
+
validator: Validator;
|
|
17
|
+
modulesManager: ModulesManager;
|
|
18
|
+
}
|
|
19
|
+
export declare class AttributesManager {
|
|
20
|
+
private logger;
|
|
21
|
+
private getDatafileReader;
|
|
22
|
+
private emitter;
|
|
23
|
+
private getTransformer;
|
|
24
|
+
private getConditionsChecker;
|
|
25
|
+
private validator;
|
|
26
|
+
private modulesManager;
|
|
27
|
+
private attributesMap;
|
|
28
|
+
constructor(options: AttributesManagerOptions);
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
private initializeFromStorage;
|
|
31
|
+
setAttribute(attributeName: AttributeName, value: Value): Promise<Value | null>;
|
|
32
|
+
isAttributeSet(attributeName: AttributeName): boolean;
|
|
33
|
+
getAttributesMap(): AttributesMap;
|
|
34
|
+
getAttributeValue(attributeName: AttributeName): Value | null;
|
|
35
|
+
removeAttribute(attributeName: AttributeName): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Sample, SampleBy, Inputs } from "@eventvisor/types";
|
|
2
|
+
import type { Logger } from "./logger";
|
|
3
|
+
import type { SourceResolver } from "./sourceResolver";
|
|
4
|
+
import type { ConditionsChecker } from "./conditions";
|
|
5
|
+
import type { Transformer } from "./transformer";
|
|
6
|
+
export type BucketKey = string;
|
|
7
|
+
export type BucketValue = number;
|
|
8
|
+
export declare const MAX_BUCKETED_NUMBER = 100000;
|
|
9
|
+
export declare function getBucketedNumber(bucketKey: string): BucketValue;
|
|
10
|
+
export declare class BucketerOptions {
|
|
11
|
+
logger: Logger;
|
|
12
|
+
sourceResolver: SourceResolver;
|
|
13
|
+
conditionsChecker: ConditionsChecker;
|
|
14
|
+
transformer: Transformer;
|
|
15
|
+
}
|
|
16
|
+
export interface SampleResult {
|
|
17
|
+
isSampled: boolean;
|
|
18
|
+
matchedSample?: Sample;
|
|
19
|
+
bucketedNumber?: number;
|
|
20
|
+
bucketKey?: BucketKey;
|
|
21
|
+
}
|
|
22
|
+
export declare class Bucketer {
|
|
23
|
+
private logger;
|
|
24
|
+
private sourceResolver;
|
|
25
|
+
private conditionsChecker;
|
|
26
|
+
private transformer;
|
|
27
|
+
constructor(options: BucketerOptions);
|
|
28
|
+
getBucketKey(sampleBy: SampleBy, inputs: Inputs): Promise<BucketKey>;
|
|
29
|
+
isSampled(sample: Sample | Sample[], inputs: Inputs): Promise<SampleResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const semver: RegExp;
|
|
2
|
+
export declare const validateAndParse: (version: string) => RegExpMatchArray;
|
|
3
|
+
export declare const compareSegments: (a: string | string[] | RegExpMatchArray, b: string | string[] | RegExpMatchArray) => 0 | 1 | -1;
|
|
4
|
+
export declare const compareVersions: (v1: string, v2: string) => 0 | 1 | -1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PlainCondition, Condition, Inputs } from "@eventvisor/types";
|
|
2
|
+
import type { GetRegex } from "./datafileReader";
|
|
3
|
+
import type { SourceResolver } from "./sourceResolver";
|
|
4
|
+
import { Logger } from "./logger";
|
|
5
|
+
export type GetConditionsChecker = () => ConditionsChecker;
|
|
6
|
+
export interface ConditionsCheckerOptions {
|
|
7
|
+
getRegex: GetRegex;
|
|
8
|
+
sourceResolver: SourceResolver;
|
|
9
|
+
logger: Logger;
|
|
10
|
+
}
|
|
11
|
+
export declare class ConditionsChecker {
|
|
12
|
+
private getRegex;
|
|
13
|
+
private sourceResolver;
|
|
14
|
+
private logger;
|
|
15
|
+
constructor(options: ConditionsCheckerOptions);
|
|
16
|
+
isMatched(condition: PlainCondition, inputs: Inputs): Promise<boolean>;
|
|
17
|
+
private _allAreMatched;
|
|
18
|
+
allAreMatched(conditions: Condition[] | Condition, inputs: Inputs): Promise<boolean>;
|
|
19
|
+
parseIfStringified(conditions: Condition | Condition[]): Condition | Condition[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AttributeName, DatafileContent, DestinationName, EffectName, EventName, Persist, ComplexPersist, Attribute, Effect, Event, Destination } from "@eventvisor/types";
|
|
2
|
+
import { Logger } from "./logger";
|
|
3
|
+
export interface DatafileReaderOptions {
|
|
4
|
+
datafile: DatafileContent;
|
|
5
|
+
logger: Logger;
|
|
6
|
+
}
|
|
7
|
+
export type GetDatafileReader = () => DatafileReader;
|
|
8
|
+
export type GetRegex = (regexString: string, regexFlags?: string) => RegExp;
|
|
9
|
+
export declare const emptyDatafile: DatafileContent;
|
|
10
|
+
export declare function getComplexPersists(persist: Persist): ComplexPersist[];
|
|
11
|
+
export declare class DatafileReader {
|
|
12
|
+
private schemaVersion;
|
|
13
|
+
private revision;
|
|
14
|
+
private datafile;
|
|
15
|
+
private logger;
|
|
16
|
+
private regexCache;
|
|
17
|
+
constructor(options: DatafileReaderOptions);
|
|
18
|
+
getSchemaVersion(): string;
|
|
19
|
+
getRevision(): string;
|
|
20
|
+
getAttribute(attributeName: AttributeName): Attribute | undefined;
|
|
21
|
+
getAttributeNames(): AttributeName[];
|
|
22
|
+
getEvent(eventName: EventName): Event | undefined;
|
|
23
|
+
getDestination(destinationName: DestinationName): Destination | undefined;
|
|
24
|
+
getDestinationNames(): DestinationName[];
|
|
25
|
+
getEffect(effectName: EffectName): Effect | undefined;
|
|
26
|
+
getEffectNames(): EffectName[];
|
|
27
|
+
getRegex(regexString: string, regexFlags?: string): RegExp;
|
|
28
|
+
getPersists(schema: Attribute | Effect): ComplexPersist[] | null;
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { EventName, AttributeName, EffectName, Value, EffectOnType } from "@eventvisor/types";
|
|
2
|
+
import type { GetDatafileReader } from "./datafileReader";
|
|
3
|
+
import type { Logger } from "./logger";
|
|
4
|
+
import type { GetTransformer } from "./transformer";
|
|
5
|
+
import type { GetConditionsChecker } from "./conditions";
|
|
6
|
+
import type { ModulesManager } from "./modulesManager";
|
|
7
|
+
export type StatesByEffect = Record<EffectName, Value>;
|
|
8
|
+
export interface DispatchOptions {
|
|
9
|
+
eventType: EffectOnType;
|
|
10
|
+
name: EventName | AttributeName;
|
|
11
|
+
value: Value;
|
|
12
|
+
}
|
|
13
|
+
export interface EffectsManagerOptions {
|
|
14
|
+
logger: Logger;
|
|
15
|
+
getDatafileReader: GetDatafileReader;
|
|
16
|
+
getTransformer: GetTransformer;
|
|
17
|
+
getConditionsChecker: GetConditionsChecker;
|
|
18
|
+
modulesManager: ModulesManager;
|
|
19
|
+
}
|
|
20
|
+
export declare class EffectsManager {
|
|
21
|
+
private logger;
|
|
22
|
+
private getDatafileReader;
|
|
23
|
+
private getTransformer;
|
|
24
|
+
private getConditionsChecker;
|
|
25
|
+
private modulesManager;
|
|
26
|
+
private statesByEffect;
|
|
27
|
+
constructor(options: EffectsManagerOptions);
|
|
28
|
+
initialize(): Promise<void>;
|
|
29
|
+
dispatch(dispatchOptions: DispatchOptions): Promise<void>;
|
|
30
|
+
refresh(): void;
|
|
31
|
+
getAllStates(): StatesByEffect;
|
|
32
|
+
getStateValue(name: EffectName): Value;
|
|
33
|
+
}
|
package/lib/emitter.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type EmitType = "ready" | "datafile_set" | "attribute_set" | "attribute_removed" | "event_tracked";
|
|
2
|
+
export type EventDetails = Record<string, unknown>;
|
|
3
|
+
export type EventCallback = (details: EventDetails) => void;
|
|
4
|
+
export type Listeners = Record<EmitType, EventCallback[]> | {};
|
|
5
|
+
export declare class Emitter {
|
|
6
|
+
listeners: Listeners;
|
|
7
|
+
constructor();
|
|
8
|
+
on(emitType: EmitType, callback: EventCallback): () => void;
|
|
9
|
+
trigger(emitType: EmitType, details?: EventDetails): void;
|
|
10
|
+
clearAll(): void;
|
|
11
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./instance";
|
|
2
|
+
export * from "./attributesManager";
|
|
3
|
+
export * from "./datafileReader";
|
|
4
|
+
export * from "./emitter";
|
|
5
|
+
export * from "./logger";
|
|
6
|
+
export * from "./transformer";
|
|
7
|
+
export * from "./bucketer";
|
|
8
|
+
export * from "./sourceResolver";
|
|
9
|
+
export * from "./modulesManager";
|
|
10
|
+
export * from "./effectsManager";
|
|
11
|
+
export * from "./murmurhash";
|
|
12
|
+
export * from "./compareVersions";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AttributeName, DatafileContent, EventName, EffectName, Value } from "@eventvisor/types";
|
|
2
|
+
import { Logger, LogLevel } from "./logger";
|
|
3
|
+
import { EmitType, EventCallback } from "./emitter";
|
|
4
|
+
import { Module, ModuleName } from "./modulesManager";
|
|
5
|
+
export interface InstanceOptions {
|
|
6
|
+
datafile?: DatafileContent;
|
|
7
|
+
logLevel?: LogLevel;
|
|
8
|
+
logger?: Logger;
|
|
9
|
+
modules?: Module[];
|
|
10
|
+
}
|
|
11
|
+
export declare class Eventvisor {
|
|
12
|
+
private datafileReader;
|
|
13
|
+
private logger;
|
|
14
|
+
private emitter;
|
|
15
|
+
private attributesManager;
|
|
16
|
+
private modulesManager;
|
|
17
|
+
private effectsManager;
|
|
18
|
+
private sourceResolver;
|
|
19
|
+
private conditionsChecker;
|
|
20
|
+
private transformer;
|
|
21
|
+
private bucketer;
|
|
22
|
+
private validator;
|
|
23
|
+
private ready;
|
|
24
|
+
private queue;
|
|
25
|
+
private queueProcessing;
|
|
26
|
+
constructor(options?: InstanceOptions);
|
|
27
|
+
isReady(): boolean;
|
|
28
|
+
onReady(): Promise<void>;
|
|
29
|
+
getRevision(): string;
|
|
30
|
+
setLogLevel(level: LogLevel): void;
|
|
31
|
+
setDatafile(datafile: DatafileContent): void;
|
|
32
|
+
on(emitType: EmitType, callback: EventCallback): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Queue
|
|
35
|
+
*/
|
|
36
|
+
private addToQueue;
|
|
37
|
+
private processQueue;
|
|
38
|
+
/**
|
|
39
|
+
* Attribute
|
|
40
|
+
*/
|
|
41
|
+
setAttributeAsync(attributeName: AttributeName, value: Value): Promise<Value>;
|
|
42
|
+
setAttribute(attributeName: AttributeName, value: Value): void;
|
|
43
|
+
getAttributeValue(attributeName: AttributeName): Value;
|
|
44
|
+
getAttributes(): import("./attributesManager").AttributesMap;
|
|
45
|
+
isAttributeSet(attributeName: AttributeName): boolean;
|
|
46
|
+
removeAttributeAsync(attributeName: AttributeName): Promise<void>;
|
|
47
|
+
removeAttribute(attributeName: AttributeName): void;
|
|
48
|
+
/**
|
|
49
|
+
* Modules
|
|
50
|
+
*/
|
|
51
|
+
registerModule(module: Module): void;
|
|
52
|
+
removeModule(moduleName: ModuleName): void;
|
|
53
|
+
/**
|
|
54
|
+
* Event
|
|
55
|
+
*/
|
|
56
|
+
trackAsync(eventName: EventName, value: Value): Promise<Value | null>;
|
|
57
|
+
track(eventName: EventName, value: Value): void;
|
|
58
|
+
/**
|
|
59
|
+
* Effect's state
|
|
60
|
+
*/
|
|
61
|
+
getStateValue(name: EffectName): Value;
|
|
62
|
+
/**
|
|
63
|
+
* @TODO: implement
|
|
64
|
+
*/
|
|
65
|
+
spawn(): void;
|
|
66
|
+
}
|
|
67
|
+
export declare function createInstance(options?: InstanceOptions): Eventvisor;
|
package/lib/logger.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type LogLevel = "fatal" | "error" | "warn" | "info" | "debug";
|
|
2
|
+
export type LogMessage = string;
|
|
3
|
+
export interface LogDetails {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export type LogHandler = (level: LogLevel, message: LogMessage, details?: LogDetails) => void;
|
|
7
|
+
export interface CreateLoggerOptions {
|
|
8
|
+
level?: LogLevel;
|
|
9
|
+
handler?: LogHandler;
|
|
10
|
+
}
|
|
11
|
+
export declare const loggerPrefix = "[Eventvisor]";
|
|
12
|
+
export declare const defaultLogHandler: LogHandler;
|
|
13
|
+
export declare class Logger {
|
|
14
|
+
static allLevels: LogLevel[];
|
|
15
|
+
static defaultLevel: LogLevel;
|
|
16
|
+
private level;
|
|
17
|
+
private handle;
|
|
18
|
+
constructor(options: CreateLoggerOptions);
|
|
19
|
+
setLevel(level: LogLevel): void;
|
|
20
|
+
log(level: LogLevel, message: LogMessage, details?: LogDetails): void;
|
|
21
|
+
debug(message: LogMessage, details?: LogDetails): void;
|
|
22
|
+
info(message: LogMessage, details?: LogDetails): void;
|
|
23
|
+
warn(message: LogMessage, details?: LogDetails): void;
|
|
24
|
+
error(message: LogMessage, details?: LogDetails): void;
|
|
25
|
+
}
|
|
26
|
+
export declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Value, Effect, Step, EventName, DestinationName, EffectName, EventLevel } from "@eventvisor/types";
|
|
2
|
+
import type { Logger } from "./logger";
|
|
3
|
+
import type { DatafileReader } from "./datafileReader";
|
|
4
|
+
import type { SourceResolver } from "./sourceResolver";
|
|
5
|
+
export type ModuleName = string;
|
|
6
|
+
export interface LookupOptions {
|
|
7
|
+
key: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HandleOptions {
|
|
10
|
+
effectName: EffectName;
|
|
11
|
+
effect: Effect;
|
|
12
|
+
step: Step;
|
|
13
|
+
payload: Value;
|
|
14
|
+
}
|
|
15
|
+
export interface TransportOptions {
|
|
16
|
+
destinationName: DestinationName;
|
|
17
|
+
eventName: EventName;
|
|
18
|
+
eventLevel?: EventLevel;
|
|
19
|
+
payload: Value;
|
|
20
|
+
}
|
|
21
|
+
export interface ReadFromStorageOptions {
|
|
22
|
+
key: string;
|
|
23
|
+
}
|
|
24
|
+
export interface WriteToStorageOptions {
|
|
25
|
+
key: string;
|
|
26
|
+
value: Value;
|
|
27
|
+
}
|
|
28
|
+
export interface RemoveFromStorageOptions {
|
|
29
|
+
key: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ModuleDependencies {
|
|
32
|
+
datafileReader: DatafileReader;
|
|
33
|
+
logger: Logger;
|
|
34
|
+
sourceResolver: SourceResolver;
|
|
35
|
+
}
|
|
36
|
+
export interface Module {
|
|
37
|
+
name: ModuleName;
|
|
38
|
+
lookup?: (options: LookupOptions, deps: ModuleDependencies) => Promise<Value>;
|
|
39
|
+
handle?: (options: HandleOptions, deps: ModuleDependencies) => Promise<void>;
|
|
40
|
+
transport?: (options: TransportOptions, deps: ModuleDependencies) => Promise<void>;
|
|
41
|
+
readFromStorage?: (options: ReadFromStorageOptions, deps: ModuleDependencies) => Promise<Value>;
|
|
42
|
+
writeToStorage?: (options: WriteToStorageOptions, deps: ModuleDependencies) => Promise<void>;
|
|
43
|
+
removeFromStorage?: (options: RemoveFromStorageOptions, deps: ModuleDependencies) => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface ModulesManagerOptions {
|
|
46
|
+
logger: Logger;
|
|
47
|
+
getDatafileReader: () => DatafileReader;
|
|
48
|
+
getSourceResolver: () => SourceResolver;
|
|
49
|
+
}
|
|
50
|
+
export declare class ModulesManager {
|
|
51
|
+
private logger;
|
|
52
|
+
private getDatafileReader;
|
|
53
|
+
private getSourceResolver;
|
|
54
|
+
private modules;
|
|
55
|
+
constructor(options: ModulesManagerOptions);
|
|
56
|
+
registerModule(module: Module): void;
|
|
57
|
+
getModule(name: string): Module;
|
|
58
|
+
removeModule(name: string): void;
|
|
59
|
+
getModuleDependencies(): ModuleDependencies;
|
|
60
|
+
lookup(fullKey: string): Promise<Value>;
|
|
61
|
+
handle(fullKey: string, effectName: EffectName, effect: Effect, step: Step, payload: Value): Promise<void>;
|
|
62
|
+
transportExists(fullKey: string): boolean;
|
|
63
|
+
transport(fullKey: string, destinationName: DestinationName, eventName: EventName, payload: Value, eventLevel?: EventLevel): Promise<void>;
|
|
64
|
+
readFromStorage(moduleName: ModuleName, key: string): Promise<Value>;
|
|
65
|
+
writeToStorage(moduleName: ModuleName, key: string, value: Value): Promise<void>;
|
|
66
|
+
removeFromStorage(moduleName: ModuleName, key: string): Promise<void>;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MurmurHashV3(key: any, seed: any): number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Attribute, Effect, Value, ComplexPersist } from "@eventvisor/types";
|
|
2
|
+
import type { DatafileReader } from "./datafileReader";
|
|
3
|
+
import type { ConditionsChecker } from "./conditions";
|
|
4
|
+
import type { ModulesManager } from "./modulesManager";
|
|
5
|
+
export type EntityMap = Record<string, Value>;
|
|
6
|
+
export interface InitializeFromStorageOptions {
|
|
7
|
+
datafileReader: DatafileReader;
|
|
8
|
+
conditionsChecker: ConditionsChecker;
|
|
9
|
+
modulesManager: ModulesManager;
|
|
10
|
+
storageKeyPrefix: string;
|
|
11
|
+
getEntityNames: () => string[];
|
|
12
|
+
getEntity: (entityName: string) => Attribute | Effect | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface FindPersistOptions {
|
|
15
|
+
persists: ComplexPersist[];
|
|
16
|
+
entityName: string;
|
|
17
|
+
conditionsChecker: ConditionsChecker;
|
|
18
|
+
payload: Value;
|
|
19
|
+
}
|
|
20
|
+
export declare function findPersist(options: FindPersistOptions): Promise<ComplexPersist | undefined>;
|
|
21
|
+
export declare function initializeFromStorage({ datafileReader, conditionsChecker, modulesManager, storageKeyPrefix, getEntityNames, getEntity, }: InitializeFromStorageOptions): Promise<EntityMap>;
|
|
22
|
+
export interface PersistEntityOptions {
|
|
23
|
+
datafileReader: DatafileReader;
|
|
24
|
+
conditionsChecker: ConditionsChecker;
|
|
25
|
+
modulesManager: ModulesManager;
|
|
26
|
+
storageKeyPrefix: string;
|
|
27
|
+
entityName: string;
|
|
28
|
+
entity: Attribute | Effect | undefined;
|
|
29
|
+
value: Value;
|
|
30
|
+
}
|
|
31
|
+
export declare function persistEntity({ datafileReader, conditionsChecker, modulesManager, storageKeyPrefix, entityName, entity, value, }: PersistEntityOptions): Promise<void>;
|
|
32
|
+
export interface RemoveEntityOptions {
|
|
33
|
+
datafileReader: DatafileReader;
|
|
34
|
+
conditionsChecker: ConditionsChecker;
|
|
35
|
+
modulesManager: ModulesManager;
|
|
36
|
+
storageKeyPrefix: string;
|
|
37
|
+
entityName: string;
|
|
38
|
+
entity: Attribute | Effect | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare function removeEntity({ datafileReader, conditionsChecker, modulesManager, storageKeyPrefix, entityName, entity, }: RemoveEntityOptions): Promise<void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Source, SourceBase, Value, Inputs } from "@eventvisor/types";
|
|
2
|
+
import type { ModulesManager } from "./modulesManager";
|
|
3
|
+
import type { Logger } from "./logger";
|
|
4
|
+
import type { AttributesManager } from "./attributesManager";
|
|
5
|
+
import type { EffectsManager } from "./effectsManager";
|
|
6
|
+
export type GetSourceResolver = () => SourceResolver;
|
|
7
|
+
export interface SourceResolverOptions {
|
|
8
|
+
logger: Logger;
|
|
9
|
+
modulesManager: ModulesManager;
|
|
10
|
+
attributesManager: AttributesManager;
|
|
11
|
+
effectsManager: EffectsManager;
|
|
12
|
+
}
|
|
13
|
+
export interface SourcePath {
|
|
14
|
+
name: string;
|
|
15
|
+
path: string[];
|
|
16
|
+
fullKey: string;
|
|
17
|
+
}
|
|
18
|
+
export type SourceOrigin = SourcePath & {
|
|
19
|
+
originType: "attribute" | "attributes" | "effect" | "payload" | "lookup" | string;
|
|
20
|
+
};
|
|
21
|
+
export declare class SourceResolver {
|
|
22
|
+
private logger;
|
|
23
|
+
private modulesManager;
|
|
24
|
+
private attributesManager;
|
|
25
|
+
private effectsManager;
|
|
26
|
+
constructor(options: SourceResolverOptions);
|
|
27
|
+
getPath(p: string): SourcePath;
|
|
28
|
+
getOrigin(source: Source | Partial<SourceBase>): SourceOrigin | SourceOrigin[] | null;
|
|
29
|
+
resolveByOrigin(origin: SourceOrigin | null, inputs?: Inputs): Promise<Value>;
|
|
30
|
+
resolve(source: Source | Partial<SourceBase>, inputs?: Inputs): Promise<Value>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Value, Transform, Inputs } from "@eventvisor/types";
|
|
2
|
+
import type { Logger } from "./logger";
|
|
3
|
+
import type { ConditionsChecker } from "./conditions";
|
|
4
|
+
import type { SourceResolver } from "./sourceResolver";
|
|
5
|
+
export type GetTransformer = () => Transformer;
|
|
6
|
+
export interface TransformerOptions {
|
|
7
|
+
logger: Logger;
|
|
8
|
+
conditionsChecker: ConditionsChecker;
|
|
9
|
+
sourceResolver: SourceResolver;
|
|
10
|
+
}
|
|
11
|
+
export declare class Transformer {
|
|
12
|
+
private logger;
|
|
13
|
+
private conditionsChecker;
|
|
14
|
+
private sourceResolver;
|
|
15
|
+
constructor(options: TransformerOptions);
|
|
16
|
+
applyAll(value: Value, transforms: Transform[], inputs?: Inputs): Promise<Value>;
|
|
17
|
+
static renameValueAt(obj: any, target: Record<string, string>): any;
|
|
18
|
+
static getValueAtPath(obj: any, path: string): any;
|
|
19
|
+
static setValueAtPath(obj: any, path: string, value: any): any;
|
|
20
|
+
static removeValueAt(obj: any, path: string): any;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JSONSchema, Value } from "@eventvisor/types";
|
|
2
|
+
import type { GetSourceResolver } from "./sourceResolver";
|
|
3
|
+
import type { Logger } from "./logger";
|
|
4
|
+
export interface ValidatorOptions {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
getSourceResolver: GetSourceResolver;
|
|
7
|
+
}
|
|
8
|
+
export declare class Validator {
|
|
9
|
+
private logger;
|
|
10
|
+
private getSourceResolver;
|
|
11
|
+
constructor(options: ValidatorOptions);
|
|
12
|
+
validate(schema: JSONSchema, value: Value): Promise<ValidationResult>;
|
|
13
|
+
}
|
|
14
|
+
export interface ValidationError {
|
|
15
|
+
path: string;
|
|
16
|
+
message: string;
|
|
17
|
+
schema?: JSONSchema;
|
|
18
|
+
value?: Value;
|
|
19
|
+
}
|
|
20
|
+
export interface ValidationResult {
|
|
21
|
+
valid: boolean;
|
|
22
|
+
errors?: ValidationError[];
|
|
23
|
+
value?: Value;
|
|
24
|
+
}
|
|
25
|
+
export interface ValidationDependencies {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
export declare function validate(schema: JSONSchema, value: Value, deps: ValidationDependencies): Promise<ValidationResult>;
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eventvisor/sdk",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Eventvisor SDK for Node.js and the browser",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"transpile": "echo 'Nothing to transpile'",
|
|
18
|
+
"dist": "webpack --config ./webpack.config.js && tsc --project tsconfig.esm.json --declaration --emitDeclarationOnly --declarationDir dist",
|
|
19
|
+
"build": "npm run transpile && npm run dist",
|
|
20
|
+
"test": "jest --config jest.config.js --verbose --coverage",
|
|
21
|
+
"test:no-coverage": "jest --config jest.config.js --verbose"
|
|
22
|
+
},
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Fahad Heylaal",
|
|
25
|
+
"url": "https://fahad19.com"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://eventvisor.org",
|
|
28
|
+
"keywords": [],
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/eventvisor/eventvisor.git"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"registry": "https://registry.npmjs.org/"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/eventvisor/eventvisor/issues"
|
|
39
|
+
},
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@eventvisor/types": "0.0.2"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "373d5c00cb6fa0d6f4baaa05a10e57e505474847"
|
|
45
|
+
}
|