@hotmeshio/hotmesh 0.0.1
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 +214 -0
- package/README.md +241 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +7 -0
- package/build/modules/errors.d.ts +28 -0
- package/build/modules/errors.js +50 -0
- package/build/modules/key.d.ts +75 -0
- package/build/modules/key.js +116 -0
- package/build/modules/utils.d.ts +34 -0
- package/build/modules/utils.js +173 -0
- package/build/package.json +73 -0
- package/build/services/activities/activity.d.ts +59 -0
- package/build/services/activities/activity.js +396 -0
- package/build/services/activities/await.d.ts +16 -0
- package/build/services/activities/await.js +143 -0
- package/build/services/activities/emit.d.ts +9 -0
- package/build/services/activities/emit.js +13 -0
- package/build/services/activities/index.d.ts +15 -0
- package/build/services/activities/index.js +16 -0
- package/build/services/activities/iterate.d.ts +9 -0
- package/build/services/activities/iterate.js +13 -0
- package/build/services/activities/trigger.d.ts +22 -0
- package/build/services/activities/trigger.js +161 -0
- package/build/services/activities/worker.d.ts +17 -0
- package/build/services/activities/worker.js +164 -0
- package/build/services/collator/index.d.ts +54 -0
- package/build/services/collator/index.js +171 -0
- package/build/services/compiler/deployer.d.ts +35 -0
- package/build/services/compiler/deployer.js +412 -0
- package/build/services/compiler/index.d.ts +30 -0
- package/build/services/compiler/index.js +111 -0
- package/build/services/compiler/validator.d.ts +32 -0
- package/build/services/compiler/validator.js +134 -0
- package/build/services/connector/clients/ioredis.d.ts +13 -0
- package/build/services/connector/clients/ioredis.js +50 -0
- package/build/services/connector/clients/redis.d.ts +13 -0
- package/build/services/connector/clients/redis.js +62 -0
- package/build/services/connector/index.d.ts +5 -0
- package/build/services/connector/index.js +31 -0
- package/build/services/dimension/index.d.ts +29 -0
- package/build/services/dimension/index.js +35 -0
- package/build/services/durable/asyncLocalStorage.d.ts +3 -0
- package/build/services/durable/asyncLocalStorage.js +5 -0
- package/build/services/durable/client.d.ts +15 -0
- package/build/services/durable/client.js +108 -0
- package/build/services/durable/connection.d.ts +4 -0
- package/build/services/durable/connection.js +51 -0
- package/build/services/durable/factory.d.ts +3 -0
- package/build/services/durable/factory.js +123 -0
- package/build/services/durable/handle.d.ts +8 -0
- package/build/services/durable/handle.js +38 -0
- package/build/services/durable/index.d.ts +57 -0
- package/build/services/durable/index.js +58 -0
- package/build/services/durable/native.d.ts +4 -0
- package/build/services/durable/native.js +47 -0
- package/build/services/durable/worker.d.ts +36 -0
- package/build/services/durable/worker.js +266 -0
- package/build/services/durable/workflow.d.ts +6 -0
- package/build/services/durable/workflow.js +135 -0
- package/build/services/engine/index.d.ts +82 -0
- package/build/services/engine/index.js +511 -0
- package/build/services/hotmesh/index.d.ts +45 -0
- package/build/services/hotmesh/index.js +134 -0
- package/build/services/logger/index.d.ts +17 -0
- package/build/services/logger/index.js +73 -0
- package/build/services/mapper/index.d.ts +24 -0
- package/build/services/mapper/index.js +72 -0
- package/build/services/pipe/functions/array.d.ts +24 -0
- package/build/services/pipe/functions/array.js +69 -0
- package/build/services/pipe/functions/bitwise.d.ts +9 -0
- package/build/services/pipe/functions/bitwise.js +24 -0
- package/build/services/pipe/functions/conditional.d.ts +10 -0
- package/build/services/pipe/functions/conditional.js +27 -0
- package/build/services/pipe/functions/date.d.ts +57 -0
- package/build/services/pipe/functions/date.js +167 -0
- package/build/services/pipe/functions/index.d.ts +25 -0
- package/build/services/pipe/functions/index.js +26 -0
- package/build/services/pipe/functions/json.d.ts +5 -0
- package/build/services/pipe/functions/json.js +12 -0
- package/build/services/pipe/functions/math.d.ts +38 -0
- package/build/services/pipe/functions/math.js +111 -0
- package/build/services/pipe/functions/number.d.ts +25 -0
- package/build/services/pipe/functions/number.js +133 -0
- package/build/services/pipe/functions/object.d.ts +22 -0
- package/build/services/pipe/functions/object.js +63 -0
- package/build/services/pipe/functions/string.d.ts +23 -0
- package/build/services/pipe/functions/string.js +69 -0
- package/build/services/pipe/functions/symbol.d.ts +12 -0
- package/build/services/pipe/functions/symbol.js +33 -0
- package/build/services/pipe/functions/unary.d.ts +7 -0
- package/build/services/pipe/functions/unary.js +18 -0
- package/build/services/pipe/index.d.ts +30 -0
- package/build/services/pipe/index.js +128 -0
- package/build/services/quorum/index.d.ts +34 -0
- package/build/services/quorum/index.js +147 -0
- package/build/services/reporter/index.d.ts +47 -0
- package/build/services/reporter/index.js +330 -0
- package/build/services/serializer/index.d.ts +36 -0
- package/build/services/serializer/index.js +222 -0
- package/build/services/signaler/store.d.ts +15 -0
- package/build/services/signaler/store.js +53 -0
- package/build/services/signaler/stream.d.ts +43 -0
- package/build/services/signaler/stream.js +317 -0
- package/build/services/store/cache.d.ts +66 -0
- package/build/services/store/cache.js +127 -0
- package/build/services/store/clients/ioredis.d.ts +27 -0
- package/build/services/store/clients/ioredis.js +96 -0
- package/build/services/store/clients/redis.d.ts +29 -0
- package/build/services/store/clients/redis.js +143 -0
- package/build/services/store/index.d.ts +88 -0
- package/build/services/store/index.js +657 -0
- package/build/services/stream/clients/ioredis.d.ts +23 -0
- package/build/services/stream/clients/ioredis.js +115 -0
- package/build/services/stream/clients/redis.d.ts +23 -0
- package/build/services/stream/clients/redis.js +119 -0
- package/build/services/stream/index.d.ts +21 -0
- package/build/services/stream/index.js +9 -0
- package/build/services/sub/clients/ioredis.d.ts +20 -0
- package/build/services/sub/clients/ioredis.js +72 -0
- package/build/services/sub/clients/redis.d.ts +20 -0
- package/build/services/sub/clients/redis.js +63 -0
- package/build/services/sub/index.d.ts +18 -0
- package/build/services/sub/index.js +9 -0
- package/build/services/task/index.d.ts +18 -0
- package/build/services/task/index.js +73 -0
- package/build/services/telemetry/index.d.ts +49 -0
- package/build/services/telemetry/index.js +223 -0
- package/build/services/worker/index.d.ts +30 -0
- package/build/services/worker/index.js +105 -0
- package/build/types/activity.d.ts +86 -0
- package/build/types/activity.js +2 -0
- package/build/types/app.d.ts +16 -0
- package/build/types/app.js +2 -0
- package/build/types/async.d.ts +5 -0
- package/build/types/async.js +2 -0
- package/build/types/cache.d.ts +1 -0
- package/build/types/cache.js +2 -0
- package/build/types/collator.d.ts +8 -0
- package/build/types/collator.js +11 -0
- package/build/types/durable.d.ts +59 -0
- package/build/types/durable.js +2 -0
- package/build/types/hook.d.ts +31 -0
- package/build/types/hook.js +9 -0
- package/build/types/hotmesh.d.ts +82 -0
- package/build/types/hotmesh.js +2 -0
- package/build/types/index.d.ts +20 -0
- package/build/types/index.js +21 -0
- package/build/types/ioredisclient.d.ts +5 -0
- package/build/types/ioredisclient.js +5 -0
- package/build/types/job.d.ts +50 -0
- package/build/types/job.js +2 -0
- package/build/types/logger.d.ts +6 -0
- package/build/types/logger.js +2 -0
- package/build/types/map.d.ts +4 -0
- package/build/types/map.js +2 -0
- package/build/types/pipe.d.ts +4 -0
- package/build/types/pipe.js +2 -0
- package/build/types/quorum.d.ts +46 -0
- package/build/types/quorum.js +2 -0
- package/build/types/redis.d.ts +8 -0
- package/build/types/redis.js +2 -0
- package/build/types/redisclient.d.ts +25 -0
- package/build/types/redisclient.js +2 -0
- package/build/types/serializer.d.ts +33 -0
- package/build/types/serializer.js +2 -0
- package/build/types/stats.d.ts +83 -0
- package/build/types/stats.js +2 -0
- package/build/types/stream.d.ts +67 -0
- package/build/types/stream.js +25 -0
- package/build/types/telemetry.d.ts +1 -0
- package/build/types/telemetry.js +11 -0
- package/build/types/transition.d.ts +17 -0
- package/build/types/transition.js +2 -0
- package/index.ts +5 -0
- package/modules/errors.ts +55 -0
- package/modules/key.ts +129 -0
- package/modules/utils.ts +170 -0
- package/package.json +73 -0
- package/services/activities/activity.ts +473 -0
- package/services/activities/await.ts +172 -0
- package/services/activities/emit.ts +25 -0
- package/services/activities/index.ts +15 -0
- package/services/activities/iterate.ts +26 -0
- package/services/activities/trigger.ts +196 -0
- package/services/activities/worker.ts +190 -0
- package/services/collator/README.md +102 -0
- package/services/collator/index.ts +182 -0
- package/services/compiler/deployer.ts +432 -0
- package/services/compiler/index.ts +98 -0
- package/services/compiler/validator.ts +154 -0
- package/services/connector/clients/ioredis.ts +57 -0
- package/services/connector/clients/redis.ts +72 -0
- package/services/connector/index.ts +44 -0
- package/services/dimension/README.md +73 -0
- package/services/dimension/index.ts +39 -0
- package/services/durable/asyncLocalStorage.ts +3 -0
- package/services/durable/client.ts +116 -0
- package/services/durable/connection.ts +50 -0
- package/services/durable/factory.ts +124 -0
- package/services/durable/handle.ts +43 -0
- package/services/durable/index.ts +60 -0
- package/services/durable/native.ts +46 -0
- package/services/durable/worker.ts +254 -0
- package/services/durable/workflow.ts +136 -0
- package/services/engine/index.ts +615 -0
- package/services/hotmesh/index.ts +182 -0
- package/services/logger/index.ts +79 -0
- package/services/mapper/index.ts +84 -0
- package/services/pipe/functions/array.ts +87 -0
- package/services/pipe/functions/bitwise.ts +27 -0
- package/services/pipe/functions/conditional.ts +31 -0
- package/services/pipe/functions/date.ts +214 -0
- package/services/pipe/functions/index.ts +25 -0
- package/services/pipe/functions/json.ts +11 -0
- package/services/pipe/functions/math.ts +143 -0
- package/services/pipe/functions/number.ts +150 -0
- package/services/pipe/functions/object.ts +79 -0
- package/services/pipe/functions/string.ts +86 -0
- package/services/pipe/functions/symbol.ts +39 -0
- package/services/pipe/functions/unary.ts +19 -0
- package/services/pipe/index.ts +138 -0
- package/services/quorum/index.ts +200 -0
- package/services/reporter/index.ts +379 -0
- package/services/serializer/README.md +10 -0
- package/services/serializer/index.ts +243 -0
- package/services/signaler/store.ts +61 -0
- package/services/signaler/stream.ts +354 -0
- package/services/store/cache.ts +172 -0
- package/services/store/clients/ioredis.ts +123 -0
- package/services/store/clients/redis.ts +169 -0
- package/services/store/index.ts +757 -0
- package/services/stream/clients/ioredis.ts +148 -0
- package/services/stream/clients/redis.ts +144 -0
- package/services/stream/index.ts +57 -0
- package/services/sub/clients/ioredis.ts +83 -0
- package/services/sub/clients/redis.ts +74 -0
- package/services/sub/index.ts +25 -0
- package/services/task/index.ts +86 -0
- package/services/telemetry/index.ts +267 -0
- package/services/worker/index.ts +165 -0
- package/types/activity.ts +115 -0
- package/types/app.ts +20 -0
- package/types/async.ts +7 -0
- package/types/cache.ts +1 -0
- package/types/collator.ts +9 -0
- package/types/durable.ts +81 -0
- package/types/hook.ts +32 -0
- package/types/hotmesh.ts +102 -0
- package/types/index.ts +138 -0
- package/types/ioredisclient.ts +10 -0
- package/types/job.ts +59 -0
- package/types/logger.ts +6 -0
- package/types/map.ts +5 -0
- package/types/ms.d.ts +7 -0
- package/types/pipe.ts +7 -0
- package/types/quorum.ts +59 -0
- package/types/redis.ts +27 -0
- package/types/redisclient.ts +29 -0
- package/types/serializer.ts +38 -0
- package/types/stats.ts +100 -0
- package/types/stream.ts +75 -0
- package/types/telemetry.ts +15 -0
- package/types/transition.ts +20 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ILogger } from "../services/logger";
|
|
2
|
+
import { HotMeshService } from "../services/hotmesh";
|
|
3
|
+
import { HookRules } from "./hook";
|
|
4
|
+
import { RedisClass, RedisClient, RedisOptions } from "./redis";
|
|
5
|
+
import { StreamData, StreamDataResponse } from "./stream";
|
|
6
|
+
type HotMesh = typeof HotMeshService;
|
|
7
|
+
type RedisConfig = {
|
|
8
|
+
class: RedisClass;
|
|
9
|
+
options: RedisOptions;
|
|
10
|
+
};
|
|
11
|
+
type HotMeshEngine = {
|
|
12
|
+
store?: RedisClient;
|
|
13
|
+
stream?: RedisClient;
|
|
14
|
+
sub?: RedisClient;
|
|
15
|
+
redis?: RedisConfig;
|
|
16
|
+
reclaimDelay?: number;
|
|
17
|
+
reclaimCount?: number;
|
|
18
|
+
};
|
|
19
|
+
type HotMeshWorker = {
|
|
20
|
+
topic: string;
|
|
21
|
+
store?: RedisClient;
|
|
22
|
+
stream?: RedisClient;
|
|
23
|
+
sub?: RedisClient;
|
|
24
|
+
redis?: {
|
|
25
|
+
class: RedisClass;
|
|
26
|
+
options: RedisOptions;
|
|
27
|
+
};
|
|
28
|
+
reclaimDelay?: number;
|
|
29
|
+
reclaimCount?: number;
|
|
30
|
+
callback: (payload: StreamData) => Promise<StreamDataResponse | void>;
|
|
31
|
+
};
|
|
32
|
+
type HotMeshConfig = {
|
|
33
|
+
appId: string;
|
|
34
|
+
namespace?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
logger?: ILogger;
|
|
37
|
+
logLevel?: 'silly' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
38
|
+
engine?: HotMeshEngine;
|
|
39
|
+
workers?: HotMeshWorker[];
|
|
40
|
+
};
|
|
41
|
+
type HotMeshGraph = {
|
|
42
|
+
subscribes: string;
|
|
43
|
+
publishes?: string;
|
|
44
|
+
expire?: number;
|
|
45
|
+
output?: {
|
|
46
|
+
schema: Record<string, any>;
|
|
47
|
+
};
|
|
48
|
+
input?: {
|
|
49
|
+
schema: Record<string, any>;
|
|
50
|
+
};
|
|
51
|
+
activities: Record<string, any>;
|
|
52
|
+
transitions?: Record<string, any>;
|
|
53
|
+
hooks?: HookRules;
|
|
54
|
+
};
|
|
55
|
+
type HotMeshSettings = {
|
|
56
|
+
namespace: string;
|
|
57
|
+
version: string;
|
|
58
|
+
};
|
|
59
|
+
type HotMeshManifest = {
|
|
60
|
+
app: {
|
|
61
|
+
id: string;
|
|
62
|
+
version: string;
|
|
63
|
+
settings: Record<string, any>;
|
|
64
|
+
graphs: HotMeshGraph[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
type VersionedFields = {
|
|
68
|
+
[K in `versions/${string}`]: any;
|
|
69
|
+
};
|
|
70
|
+
type HotMeshApp = VersionedFields & {
|
|
71
|
+
id: string;
|
|
72
|
+
version: string;
|
|
73
|
+
settings?: string;
|
|
74
|
+
active?: boolean;
|
|
75
|
+
};
|
|
76
|
+
type HotMeshApps = {
|
|
77
|
+
[appId: string]: HotMeshApp;
|
|
78
|
+
};
|
|
79
|
+
export { HotMesh, HotMeshEngine, RedisConfig, HotMeshWorker, HotMeshSettings, HotMeshApp, //a single app in the db
|
|
80
|
+
HotMeshApps, //object array of all apps in the db
|
|
81
|
+
HotMeshConfig, //customer config
|
|
82
|
+
HotMeshManifest, HotMeshGraph };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { ActivityType, ActivityDataType, ActivityContext, ActivityData, ActivityDuplex, ActivityLeg, ActivityMetadata, Consumes, AwaitActivity, BaseActivity, EmitActivity, WorkerActivity, IterateActivity, TriggerActivity, TriggerActivityStats } from './activity';
|
|
2
|
+
export { App, AppVID, AppTransitions, AppSubscriptions } from './app';
|
|
3
|
+
export { AsyncSignal } from './async';
|
|
4
|
+
export { CacheMode } from './cache';
|
|
5
|
+
export { CollationFaultType, CollationStage } from './collator';
|
|
6
|
+
export { HookCondition, HookConditions, HookGate, HookInterface, HookRule, HookRules, HookSignal } from './hook';
|
|
7
|
+
export { RedisClientType as IORedisClientType, RedisMultiType as IORedisMultiType } from './ioredisclient';
|
|
8
|
+
export { ILogger } from './logger';
|
|
9
|
+
export { JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState } from './job';
|
|
10
|
+
export { MappingStatements } from './map';
|
|
11
|
+
export { Pipe, PipeItem, PipeItems } from './pipe';
|
|
12
|
+
export { HotMesh, HotMeshApp, HotMeshApps, HotMeshConfig, HotMeshEngine, RedisConfig, HotMeshGraph, HotMeshManifest, HotMeshSettings, HotMeshWorker } from './hotmesh';
|
|
13
|
+
export { ActivateMessage, JobMessage, JobMessageCallback, PingMessage, PongMessage, QuorumMessage, SubscriptionCallback, ThrottleMessage, WorkMessage } from './quorum';
|
|
14
|
+
export { MultiResponseFlags, RedisClient, RedisMulti } from './redis';
|
|
15
|
+
export { RedisClientType, RedisMultiType } from './redisclient';
|
|
16
|
+
export { JSONSchema, StringAnyType, StringScalarType, StringStringType, SymbolMap, SymbolMaps, SymbolRanges, Symbols, SymbolSets } from './serializer';
|
|
17
|
+
export { AggregatedData, CountByFacet, GetStatsOptions, IdsData, Measure, MeasureIds, MetricTypes, StatType, StatsType, IdsResponse, JobStats, JobStatsInput, JobStatsRange, StatsResponse, Segment, TimeSegment } from './stats';
|
|
18
|
+
export { ReclaimedMessageType, StreamCode, StreamConfig, StreamData, StreamDataType, StreamError, StreamDataResponse, StreamRetryPolicy, StreamRole, StreamStatus } from './stream';
|
|
19
|
+
export { context, Context, Counter, Meter, metrics, propagation, SpanContext, Span, SpanStatus, SpanStatusCode, SpanKind, trace, Tracer, ValueType } from './telemetry';
|
|
20
|
+
export { TransitionMatch, TransitionRule, Transitions } from './transition';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValueType = exports.trace = exports.SpanKind = exports.SpanStatusCode = exports.propagation = exports.metrics = exports.context = exports.StreamStatus = exports.StreamRole = exports.StreamDataType = exports.IORedisClientType = exports.HookGate = exports.CollationFaultType = void 0;
|
|
4
|
+
var collator_1 = require("./collator");
|
|
5
|
+
Object.defineProperty(exports, "CollationFaultType", { enumerable: true, get: function () { return collator_1.CollationFaultType; } });
|
|
6
|
+
var hook_1 = require("./hook");
|
|
7
|
+
Object.defineProperty(exports, "HookGate", { enumerable: true, get: function () { return hook_1.HookGate; } });
|
|
8
|
+
var ioredisclient_1 = require("./ioredisclient");
|
|
9
|
+
Object.defineProperty(exports, "IORedisClientType", { enumerable: true, get: function () { return ioredisclient_1.RedisClientType; } });
|
|
10
|
+
var stream_1 = require("./stream");
|
|
11
|
+
Object.defineProperty(exports, "StreamDataType", { enumerable: true, get: function () { return stream_1.StreamDataType; } });
|
|
12
|
+
Object.defineProperty(exports, "StreamRole", { enumerable: true, get: function () { return stream_1.StreamRole; } });
|
|
13
|
+
Object.defineProperty(exports, "StreamStatus", { enumerable: true, get: function () { return stream_1.StreamStatus; } });
|
|
14
|
+
var telemetry_1 = require("./telemetry");
|
|
15
|
+
Object.defineProperty(exports, "context", { enumerable: true, get: function () { return telemetry_1.context; } });
|
|
16
|
+
Object.defineProperty(exports, "metrics", { enumerable: true, get: function () { return telemetry_1.metrics; } });
|
|
17
|
+
Object.defineProperty(exports, "propagation", { enumerable: true, get: function () { return telemetry_1.propagation; } });
|
|
18
|
+
Object.defineProperty(exports, "SpanStatusCode", { enumerable: true, get: function () { return telemetry_1.SpanStatusCode; } });
|
|
19
|
+
Object.defineProperty(exports, "SpanKind", { enumerable: true, get: function () { return telemetry_1.SpanKind; } });
|
|
20
|
+
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return telemetry_1.trace; } });
|
|
21
|
+
Object.defineProperty(exports, "ValueType", { enumerable: true, get: function () { return telemetry_1.ValueType; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisClientType = void 0;
|
|
4
|
+
const ioredis_1 = require("ioredis");
|
|
5
|
+
Object.defineProperty(exports, "RedisClientType", { enumerable: true, get: function () { return ioredis_1.Redis; } });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
type JobData = Record<string, unknown | Record<string, unknown>>;
|
|
2
|
+
type JobsData = Record<string, unknown>;
|
|
3
|
+
type ActivityData = {
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
type JobMetadata = {
|
|
8
|
+
key?: string;
|
|
9
|
+
jid: string;
|
|
10
|
+
dad: string;
|
|
11
|
+
aid: string;
|
|
12
|
+
pj?: string;
|
|
13
|
+
pd?: string;
|
|
14
|
+
pa?: string;
|
|
15
|
+
ngn?: string;
|
|
16
|
+
app: string;
|
|
17
|
+
vrs: string;
|
|
18
|
+
tpc: string;
|
|
19
|
+
ts: string;
|
|
20
|
+
jc: string;
|
|
21
|
+
ju: string;
|
|
22
|
+
js: JobStatus;
|
|
23
|
+
atp: string;
|
|
24
|
+
stp: string;
|
|
25
|
+
spn: string;
|
|
26
|
+
trc: string;
|
|
27
|
+
err?: string;
|
|
28
|
+
expire?: number;
|
|
29
|
+
};
|
|
30
|
+
type JobStatus = number;
|
|
31
|
+
type JobState = {
|
|
32
|
+
metadata: JobMetadata;
|
|
33
|
+
data: JobData;
|
|
34
|
+
[activityId: symbol]: {
|
|
35
|
+
input: ActivityData;
|
|
36
|
+
output: ActivityData;
|
|
37
|
+
hook: ActivityData;
|
|
38
|
+
settings: ActivityData;
|
|
39
|
+
errors: ActivityData;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type JobOutput = {
|
|
43
|
+
metadata: JobMetadata;
|
|
44
|
+
data: JobData;
|
|
45
|
+
};
|
|
46
|
+
type PartialJobState = {
|
|
47
|
+
metadata: JobMetadata | Pick<JobMetadata, 'jid' | 'dad' | 'aid'>;
|
|
48
|
+
data: JobData;
|
|
49
|
+
};
|
|
50
|
+
export { JobState, JobStatus, JobData, JobsData, JobMetadata, PartialJobState, JobOutput };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JobOutput } from "./job";
|
|
2
|
+
/**
|
|
3
|
+
* The types in this file are used to define those messages that are sent
|
|
4
|
+
* to hotmesh client instances when a new version is about to be activated.
|
|
5
|
+
* These messages serve to coordinate the cache invalidation and switch-over
|
|
6
|
+
* to the new version without any downtime and a coordinating parent server.
|
|
7
|
+
*/
|
|
8
|
+
export type QuorumMessage = PingMessage | PongMessage | ActivateMessage | WorkMessage | JobMessage | ThrottleMessage;
|
|
9
|
+
export interface PingMessage {
|
|
10
|
+
type: 'ping';
|
|
11
|
+
originator: string;
|
|
12
|
+
}
|
|
13
|
+
export interface WorkMessage {
|
|
14
|
+
type: 'work';
|
|
15
|
+
originator: string;
|
|
16
|
+
}
|
|
17
|
+
export interface PongMessage {
|
|
18
|
+
type: 'pong';
|
|
19
|
+
originator: string;
|
|
20
|
+
guid: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ActivateMessage {
|
|
23
|
+
type: 'activate';
|
|
24
|
+
cache_mode: 'nocache' | 'cache';
|
|
25
|
+
until_version: string;
|
|
26
|
+
}
|
|
27
|
+
export interface JobMessage {
|
|
28
|
+
type: 'job';
|
|
29
|
+
topic: string;
|
|
30
|
+
job: JobOutput;
|
|
31
|
+
}
|
|
32
|
+
export interface ThrottleMessage {
|
|
33
|
+
type: 'throttle';
|
|
34
|
+
guid?: string;
|
|
35
|
+
topic?: string;
|
|
36
|
+
throttle: number;
|
|
37
|
+
}
|
|
38
|
+
export interface JobMessageCallback {
|
|
39
|
+
(topic: string, message: JobOutput): void;
|
|
40
|
+
}
|
|
41
|
+
export interface SubscriptionCallback {
|
|
42
|
+
(topic: string, message: Record<string, any>): void;
|
|
43
|
+
}
|
|
44
|
+
export interface QuorumMessageCallback {
|
|
45
|
+
(topic: string, message: QuorumMessage): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RedisClassType, RedisClientType as RCT, RedisMultiType as RMT, RedisClientOptions as RCO } from './redisclient';
|
|
2
|
+
import { RedisClassType as IORRedisClassType, RedisClientType as IORCT, RedisMultiType as IORMT, RedisClientOptions as IORCO } from './ioredisclient';
|
|
3
|
+
type RedisClass = RedisClassType | IORRedisClassType;
|
|
4
|
+
type RedisClient = RCT | IORCT;
|
|
5
|
+
type RedisMulti = RMT | IORMT;
|
|
6
|
+
type RedisOptions = RCO | IORCO;
|
|
7
|
+
type MultiResponseFlags = (string | number)[];
|
|
8
|
+
export { RedisClass, RedisClient, RedisMulti, RedisOptions, MultiResponseFlags, };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createClient, RedisClientOptions } from 'redis';
|
|
2
|
+
type RedisClientType = ReturnType<typeof createClient>;
|
|
3
|
+
interface RedisMultiType {
|
|
4
|
+
XADD(key: string, id: string, fields: any): this;
|
|
5
|
+
XACK(key: string, group: string, id: string): this;
|
|
6
|
+
XDEL(key: string, id: string): this;
|
|
7
|
+
HDEL(key: string, itemId: string): this;
|
|
8
|
+
HGET(key: string, itemId: string): this;
|
|
9
|
+
HGETALL(key: string): this;
|
|
10
|
+
HINCRBYFLOAT(key: string, itemId: string, value: number): this;
|
|
11
|
+
HMGET(key: string, itemIds: string[]): this;
|
|
12
|
+
HSET(key: string, values: Record<string, string>): this;
|
|
13
|
+
LRANGE(key: string, start: number, end: number): this;
|
|
14
|
+
RPUSH(key: string, value: string): this;
|
|
15
|
+
ZADD(key: string, values: {
|
|
16
|
+
score: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}): this;
|
|
19
|
+
sendCommand(command: string[]): Promise<any>;
|
|
20
|
+
exec: () => Promise<unknown[]>;
|
|
21
|
+
}
|
|
22
|
+
type RedisClassType = {
|
|
23
|
+
createClient: (options: RedisClientOptions) => any;
|
|
24
|
+
};
|
|
25
|
+
export { RedisClassType, RedisClientType, RedisMultiType, RedisClientOptions, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface JSONSchema {
|
|
2
|
+
type?: string;
|
|
3
|
+
enum?: string[];
|
|
4
|
+
examples?: any[];
|
|
5
|
+
properties?: {
|
|
6
|
+
[key: string]: JSONSchema;
|
|
7
|
+
};
|
|
8
|
+
items?: JSONSchema;
|
|
9
|
+
description?: string;
|
|
10
|
+
'x-train'?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type SymbolRanges = {
|
|
13
|
+
[key: string]: number;
|
|
14
|
+
};
|
|
15
|
+
export type Symbols = {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
export type SymbolSets = {
|
|
19
|
+
[key: string]: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type StringStringType = {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
};
|
|
26
|
+
export type StringAnyType = {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
export type StringScalarType = {
|
|
30
|
+
[key: string]: boolean | number | string;
|
|
31
|
+
};
|
|
32
|
+
export type SymbolMap = Map<string, string>;
|
|
33
|
+
export type SymbolMaps = Map<string, SymbolMap>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
type MetricTypes = 'count' | 'sum' | 'avg' | 'mdn' | 'max' | 'min' | 'index';
|
|
2
|
+
interface StatType {
|
|
3
|
+
target: string;
|
|
4
|
+
metric: MetricTypes;
|
|
5
|
+
value: number | string;
|
|
6
|
+
}
|
|
7
|
+
interface Measure {
|
|
8
|
+
target: string;
|
|
9
|
+
type: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}
|
|
12
|
+
interface Segment {
|
|
13
|
+
time: string;
|
|
14
|
+
count: number;
|
|
15
|
+
measures: Measure[];
|
|
16
|
+
}
|
|
17
|
+
interface StatsType {
|
|
18
|
+
general: StatType[];
|
|
19
|
+
index: StatType[];
|
|
20
|
+
median: StatType[];
|
|
21
|
+
}
|
|
22
|
+
interface JobStats {
|
|
23
|
+
count?: number;
|
|
24
|
+
[field: string]: number;
|
|
25
|
+
}
|
|
26
|
+
interface JobStatsRange {
|
|
27
|
+
[key: string]: JobStats;
|
|
28
|
+
}
|
|
29
|
+
interface JobStatsInput {
|
|
30
|
+
data: Record<string, unknown>;
|
|
31
|
+
range?: string;
|
|
32
|
+
start?: string;
|
|
33
|
+
end?: string;
|
|
34
|
+
sparse?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface GetStatsOptions {
|
|
37
|
+
key: string;
|
|
38
|
+
granularity: string;
|
|
39
|
+
range?: string;
|
|
40
|
+
start?: string;
|
|
41
|
+
end?: string;
|
|
42
|
+
sparse?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface StatsResponse {
|
|
45
|
+
key: string;
|
|
46
|
+
granularity: string;
|
|
47
|
+
range: string;
|
|
48
|
+
end: string | Date;
|
|
49
|
+
count: number;
|
|
50
|
+
measures: Measure[];
|
|
51
|
+
segments?: Segment[];
|
|
52
|
+
}
|
|
53
|
+
interface AggregatedData {
|
|
54
|
+
[key: string]: number;
|
|
55
|
+
}
|
|
56
|
+
interface IdsData {
|
|
57
|
+
[target: string]: string[];
|
|
58
|
+
}
|
|
59
|
+
interface MeasureIds {
|
|
60
|
+
time: string;
|
|
61
|
+
target: string;
|
|
62
|
+
count: number;
|
|
63
|
+
type: 'ids';
|
|
64
|
+
ids: string[];
|
|
65
|
+
}
|
|
66
|
+
interface TimeSegment {
|
|
67
|
+
time: string;
|
|
68
|
+
measures: MeasureIds[];
|
|
69
|
+
}
|
|
70
|
+
interface CountByFacet {
|
|
71
|
+
facet: string;
|
|
72
|
+
count: number;
|
|
73
|
+
}
|
|
74
|
+
interface IdsResponse {
|
|
75
|
+
key: string;
|
|
76
|
+
facets: string[];
|
|
77
|
+
granularity: string;
|
|
78
|
+
range: string;
|
|
79
|
+
start: string;
|
|
80
|
+
counts: CountByFacet[];
|
|
81
|
+
segments: TimeSegment[];
|
|
82
|
+
}
|
|
83
|
+
export { StatsType, StatType, MetricTypes, JobStats, JobStatsRange, JobStatsInput, GetStatsOptions, StatsResponse, AggregatedData, Measure, Segment, IdsData, MeasureIds, TimeSegment, IdsResponse, CountByFacet };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface StreamRetryPolicy {
|
|
2
|
+
[key: string]: [number, 'x'];
|
|
3
|
+
}
|
|
4
|
+
export type StreamCode = number;
|
|
5
|
+
export type StreamError = {
|
|
6
|
+
message: string;
|
|
7
|
+
code: number;
|
|
8
|
+
job_id?: string;
|
|
9
|
+
stack?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
error?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export declare enum StreamStatus {
|
|
14
|
+
SUCCESS = "success",
|
|
15
|
+
ERROR = "error",
|
|
16
|
+
PENDING = "pending"
|
|
17
|
+
}
|
|
18
|
+
export declare enum StreamDataType {
|
|
19
|
+
TIMEHOOK = "timehook",
|
|
20
|
+
WEBHOOK = "webhook",
|
|
21
|
+
AWAIT = "await",
|
|
22
|
+
RESULT = "result",
|
|
23
|
+
WORKER = "worker",
|
|
24
|
+
RESPONSE = "response",
|
|
25
|
+
TRANSITION = "transition"
|
|
26
|
+
}
|
|
27
|
+
export interface StreamData {
|
|
28
|
+
metadata: {
|
|
29
|
+
topic?: string;
|
|
30
|
+
jid?: string;
|
|
31
|
+
dad?: string;
|
|
32
|
+
aid: string;
|
|
33
|
+
trc?: string;
|
|
34
|
+
spn?: string;
|
|
35
|
+
try?: number;
|
|
36
|
+
};
|
|
37
|
+
type?: StreamDataType;
|
|
38
|
+
data: Record<string, unknown>;
|
|
39
|
+
policies?: {
|
|
40
|
+
retry?: StreamRetryPolicy;
|
|
41
|
+
};
|
|
42
|
+
status?: StreamStatus;
|
|
43
|
+
code?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface StreamDataResponse extends StreamData {
|
|
46
|
+
}
|
|
47
|
+
export declare enum StreamRole {
|
|
48
|
+
WORKER = "worker",
|
|
49
|
+
ENGINE = "engine",
|
|
50
|
+
SYSTEM = "system"
|
|
51
|
+
}
|
|
52
|
+
export type ReclaimedMessageType = [
|
|
53
|
+
messageId: string,
|
|
54
|
+
details: [
|
|
55
|
+
key: string,
|
|
56
|
+
value: string
|
|
57
|
+
]
|
|
58
|
+
][];
|
|
59
|
+
export type StreamConfig = {
|
|
60
|
+
namespace: string;
|
|
61
|
+
appId: string;
|
|
62
|
+
guid: string;
|
|
63
|
+
role: StreamRole;
|
|
64
|
+
topic?: string;
|
|
65
|
+
reclaimDelay?: number;
|
|
66
|
+
reclaimCount?: number;
|
|
67
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamRole = exports.StreamDataType = exports.StreamStatus = void 0;
|
|
4
|
+
var StreamStatus;
|
|
5
|
+
(function (StreamStatus) {
|
|
6
|
+
StreamStatus["SUCCESS"] = "success";
|
|
7
|
+
StreamStatus["ERROR"] = "error";
|
|
8
|
+
StreamStatus["PENDING"] = "pending";
|
|
9
|
+
})(StreamStatus = exports.StreamStatus || (exports.StreamStatus = {}));
|
|
10
|
+
var StreamDataType;
|
|
11
|
+
(function (StreamDataType) {
|
|
12
|
+
StreamDataType["TIMEHOOK"] = "timehook";
|
|
13
|
+
StreamDataType["WEBHOOK"] = "webhook";
|
|
14
|
+
StreamDataType["AWAIT"] = "await";
|
|
15
|
+
StreamDataType["RESULT"] = "result";
|
|
16
|
+
StreamDataType["WORKER"] = "worker";
|
|
17
|
+
StreamDataType["RESPONSE"] = "response";
|
|
18
|
+
StreamDataType["TRANSITION"] = "transition";
|
|
19
|
+
})(StreamDataType = exports.StreamDataType || (exports.StreamDataType = {}));
|
|
20
|
+
var StreamRole;
|
|
21
|
+
(function (StreamRole) {
|
|
22
|
+
StreamRole["WORKER"] = "worker";
|
|
23
|
+
StreamRole["ENGINE"] = "engine";
|
|
24
|
+
StreamRole["SYSTEM"] = "system";
|
|
25
|
+
})(StreamRole = exports.StreamRole || (exports.StreamRole = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { context, Context, Counter, Meter, metrics, propagation, SpanContext, Span, SpanStatus, SpanStatusCode, SpanKind, trace, Tracer, ValueType } from '@opentelemetry/api';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValueType = exports.trace = exports.SpanKind = exports.SpanStatusCode = exports.propagation = exports.metrics = exports.context = void 0;
|
|
4
|
+
var api_1 = require("@opentelemetry/api");
|
|
5
|
+
Object.defineProperty(exports, "context", { enumerable: true, get: function () { return api_1.context; } });
|
|
6
|
+
Object.defineProperty(exports, "metrics", { enumerable: true, get: function () { return api_1.metrics; } });
|
|
7
|
+
Object.defineProperty(exports, "propagation", { enumerable: true, get: function () { return api_1.propagation; } });
|
|
8
|
+
Object.defineProperty(exports, "SpanStatusCode", { enumerable: true, get: function () { return api_1.SpanStatusCode; } });
|
|
9
|
+
Object.defineProperty(exports, "SpanKind", { enumerable: true, get: function () { return api_1.SpanKind; } });
|
|
10
|
+
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return api_1.trace; } });
|
|
11
|
+
Object.defineProperty(exports, "ValueType", { enumerable: true, get: function () { return api_1.ValueType; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Pipe } from "./pipe";
|
|
2
|
+
export type TransitionMatch = {
|
|
3
|
+
expected: boolean | string | number | null;
|
|
4
|
+
actual: boolean | string | number | null | {
|
|
5
|
+
'@pipe': Pipe;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type TransitionRule = {
|
|
9
|
+
gate?: 'and' | 'or';
|
|
10
|
+
code?: string;
|
|
11
|
+
match: Array<TransitionMatch>;
|
|
12
|
+
};
|
|
13
|
+
export type Transitions = {
|
|
14
|
+
[key: string]: {
|
|
15
|
+
[key: string]: TransitionRule;
|
|
16
|
+
};
|
|
17
|
+
};
|
package/index.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ActivityDuplex } from "../types/activity";
|
|
2
|
+
import { CollationFaultType, CollationStage } from "../types/collator";
|
|
3
|
+
|
|
4
|
+
class GetStateError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Error occurred while getting job state");
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
class SetStateError extends Error {
|
|
10
|
+
constructor() {
|
|
11
|
+
super("Error occurred while setting job state");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class MapDataError extends Error {
|
|
16
|
+
constructor() {
|
|
17
|
+
super("Error occurred while mapping data");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class RegisterTimeoutError extends Error {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("Error occurred while registering activity timeout");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class DuplicateJobError extends Error {
|
|
28
|
+
constructor(jobId: string) {
|
|
29
|
+
super("Duplicate job");
|
|
30
|
+
this.message = `Duplicate job: ${jobId}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class ExecActivityError extends Error {
|
|
35
|
+
constructor() {
|
|
36
|
+
super("Error occurred while executing activity");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class CollationError extends Error {
|
|
41
|
+
status: number; //15-digit activity collation integer (889000001000001)
|
|
42
|
+
leg: ActivityDuplex;
|
|
43
|
+
stage: CollationStage; //enter | exit | confirm
|
|
44
|
+
fault: CollationFaultType; //missing, invalid, etc
|
|
45
|
+
|
|
46
|
+
constructor(status: number, leg: ActivityDuplex, stage: CollationStage, fault?: CollationFaultType) {
|
|
47
|
+
super("collation-error");
|
|
48
|
+
this.leg = leg;
|
|
49
|
+
this.status = status;
|
|
50
|
+
this.stage = stage;
|
|
51
|
+
this.fault = fault;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { CollationError, DuplicateJobError, GetStateError, SetStateError, MapDataError, RegisterTimeoutError, ExecActivityError };
|