@hotmeshio/hotmesh 0.0.8 → 0.0.9
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 +4 -7
- package/README.md +37 -46
- package/build/{esm/package.json → package.json} +4 -11
- package/build/{cjs/services → services}/durable/native.js +2 -2
- package/build/{esm/services → services}/durable/worker.d.ts +1 -3
- package/build/{cjs/services → services}/durable/worker.js +9 -32
- package/build/{cjs/services → services}/durable/workflow.js +6 -1
- package/build/{cjs/types → types}/durable.d.ts +4 -6
- package/package.json +4 -11
- package/services/durable/native.ts +2 -2
- package/services/durable/worker.ts +9 -9
- package/services/durable/workflow.ts +7 -1
- package/types/durable.ts +4 -4
- package/build/cjs/package.json +0 -82
- package/build/cjs/services/durable/worker.d.ts +0 -38
- package/build/esm/index.d.ts +0 -4
- package/build/esm/index.js +0 -3
- package/build/esm/modules/errors.d.ts +0 -28
- package/build/esm/modules/errors.js +0 -41
- package/build/esm/modules/key.d.ts +0 -75
- package/build/esm/modules/key.js +0 -111
- package/build/esm/modules/utils.d.ts +0 -34
- package/build/esm/modules/utils.js +0 -154
- package/build/esm/services/activities/activity.d.ts +0 -67
- package/build/esm/services/activities/activity.js +0 -486
- package/build/esm/services/activities/await.d.ts +0 -16
- package/build/esm/services/activities/await.js +0 -140
- package/build/esm/services/activities/cycle.d.ts +0 -19
- package/build/esm/services/activities/cycle.js +0 -74
- package/build/esm/services/activities/emit.d.ts +0 -9
- package/build/esm/services/activities/emit.js +0 -10
- package/build/esm/services/activities/index.d.ts +0 -17
- package/build/esm/services/activities/index.js +0 -16
- package/build/esm/services/activities/iterate.d.ts +0 -9
- package/build/esm/services/activities/iterate.js +0 -10
- package/build/esm/services/activities/trigger.d.ts +0 -22
- package/build/esm/services/activities/trigger.js +0 -158
- package/build/esm/services/activities/worker.d.ts +0 -11
- package/build/esm/services/activities/worker.js +0 -70
- package/build/esm/services/collator/index.d.ts +0 -73
- package/build/esm/services/collator/index.js +0 -221
- package/build/esm/services/compiler/deployer.d.ts +0 -36
- package/build/esm/services/compiler/deployer.js +0 -423
- package/build/esm/services/compiler/index.d.ts +0 -30
- package/build/esm/services/compiler/index.js +0 -82
- package/build/esm/services/compiler/validator.d.ts +0 -32
- package/build/esm/services/compiler/validator.js +0 -131
- package/build/esm/services/connector/clients/ioredis.d.ts +0 -13
- package/build/esm/services/connector/clients/ioredis.js +0 -47
- package/build/esm/services/connector/clients/redis.d.ts +0 -13
- package/build/esm/services/connector/clients/redis.js +0 -59
- package/build/esm/services/connector/index.d.ts +0 -5
- package/build/esm/services/connector/index.js +0 -27
- package/build/esm/services/dimension/index.d.ts +0 -29
- package/build/esm/services/dimension/index.js +0 -32
- package/build/esm/services/durable/asyncLocalStorage.d.ts +0 -3
- package/build/esm/services/durable/asyncLocalStorage.js +0 -2
- package/build/esm/services/durable/client.d.ts +0 -15
- package/build/esm/services/durable/client.js +0 -114
- package/build/esm/services/durable/connection.d.ts +0 -4
- package/build/esm/services/durable/connection.js +0 -47
- package/build/esm/services/durable/factory.d.ts +0 -3
- package/build/esm/services/durable/factory.js +0 -135
- package/build/esm/services/durable/handle.d.ts +0 -8
- package/build/esm/services/durable/handle.js +0 -34
- package/build/esm/services/durable/index.d.ts +0 -57
- package/build/esm/services/durable/index.js +0 -55
- package/build/esm/services/durable/native.d.ts +0 -4
- package/build/esm/services/durable/native.js +0 -43
- package/build/esm/services/durable/worker.js +0 -267
- package/build/esm/services/durable/workflow.d.ts +0 -6
- package/build/esm/services/durable/workflow.js +0 -132
- package/build/esm/services/engine/index.d.ts +0 -82
- package/build/esm/services/engine/index.js +0 -522
- package/build/esm/services/hotmesh/index.d.ts +0 -45
- package/build/esm/services/hotmesh/index.js +0 -131
- package/build/esm/services/logger/index.d.ts +0 -17
- package/build/esm/services/logger/index.js +0 -70
- package/build/esm/services/mapper/index.d.ts +0 -24
- package/build/esm/services/mapper/index.js +0 -72
- package/build/esm/services/pipe/functions/array.d.ts +0 -24
- package/build/esm/services/pipe/functions/array.js +0 -66
- package/build/esm/services/pipe/functions/bitwise.d.ts +0 -9
- package/build/esm/services/pipe/functions/bitwise.js +0 -21
- package/build/esm/services/pipe/functions/conditional.d.ts +0 -10
- package/build/esm/services/pipe/functions/conditional.js +0 -24
- package/build/esm/services/pipe/functions/date.d.ts +0 -57
- package/build/esm/services/pipe/functions/date.js +0 -164
- package/build/esm/services/pipe/functions/index.d.ts +0 -25
- package/build/esm/services/pipe/functions/index.js +0 -24
- package/build/esm/services/pipe/functions/json.d.ts +0 -5
- package/build/esm/services/pipe/functions/json.js +0 -9
- package/build/esm/services/pipe/functions/math.d.ts +0 -38
- package/build/esm/services/pipe/functions/math.js +0 -108
- package/build/esm/services/pipe/functions/number.d.ts +0 -25
- package/build/esm/services/pipe/functions/number.js +0 -130
- package/build/esm/services/pipe/functions/object.d.ts +0 -22
- package/build/esm/services/pipe/functions/object.js +0 -60
- package/build/esm/services/pipe/functions/string.d.ts +0 -23
- package/build/esm/services/pipe/functions/string.js +0 -66
- package/build/esm/services/pipe/functions/symbol.d.ts +0 -12
- package/build/esm/services/pipe/functions/symbol.js +0 -30
- package/build/esm/services/pipe/functions/unary.d.ts +0 -7
- package/build/esm/services/pipe/functions/unary.js +0 -15
- package/build/esm/services/pipe/index.d.ts +0 -30
- package/build/esm/services/pipe/index.js +0 -122
- package/build/esm/services/quorum/index.d.ts +0 -34
- package/build/esm/services/quorum/index.js +0 -144
- package/build/esm/services/reporter/index.d.ts +0 -47
- package/build/esm/services/reporter/index.js +0 -327
- package/build/esm/services/serializer/index.d.ts +0 -41
- package/build/esm/services/serializer/index.js +0 -251
- package/build/esm/services/signaler/store.d.ts +0 -15
- package/build/esm/services/signaler/store.js +0 -50
- package/build/esm/services/signaler/stream.d.ts +0 -43
- package/build/esm/services/signaler/stream.js +0 -314
- package/build/esm/services/store/cache.d.ts +0 -66
- package/build/esm/services/store/cache.js +0 -124
- package/build/esm/services/store/clients/ioredis.d.ts +0 -27
- package/build/esm/services/store/clients/ioredis.js +0 -93
- package/build/esm/services/store/clients/redis.d.ts +0 -29
- package/build/esm/services/store/clients/redis.js +0 -140
- package/build/esm/services/store/index.d.ts +0 -88
- package/build/esm/services/store/index.js +0 -623
- package/build/esm/services/stream/clients/ioredis.d.ts +0 -23
- package/build/esm/services/stream/clients/ioredis.js +0 -112
- package/build/esm/services/stream/clients/redis.d.ts +0 -23
- package/build/esm/services/stream/clients/redis.js +0 -116
- package/build/esm/services/stream/index.d.ts +0 -21
- package/build/esm/services/stream/index.js +0 -6
- package/build/esm/services/sub/clients/ioredis.d.ts +0 -20
- package/build/esm/services/sub/clients/ioredis.js +0 -69
- package/build/esm/services/sub/clients/redis.d.ts +0 -20
- package/build/esm/services/sub/clients/redis.js +0 -60
- package/build/esm/services/sub/index.d.ts +0 -18
- package/build/esm/services/sub/index.js +0 -6
- package/build/esm/services/task/index.d.ts +0 -18
- package/build/esm/services/task/index.js +0 -70
- package/build/esm/services/telemetry/index.d.ts +0 -49
- package/build/esm/services/telemetry/index.js +0 -217
- package/build/esm/services/worker/index.d.ts +0 -30
- package/build/esm/services/worker/index.js +0 -102
- package/build/esm/types/activity.d.ts +0 -92
- package/build/esm/types/activity.js +0 -1
- package/build/esm/types/app.d.ts +0 -16
- package/build/esm/types/app.js +0 -1
- package/build/esm/types/async.d.ts +0 -5
- package/build/esm/types/async.js +0 -1
- package/build/esm/types/cache.d.ts +0 -1
- package/build/esm/types/cache.js +0 -1
- package/build/esm/types/collator.d.ts +0 -8
- package/build/esm/types/collator.js +0 -8
- package/build/esm/types/durable.d.ts +0 -59
- package/build/esm/types/durable.js +0 -1
- package/build/esm/types/hook.d.ts +0 -31
- package/build/esm/types/hook.js +0 -6
- package/build/esm/types/hotmesh.d.ts +0 -82
- package/build/esm/types/hotmesh.js +0 -1
- package/build/esm/types/index.d.ts +0 -20
- package/build/esm/types/index.js +0 -5
- package/build/esm/types/ioredisclient.d.ts +0 -5
- package/build/esm/types/ioredisclient.js +0 -2
- package/build/esm/types/job.d.ts +0 -50
- package/build/esm/types/job.js +0 -1
- package/build/esm/types/logger.d.ts +0 -6
- package/build/esm/types/logger.js +0 -1
- package/build/esm/types/map.d.ts +0 -4
- package/build/esm/types/map.js +0 -1
- package/build/esm/types/pipe.d.ts +0 -4
- package/build/esm/types/pipe.js +0 -1
- package/build/esm/types/quorum.d.ts +0 -46
- package/build/esm/types/quorum.js +0 -1
- package/build/esm/types/redis.d.ts +0 -8
- package/build/esm/types/redis.js +0 -1
- package/build/esm/types/redisclient.d.ts +0 -25
- package/build/esm/types/redisclient.js +0 -1
- package/build/esm/types/serializer.d.ts +0 -33
- package/build/esm/types/serializer.js +0 -1
- package/build/esm/types/stats.d.ts +0 -83
- package/build/esm/types/stats.js +0 -1
- package/build/esm/types/stream.d.ts +0 -67
- package/build/esm/types/stream.js +0 -22
- package/build/esm/types/telemetry.d.ts +0 -1
- package/build/esm/types/telemetry.js +0 -1
- package/build/esm/types/transition.d.ts +0 -17
- package/build/esm/types/transition.js +0 -1
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -9
- /package/build/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/build/{cjs/index.js → index.js} +0 -0
- /package/build/{cjs/modules → modules}/errors.d.ts +0 -0
- /package/build/{cjs/modules → modules}/errors.js +0 -0
- /package/build/{cjs/modules → modules}/key.d.ts +0 -0
- /package/build/{cjs/modules → modules}/key.js +0 -0
- /package/build/{cjs/modules → modules}/utils.d.ts +0 -0
- /package/build/{cjs/modules → modules}/utils.js +0 -0
- /package/build/{cjs/services → services}/activities/activity.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/activity.js +0 -0
- /package/build/{cjs/services → services}/activities/await.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/await.js +0 -0
- /package/build/{cjs/services → services}/activities/cycle.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/cycle.js +0 -0
- /package/build/{cjs/services → services}/activities/emit.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/emit.js +0 -0
- /package/build/{cjs/services → services}/activities/index.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/index.js +0 -0
- /package/build/{cjs/services → services}/activities/iterate.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/iterate.js +0 -0
- /package/build/{cjs/services → services}/activities/trigger.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/trigger.js +0 -0
- /package/build/{cjs/services → services}/activities/worker.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/worker.js +0 -0
- /package/build/{cjs/services → services}/collator/index.d.ts +0 -0
- /package/build/{cjs/services → services}/collator/index.js +0 -0
- /package/build/{cjs/services → services}/compiler/deployer.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/deployer.js +0 -0
- /package/build/{cjs/services → services}/compiler/index.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/index.js +0 -0
- /package/build/{cjs/services → services}/compiler/validator.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/validator.js +0 -0
- /package/build/{cjs/services → services}/connector/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/connector/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/connector/index.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/index.js +0 -0
- /package/build/{cjs/services → services}/dimension/index.d.ts +0 -0
- /package/build/{cjs/services → services}/dimension/index.js +0 -0
- /package/build/{cjs/services → services}/durable/asyncLocalStorage.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/asyncLocalStorage.js +0 -0
- /package/build/{cjs/services → services}/durable/client.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/client.js +0 -0
- /package/build/{cjs/services → services}/durable/connection.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/connection.js +0 -0
- /package/build/{cjs/services → services}/durable/factory.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/factory.js +0 -0
- /package/build/{cjs/services → services}/durable/handle.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/handle.js +0 -0
- /package/build/{cjs/services → services}/durable/index.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/index.js +0 -0
- /package/build/{cjs/services → services}/durable/native.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/workflow.d.ts +0 -0
- /package/build/{cjs/services → services}/engine/index.d.ts +0 -0
- /package/build/{cjs/services → services}/engine/index.js +0 -0
- /package/build/{cjs/services → services}/hotmesh/index.d.ts +0 -0
- /package/build/{cjs/services → services}/hotmesh/index.js +0 -0
- /package/build/{cjs/services → services}/logger/index.d.ts +0 -0
- /package/build/{cjs/services → services}/logger/index.js +0 -0
- /package/build/{cjs/services → services}/mapper/index.d.ts +0 -0
- /package/build/{cjs/services → services}/mapper/index.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/array.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/array.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/bitwise.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/bitwise.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/conditional.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/conditional.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/date.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/date.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/index.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/json.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/json.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/math.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/math.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/number.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/number.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/object.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/object.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/string.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/string.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/symbol.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/symbol.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/unary.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/unary.js +0 -0
- /package/build/{cjs/services → services}/pipe/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/index.js +0 -0
- /package/build/{cjs/services → services}/quorum/index.d.ts +0 -0
- /package/build/{cjs/services → services}/quorum/index.js +0 -0
- /package/build/{cjs/services → services}/reporter/index.d.ts +0 -0
- /package/build/{cjs/services → services}/reporter/index.js +0 -0
- /package/build/{cjs/services → services}/serializer/index.d.ts +0 -0
- /package/build/{cjs/services → services}/serializer/index.js +0 -0
- /package/build/{cjs/services → services}/signaler/store.d.ts +0 -0
- /package/build/{cjs/services → services}/signaler/store.js +0 -0
- /package/build/{cjs/services → services}/signaler/stream.d.ts +0 -0
- /package/build/{cjs/services → services}/signaler/stream.js +0 -0
- /package/build/{cjs/services → services}/store/cache.d.ts +0 -0
- /package/build/{cjs/services → services}/store/cache.js +0 -0
- /package/build/{cjs/services → services}/store/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/store/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/store/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/store/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/store/index.d.ts +0 -0
- /package/build/{cjs/services → services}/store/index.js +0 -0
- /package/build/{cjs/services → services}/stream/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/stream/index.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/index.js +0 -0
- /package/build/{cjs/services → services}/sub/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/sub/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/sub/index.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/index.js +0 -0
- /package/build/{cjs/services → services}/task/index.d.ts +0 -0
- /package/build/{cjs/services → services}/task/index.js +0 -0
- /package/build/{cjs/services → services}/telemetry/index.d.ts +0 -0
- /package/build/{cjs/services → services}/telemetry/index.js +0 -0
- /package/build/{cjs/services → services}/worker/index.d.ts +0 -0
- /package/build/{cjs/services → services}/worker/index.js +0 -0
- /package/build/{cjs/types → types}/activity.d.ts +0 -0
- /package/build/{cjs/types → types}/activity.js +0 -0
- /package/build/{cjs/types → types}/app.d.ts +0 -0
- /package/build/{cjs/types → types}/app.js +0 -0
- /package/build/{cjs/types → types}/async.d.ts +0 -0
- /package/build/{cjs/types → types}/async.js +0 -0
- /package/build/{cjs/types → types}/cache.d.ts +0 -0
- /package/build/{cjs/types → types}/cache.js +0 -0
- /package/build/{cjs/types → types}/collator.d.ts +0 -0
- /package/build/{cjs/types → types}/collator.js +0 -0
- /package/build/{cjs/types → types}/durable.js +0 -0
- /package/build/{cjs/types → types}/hook.d.ts +0 -0
- /package/build/{cjs/types → types}/hook.js +0 -0
- /package/build/{cjs/types → types}/hotmesh.d.ts +0 -0
- /package/build/{cjs/types → types}/hotmesh.js +0 -0
- /package/build/{cjs/types → types}/index.d.ts +0 -0
- /package/build/{cjs/types → types}/index.js +0 -0
- /package/build/{cjs/types → types}/ioredisclient.d.ts +0 -0
- /package/build/{cjs/types → types}/ioredisclient.js +0 -0
- /package/build/{cjs/types → types}/job.d.ts +0 -0
- /package/build/{cjs/types → types}/job.js +0 -0
- /package/build/{cjs/types → types}/logger.d.ts +0 -0
- /package/build/{cjs/types → types}/logger.js +0 -0
- /package/build/{cjs/types → types}/map.d.ts +0 -0
- /package/build/{cjs/types → types}/map.js +0 -0
- /package/build/{cjs/types → types}/pipe.d.ts +0 -0
- /package/build/{cjs/types → types}/pipe.js +0 -0
- /package/build/{cjs/types → types}/quorum.d.ts +0 -0
- /package/build/{cjs/types → types}/quorum.js +0 -0
- /package/build/{cjs/types → types}/redis.d.ts +0 -0
- /package/build/{cjs/types → types}/redis.js +0 -0
- /package/build/{cjs/types → types}/redisclient.d.ts +0 -0
- /package/build/{cjs/types → types}/redisclient.js +0 -0
- /package/build/{cjs/types → types}/serializer.d.ts +0 -0
- /package/build/{cjs/types → types}/serializer.js +0 -0
- /package/build/{cjs/types → types}/stats.d.ts +0 -0
- /package/build/{cjs/types → types}/stats.js +0 -0
- /package/build/{cjs/types → types}/stream.d.ts +0 -0
- /package/build/{cjs/types → types}/stream.js +0 -0
- /package/build/{cjs/types → types}/telemetry.d.ts +0 -0
- /package/build/{cjs/types → types}/telemetry.js +0 -0
- /package/build/{cjs/types → types}/transition.d.ts +0 -0
- /package/build/{cjs/types → types}/transition.js +0 -0
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { CollationError } from '../../modules/errors';
|
|
2
|
-
import { CollationFaultType } from '../../types/collator';
|
|
3
|
-
class CollatorService {
|
|
4
|
-
/**
|
|
5
|
-
* returns the dimensional address (dad) for the target; due
|
|
6
|
-
* to the nature of the notary system, the dad for leg 2 entry
|
|
7
|
-
* must target the `0` index while leg 2 exit must target the
|
|
8
|
-
* current index (0)
|
|
9
|
-
*/
|
|
10
|
-
static getDimensionalAddress(activity, isEntry = false) {
|
|
11
|
-
let dad = activity.context.metadata.dad || activity.metadata.dad;
|
|
12
|
-
if (isEntry && dad && activity.leg === 2) {
|
|
13
|
-
dad = `${dad.substring(0, dad.lastIndexOf(','))},0`;
|
|
14
|
-
}
|
|
15
|
-
return CollatorService.getDimensionsById([...activity.config.ancestors, activity.metadata.aid], dad);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* resolves the dimensional address for the
|
|
19
|
-
* ancestor in the graph to go back to. this address
|
|
20
|
-
* is determined by trimming the last digits from
|
|
21
|
-
* the `dad` (including the target).
|
|
22
|
-
* the target activity index is then set to `0`, so that
|
|
23
|
-
* the origin node can be queried for approval/entry.
|
|
24
|
-
*/
|
|
25
|
-
static resolveReentryDimension(activity) {
|
|
26
|
-
const targetActivityId = activity.config.ancestor;
|
|
27
|
-
const ancestors = activity.config.ancestors;
|
|
28
|
-
const ancestorIndex = ancestors.indexOf(targetActivityId);
|
|
29
|
-
const dimensions = activity.metadata.dad.split(','); //e.g., `,0,0,1,0`
|
|
30
|
-
dimensions.length = ancestorIndex + 1;
|
|
31
|
-
dimensions.push('0');
|
|
32
|
-
return dimensions.join(',');
|
|
33
|
-
}
|
|
34
|
-
static async notarizeEntry(activity, multi) {
|
|
35
|
-
//decrement by -100_000_000_000_000
|
|
36
|
-
const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -100000000000000, this.getDimensionalAddress(activity), multi);
|
|
37
|
-
this.verifyInteger(amount, 1, 'enter');
|
|
38
|
-
return amount;
|
|
39
|
-
}
|
|
40
|
-
;
|
|
41
|
-
static async authorizeReentry(activity, multi) {
|
|
42
|
-
//set second digit to 8, allowing for re-entry
|
|
43
|
-
//decrement by -10_000_000_000_000
|
|
44
|
-
const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -10000000000000, this.getDimensionalAddress(activity), multi);
|
|
45
|
-
//this.verifyInteger(amount, 1, 'exit');
|
|
46
|
-
return amount;
|
|
47
|
-
}
|
|
48
|
-
static async notarizeEarlyExit(activity, multi) {
|
|
49
|
-
//decrement the 2nd and 3rd digits to fully deactivate (`cycle` activities use this command to fully exit after leg 1) (should result in `888000000000000`)
|
|
50
|
-
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -11000000000000, this.getDimensionalAddress(activity), multi);
|
|
51
|
-
}
|
|
52
|
-
;
|
|
53
|
-
static async notarizeEarlyCompletion(activity, multi) {
|
|
54
|
-
//initialize both `possible` (1m) and `actualized` (1) zero dimension, while decrementing the 2nd
|
|
55
|
-
//3rd digit is optionally kept open if the activity might be used in a cycle
|
|
56
|
-
const decrement = activity.config.cycle ? 10000000000000 : 11000000000000;
|
|
57
|
-
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1000001 - decrement, this.getDimensionalAddress(activity), multi);
|
|
58
|
-
}
|
|
59
|
-
;
|
|
60
|
-
static async notarizeReentry(activity, multi) {
|
|
61
|
-
//increment by 1_000_000 (indicates re-entry and is used to drive the 'dimensional address' for adjacent activities (minus 1))
|
|
62
|
-
const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1000000, this.getDimensionalAddress(activity, true), multi);
|
|
63
|
-
this.verifyInteger(amount, 2, 'enter');
|
|
64
|
-
return amount;
|
|
65
|
-
}
|
|
66
|
-
;
|
|
67
|
-
static async notarizeContinuation(activity, multi) {
|
|
68
|
-
//keep open; actualize the leg2 dimension (+1)
|
|
69
|
-
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1, this.getDimensionalAddress(activity), multi);
|
|
70
|
-
}
|
|
71
|
-
;
|
|
72
|
-
static async notarizeCompletion(activity, multi) {
|
|
73
|
-
//1) ALWAYS actualize leg2 dimension (+1)
|
|
74
|
-
//2) IF the activity is used in a cycle, don't close leg 2!
|
|
75
|
-
const decrement = activity.config.cycle ? 0 : -1000000000000;
|
|
76
|
-
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1 - decrement, this.getDimensionalAddress(activity), multi);
|
|
77
|
-
}
|
|
78
|
-
;
|
|
79
|
-
static getDigitAtIndex(num, targetDigitIndex) {
|
|
80
|
-
const numStr = num.toString();
|
|
81
|
-
if (targetDigitIndex < 0 || targetDigitIndex >= numStr.length) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
const digit = parseInt(numStr[targetDigitIndex], 10);
|
|
85
|
-
return digit;
|
|
86
|
-
}
|
|
87
|
-
static getDimensionalIndex(num) {
|
|
88
|
-
const numStr = num.toString();
|
|
89
|
-
if (numStr.length < 9) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
const extractedStr = numStr.substring(3, 9);
|
|
93
|
-
const extractedInt = parseInt(extractedStr, 10);
|
|
94
|
-
return extractedInt - 1;
|
|
95
|
-
}
|
|
96
|
-
static isDuplicate(num, targetDigitIndex) {
|
|
97
|
-
return this.getDigitAtIndex(num, targetDigitIndex) < 8;
|
|
98
|
-
}
|
|
99
|
-
static isInactive(num) {
|
|
100
|
-
return this.getDigitAtIndex(num, 2) < 9;
|
|
101
|
-
}
|
|
102
|
-
static isPrimed(amount, leg) {
|
|
103
|
-
//activity entry is not allowed if paths not properly pre-set
|
|
104
|
-
if (leg == 1) {
|
|
105
|
-
return amount != -100000000000000;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
return this.getDigitAtIndex(amount, 0) < 9 &&
|
|
109
|
-
this.getDigitAtIndex(amount, 1) < 9;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
static verifyInteger(amount, leg, stage) {
|
|
113
|
-
let faultType;
|
|
114
|
-
if (leg === 1 && stage === 'enter') {
|
|
115
|
-
if (!this.isPrimed(amount, 1)) {
|
|
116
|
-
faultType = CollationFaultType.MISSING;
|
|
117
|
-
}
|
|
118
|
-
else if (this.isDuplicate(amount, 0)) {
|
|
119
|
-
faultType = CollationFaultType.DUPLICATE;
|
|
120
|
-
}
|
|
121
|
-
else if (amount != 899000000000000) {
|
|
122
|
-
faultType = CollationFaultType.INVALID;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else if (leg === 1 && stage === 'exit') {
|
|
126
|
-
if (amount === -10000000000000) {
|
|
127
|
-
faultType = CollationFaultType.MISSING;
|
|
128
|
-
}
|
|
129
|
-
else if (this.isDuplicate(amount, 1)) {
|
|
130
|
-
faultType = CollationFaultType.DUPLICATE;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else if (leg === 2 && stage === 'enter') {
|
|
134
|
-
if (!this.isPrimed(amount, 2)) {
|
|
135
|
-
faultType = CollationFaultType.FORBIDDEN;
|
|
136
|
-
}
|
|
137
|
-
else if (this.isInactive(amount)) {
|
|
138
|
-
faultType = CollationFaultType.INACTIVE;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (faultType) {
|
|
142
|
-
throw new CollationError(amount, leg, stage, faultType);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
static getDimensionsById(ancestors, dad) {
|
|
146
|
-
//ancestors is an ordered list of all ancestors, starting with the trigger (['t1', 'a1', 'a2'])
|
|
147
|
-
//dad is the dimensional address of the ancestors list (',0,5,3')
|
|
148
|
-
//loop through the ancestors list and create a map of the ancestor to the dimensional address.
|
|
149
|
-
//return { 't1': ',0', 'a1': ',0,5', 'a1': ',0,5,3', $ADJACENT: ',0,5,3,0' };
|
|
150
|
-
// `adjacent` is a special key that is used to track the dimensional address of adjacent activities
|
|
151
|
-
const map = { '$ADJACENT': `${dad},0` };
|
|
152
|
-
let dadStr = dad;
|
|
153
|
-
ancestors.reverse().forEach((ancestor) => {
|
|
154
|
-
map[ancestor] = dadStr;
|
|
155
|
-
dadStr = dadStr.substring(0, dadStr.lastIndexOf(','));
|
|
156
|
-
});
|
|
157
|
-
return map;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* All non-trigger activities are assigned a status seed by their parent
|
|
161
|
-
*/
|
|
162
|
-
static getSeed() {
|
|
163
|
-
return '999000000000000';
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* All trigger activities are assigned a status seed in a completed state
|
|
167
|
-
*/
|
|
168
|
-
static getTriggerSeed() {
|
|
169
|
-
return '888000001000001';
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* entry point for compiler-type activities. This is called by the compiler
|
|
173
|
-
* to bind the sorted activity IDs to the trigger activity. These are then used
|
|
174
|
-
* at runtime by the activities to track job/activity status.
|
|
175
|
-
* @param graphs
|
|
176
|
-
*/
|
|
177
|
-
static compile(graphs) {
|
|
178
|
-
CollatorService.bindAncestorArray(graphs);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* binds the ancestor array to each activity.
|
|
182
|
-
* Used in conjunction with the dimensional
|
|
183
|
-
* address (dad). If dad is `,0,1,0,0` and the
|
|
184
|
-
* ancestor array is `['t1', 'a1', 'a2']` for
|
|
185
|
-
* activity 'a3', then the SAVED DAD
|
|
186
|
-
* will always have the trailing
|
|
187
|
-
* 0's removed. This ensures that the addressing
|
|
188
|
-
* remains consistent even if the graph changes.
|
|
189
|
-
* id DAD SAVED DAD
|
|
190
|
-
* * t1 => ,0 => [empty]
|
|
191
|
-
* * a1 => ,0,1 => ,0,1
|
|
192
|
-
* * a2 => ,0,1,0 => ,0,1
|
|
193
|
-
* * a3 => ,0,1,0,0 => ,0,1
|
|
194
|
-
*
|
|
195
|
-
*/
|
|
196
|
-
static bindAncestorArray(graphs) {
|
|
197
|
-
graphs.forEach((graph) => {
|
|
198
|
-
const ancestors = {};
|
|
199
|
-
const startingNode = Object.keys(graph.activities).find((activity) => graph.activities[activity].type === 'trigger');
|
|
200
|
-
if (!startingNode) {
|
|
201
|
-
throw new Error('collator-trigger-activity-not-found');
|
|
202
|
-
}
|
|
203
|
-
const dfs = (node, parentList) => {
|
|
204
|
-
ancestors[node] = parentList;
|
|
205
|
-
graph.activities[node]['ancestors'] = parentList;
|
|
206
|
-
const transitions = graph.transitions?.[node] || [];
|
|
207
|
-
transitions.forEach((transition) => {
|
|
208
|
-
dfs(transition.to, [...parentList, node]);
|
|
209
|
-
});
|
|
210
|
-
};
|
|
211
|
-
// Start the DFS traversal
|
|
212
|
-
dfs(startingNode, []);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
static isActivityComplete(status) {
|
|
216
|
-
return (status - 0) <= 0;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
//max int digit count that supports `hincrby`
|
|
220
|
-
CollatorService.targetLength = 15;
|
|
221
|
-
export { CollatorService };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { StoreService } from '../store';
|
|
2
|
-
import { HotMeshGraph, HotMeshManifest } from '../../types/hotmesh';
|
|
3
|
-
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
4
|
-
import { Symbols } from '../../types/serializer';
|
|
5
|
-
declare class Deployer {
|
|
6
|
-
manifest: HotMeshManifest | null;
|
|
7
|
-
store: StoreService<RedisClient, RedisMulti> | null;
|
|
8
|
-
constructor(manifest: HotMeshManifest);
|
|
9
|
-
deploy(store: StoreService<RedisClient, RedisMulti>): Promise<void>;
|
|
10
|
-
getVID(): {
|
|
11
|
-
id: string;
|
|
12
|
-
version: string;
|
|
13
|
-
};
|
|
14
|
-
generateSymKeys(): Promise<void>;
|
|
15
|
-
bindSelf(consumes: Record<string, string[]>, produces: string[], activityId: string): void;
|
|
16
|
-
bindSymbols(startIndex: number, maxIndex: number, existingSymbols: Symbols, prefix: string, produces: string[]): Symbols;
|
|
17
|
-
copyJobSchemas(): void;
|
|
18
|
-
bindBackRefs(): void;
|
|
19
|
-
convertTopicsToTypes(): void;
|
|
20
|
-
bindParents(): Promise<void>;
|
|
21
|
-
collectValues(schema: Record<string, any>, values: Set<string>): void;
|
|
22
|
-
traverse(obj: any, values: Set<string>): void;
|
|
23
|
-
generateSymVals(): Promise<void>;
|
|
24
|
-
resolveJobMapsPaths(): void;
|
|
25
|
-
resolveMappingDependencies(): void;
|
|
26
|
-
groupMappingRules(rules: string[]): Record<string, string[]>;
|
|
27
|
-
resolveMappableValue(mappable: string): [string, string];
|
|
28
|
-
deployActivitySchemas(): Promise<void>;
|
|
29
|
-
deploySubscriptions(): Promise<void>;
|
|
30
|
-
findTrigger(graph: HotMeshGraph): [string, Record<string, any>] | null;
|
|
31
|
-
deployTransitions(): Promise<void>;
|
|
32
|
-
deployHookPatterns(): Promise<void>;
|
|
33
|
-
deployConsumerGroups(): Promise<void>;
|
|
34
|
-
deployConsumerGroup(stream: string, group: string): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
export { Deployer };
|
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../modules/key';
|
|
2
|
-
import { getSymKey } from '../../modules/utils';
|
|
3
|
-
import { CollatorService } from '../collator';
|
|
4
|
-
import { SerializerService } from '../serializer';
|
|
5
|
-
const DEFAULT_METADATA_RANGE_SIZE = 26; //metadata is 26 slots ([a-z] * 1)
|
|
6
|
-
const DEFAULT_DATA_RANGE_SIZE = 260; //data is 260 slots ([a-zA-Z] * 5)
|
|
7
|
-
const DEFAULT_RANGE_SIZE = DEFAULT_METADATA_RANGE_SIZE + DEFAULT_DATA_RANGE_SIZE;
|
|
8
|
-
class Deployer {
|
|
9
|
-
constructor(manifest) {
|
|
10
|
-
this.manifest = null;
|
|
11
|
-
this.manifest = manifest;
|
|
12
|
-
}
|
|
13
|
-
async deploy(store) {
|
|
14
|
-
this.store = store;
|
|
15
|
-
CollatorService.compile(this.manifest.app.graphs);
|
|
16
|
-
this.convertTopicsToTypes();
|
|
17
|
-
this.copyJobSchemas();
|
|
18
|
-
this.bindBackRefs();
|
|
19
|
-
this.bindParents();
|
|
20
|
-
this.resolveMappingDependencies();
|
|
21
|
-
this.resolveJobMapsPaths();
|
|
22
|
-
await this.generateSymKeys();
|
|
23
|
-
await this.generateSymVals();
|
|
24
|
-
await this.deployHookPatterns();
|
|
25
|
-
await this.deployActivitySchemas();
|
|
26
|
-
await this.deploySubscriptions();
|
|
27
|
-
await this.deployTransitions();
|
|
28
|
-
await this.deployConsumerGroups();
|
|
29
|
-
}
|
|
30
|
-
getVID() {
|
|
31
|
-
return {
|
|
32
|
-
id: this.manifest.app.id,
|
|
33
|
-
version: this.manifest.app.version,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async generateSymKeys() {
|
|
37
|
-
//note: symbol ranges are additive (per version); path assignments are immutable
|
|
38
|
-
const appId = this.manifest.app.id;
|
|
39
|
-
for (const graph of this.manifest.app.graphs) {
|
|
40
|
-
//generate JOB symbols
|
|
41
|
-
const [, trigger] = this.findTrigger(graph);
|
|
42
|
-
const topic = trigger.subscribes;
|
|
43
|
-
const [lower, upper, symbols] = await this.store.reserveSymbolRange(`$${topic}`, DEFAULT_RANGE_SIZE, 'JOB');
|
|
44
|
-
const prefix = ''; //job meta/data is NOT namespaced
|
|
45
|
-
const newSymbols = this.bindSymbols(lower, upper, symbols, prefix, trigger.PRODUCES);
|
|
46
|
-
if (Object.keys(newSymbols).length) {
|
|
47
|
-
await this.store.addSymbols(`$${topic}`, newSymbols);
|
|
48
|
-
}
|
|
49
|
-
//generate ACTIVITY symbols
|
|
50
|
-
for (const [activityId, activity] of Object.entries(graph.activities)) {
|
|
51
|
-
const [lower, upper, symbols] = await this.store.reserveSymbolRange(activityId, DEFAULT_RANGE_SIZE, 'ACTIVITY');
|
|
52
|
-
const prefix = `${activityId}/`; //activity meta/data is namespaced
|
|
53
|
-
this.bindSelf(activity.consumes, activity.produces, activityId);
|
|
54
|
-
const newSymbols = this.bindSymbols(lower, upper, symbols, prefix, activity.produces);
|
|
55
|
-
if (Object.keys(newSymbols).length) {
|
|
56
|
-
await this.store.addSymbols(activityId, newSymbols);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
bindSelf(consumes, produces, activityId) {
|
|
62
|
-
//bind self-referential mappings
|
|
63
|
-
for (const selfId of [activityId, '$self']) {
|
|
64
|
-
const selfConsumes = consumes[selfId];
|
|
65
|
-
if (selfConsumes) {
|
|
66
|
-
for (const path of selfConsumes) {
|
|
67
|
-
if (!produces.includes(path)) {
|
|
68
|
-
produces.push(path);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
bindSymbols(startIndex, maxIndex, existingSymbols, prefix, produces) {
|
|
75
|
-
let newSymbols = {};
|
|
76
|
-
let currentSymbols = { ...existingSymbols };
|
|
77
|
-
for (let path of produces) {
|
|
78
|
-
const fullPath = `${prefix}${path}`;
|
|
79
|
-
if (!currentSymbols[fullPath]) {
|
|
80
|
-
if (startIndex > maxIndex) {
|
|
81
|
-
throw new Error('Symbol index out of bounds');
|
|
82
|
-
}
|
|
83
|
-
const symbol = getSymKey(startIndex);
|
|
84
|
-
startIndex++;
|
|
85
|
-
newSymbols[fullPath] = symbol;
|
|
86
|
-
currentSymbols[fullPath] = symbol; // update the currentSymbols to include this new symbol
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return newSymbols;
|
|
90
|
-
}
|
|
91
|
-
copyJobSchemas() {
|
|
92
|
-
const graphs = this.manifest.app.graphs;
|
|
93
|
-
for (const graph of graphs) {
|
|
94
|
-
const jobSchema = graph.output?.schema;
|
|
95
|
-
const outputSchema = graph.input?.schema;
|
|
96
|
-
if (!jobSchema && !outputSchema)
|
|
97
|
-
continue;
|
|
98
|
-
const activities = graph.activities;
|
|
99
|
-
// Find the trigger activity and bind the job schema to it
|
|
100
|
-
// at execution time, the trigger is a standin for the job
|
|
101
|
-
for (const activityKey in activities) {
|
|
102
|
-
if (activities[activityKey].type === 'trigger') {
|
|
103
|
-
const trigger = activities[activityKey];
|
|
104
|
-
if (jobSchema) {
|
|
105
|
-
//possible for trigger to have job mappings
|
|
106
|
-
if (!trigger.job) {
|
|
107
|
-
trigger.job = {};
|
|
108
|
-
}
|
|
109
|
-
trigger.job.schema = jobSchema;
|
|
110
|
-
}
|
|
111
|
-
if (outputSchema) {
|
|
112
|
-
//impossible for trigger to have output mappings.
|
|
113
|
-
trigger.output = { schema: outputSchema };
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
bindBackRefs() {
|
|
120
|
-
for (const graph of this.manifest.app.graphs) {
|
|
121
|
-
const activities = graph.activities;
|
|
122
|
-
const triggerId = this.findTrigger(graph)[0];
|
|
123
|
-
for (const activityKey in activities) {
|
|
124
|
-
activities[activityKey].trigger = triggerId;
|
|
125
|
-
activities[activityKey].subscribes = graph.subscribes;
|
|
126
|
-
if (graph.publishes) {
|
|
127
|
-
activities[activityKey].publishes = graph.publishes;
|
|
128
|
-
}
|
|
129
|
-
if (graph.expire) {
|
|
130
|
-
activities[activityKey].expire = graph.expire;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
//more intuitive for SDK users to use 'topic',
|
|
136
|
-
//but the compiler is desiged to be generic and uses 'subtypes'
|
|
137
|
-
convertTopicsToTypes() {
|
|
138
|
-
for (const graph of this.manifest.app.graphs) {
|
|
139
|
-
const activities = graph.activities;
|
|
140
|
-
for (const activityKey in activities) {
|
|
141
|
-
const activity = activities[activityKey];
|
|
142
|
-
if (['worker', 'await'].includes(activity.type) && activity.topic && !activity.subtype) {
|
|
143
|
-
activity.subtype = activity.topic;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
async bindParents() {
|
|
149
|
-
const graphs = this.manifest.app.graphs;
|
|
150
|
-
for (const graph of graphs) {
|
|
151
|
-
if (graph.transitions) {
|
|
152
|
-
for (const fromActivity in graph.transitions) {
|
|
153
|
-
const toTransitions = graph.transitions[fromActivity];
|
|
154
|
-
for (const transition of toTransitions) {
|
|
155
|
-
const to = transition.to;
|
|
156
|
-
//DAGs have one parent; easy to optimize for
|
|
157
|
-
graph.activities[to].parent = fromActivity;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
collectValues(schema, values) {
|
|
164
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
165
|
-
if (key === 'enum' || key === 'examples' || key === 'default') {
|
|
166
|
-
if (Array.isArray(value)) {
|
|
167
|
-
for (const v of value) {
|
|
168
|
-
if (typeof v === 'string' && v.length > 5) {
|
|
169
|
-
values.add(v);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else if (typeof value === 'string' && value.length > 5) {
|
|
174
|
-
values.add(value);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
else if (typeof value === 'object') {
|
|
178
|
-
this.collectValues(value, values);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
traverse(obj, values) {
|
|
183
|
-
for (const value of Object.values(obj)) {
|
|
184
|
-
if (typeof value === 'object') {
|
|
185
|
-
if ('schema' in value) {
|
|
186
|
-
this.collectValues(value.schema, values);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
this.traverse(value, values);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async generateSymVals() {
|
|
195
|
-
const uniqueStrings = new Set();
|
|
196
|
-
for (const graph of this.manifest.app.graphs) {
|
|
197
|
-
this.traverse(graph, uniqueStrings);
|
|
198
|
-
}
|
|
199
|
-
const existingSymbols = await this.store.getSymbolValues();
|
|
200
|
-
const startIndex = Object.keys(existingSymbols).length;
|
|
201
|
-
const maxIndex = Math.pow(52, 2) - 1;
|
|
202
|
-
const newSymbols = SerializerService.filterSymVals(startIndex, maxIndex, existingSymbols, uniqueStrings);
|
|
203
|
-
await this.store.addSymbolValues(newSymbols);
|
|
204
|
-
}
|
|
205
|
-
resolveJobMapsPaths() {
|
|
206
|
-
function parsePaths(obj) {
|
|
207
|
-
let result = [];
|
|
208
|
-
function traverse(obj, path = []) {
|
|
209
|
-
for (let key in obj) {
|
|
210
|
-
if (typeof obj[key] === 'object' && obj[key] !== null && !('@pipe' in obj[key])) {
|
|
211
|
-
let newPath = [...path, key];
|
|
212
|
-
traverse(obj[key], newPath);
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
const finalPath = `data/${[...path, key].join('/')}`;
|
|
216
|
-
if (!result.includes(finalPath)) {
|
|
217
|
-
result.push(finalPath);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (obj) {
|
|
223
|
-
traverse(obj);
|
|
224
|
-
}
|
|
225
|
-
return result;
|
|
226
|
-
}
|
|
227
|
-
for (const graph of this.manifest.app.graphs) {
|
|
228
|
-
let results = [];
|
|
229
|
-
const [, trigger] = this.findTrigger(graph);
|
|
230
|
-
for (const activityKey in graph.activities) {
|
|
231
|
-
const activity = graph.activities[activityKey];
|
|
232
|
-
results = results.concat(parsePaths(activity.job?.maps));
|
|
233
|
-
}
|
|
234
|
-
trigger.PRODUCES = results;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
resolveMappingDependencies() {
|
|
238
|
-
const dynamicMappingRules = [];
|
|
239
|
-
//recursive function to descend into the object and find all dynamic mapping rules
|
|
240
|
-
function traverse(obj, consumes) {
|
|
241
|
-
for (const key in obj) {
|
|
242
|
-
if (typeof obj[key] === 'string') {
|
|
243
|
-
const stringValue = obj[key];
|
|
244
|
-
const dynamicMappingRuleMatch = stringValue.match(/^\{[^@].*}$/);
|
|
245
|
-
if (dynamicMappingRuleMatch) {
|
|
246
|
-
if (stringValue.split('.')[1] !== 'input') {
|
|
247
|
-
dynamicMappingRules.push(stringValue);
|
|
248
|
-
consumes.push(stringValue);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
else if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
253
|
-
traverse(obj[key], consumes);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const graphs = this.manifest.app.graphs;
|
|
258
|
-
for (const graph of graphs) {
|
|
259
|
-
const activities = graph.activities;
|
|
260
|
-
for (const activityId in activities) {
|
|
261
|
-
const activity = activities[activityId];
|
|
262
|
-
activity.consumes = [];
|
|
263
|
-
traverse(activity, activity.consumes);
|
|
264
|
-
activity.consumes = this.groupMappingRules(activity.consumes);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
const groupedRules = this.groupMappingRules(dynamicMappingRules);
|
|
268
|
-
// Iterate through the graph and add 'produces' field to each activity
|
|
269
|
-
for (const graph of graphs) {
|
|
270
|
-
const activities = graph.activities;
|
|
271
|
-
for (const activityId in activities) {
|
|
272
|
-
const activity = activities[activityId];
|
|
273
|
-
activity.produces = groupedRules[`${activityId}`] || [];
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
groupMappingRules(rules) {
|
|
278
|
-
rules = Array.from(new Set(rules)).sort();
|
|
279
|
-
// Group by the first symbol before the period (this is the activity name)
|
|
280
|
-
const groupedRules = {};
|
|
281
|
-
for (const rule of rules) {
|
|
282
|
-
const [group, resolved] = this.resolveMappableValue(rule);
|
|
283
|
-
if (!groupedRules[group]) {
|
|
284
|
-
groupedRules[group] = [];
|
|
285
|
-
}
|
|
286
|
-
groupedRules[group].push(resolved);
|
|
287
|
-
}
|
|
288
|
-
return groupedRules;
|
|
289
|
-
}
|
|
290
|
-
resolveMappableValue(mappable) {
|
|
291
|
-
mappable = mappable.substring(1, mappable.length - 1);
|
|
292
|
-
const parts = mappable.split('.');
|
|
293
|
-
if (parts[0] === '$job') {
|
|
294
|
-
const [group, ...path] = parts;
|
|
295
|
-
return [group, path.join('/')];
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
//normalize paths to be relative to the activity
|
|
299
|
-
const [group, type, subtype, ...path] = parts;
|
|
300
|
-
const prefix = {
|
|
301
|
-
hook: 'hook/data',
|
|
302
|
-
input: 'input/data',
|
|
303
|
-
output: subtype === 'data' ? 'output/data' : 'output/metadata'
|
|
304
|
-
}[type];
|
|
305
|
-
return [group, `${prefix}/${path.join('/')}`];
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
async deployActivitySchemas() {
|
|
309
|
-
const graphs = this.manifest.app.graphs;
|
|
310
|
-
const activitySchemas = {};
|
|
311
|
-
for (const graph of graphs) {
|
|
312
|
-
const activities = graph.activities;
|
|
313
|
-
for (const activityKey in activities) {
|
|
314
|
-
activitySchemas[activityKey] = activities[activityKey];
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
await this.store.setSchemas(activitySchemas, this.getVID());
|
|
318
|
-
}
|
|
319
|
-
async deploySubscriptions() {
|
|
320
|
-
const graphs = this.manifest.app.graphs;
|
|
321
|
-
const publicSubscriptions = {};
|
|
322
|
-
for (const graph of graphs) {
|
|
323
|
-
const activities = graph.activities;
|
|
324
|
-
const subscribesTopic = graph.subscribes;
|
|
325
|
-
// Find the activity ID associated with the subscribes topic
|
|
326
|
-
for (const activityKey in activities) {
|
|
327
|
-
if (activities[activityKey].type === 'trigger') {
|
|
328
|
-
publicSubscriptions[subscribesTopic] = activityKey;
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
await this.store.setSubscriptions(publicSubscriptions, this.getVID());
|
|
334
|
-
}
|
|
335
|
-
findTrigger(graph) {
|
|
336
|
-
for (const activityKey in graph.activities) {
|
|
337
|
-
const activity = graph.activities[activityKey];
|
|
338
|
-
if (activity.type === 'trigger') {
|
|
339
|
-
return [activityKey, activity];
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
async deployTransitions() {
|
|
345
|
-
const graphs = this.manifest.app.graphs;
|
|
346
|
-
const privateSubscriptions = {};
|
|
347
|
-
for (const graph of graphs) {
|
|
348
|
-
if (graph.subscribes && graph.subscribes.startsWith('.')) {
|
|
349
|
-
const [triggerId] = this.findTrigger(graph);
|
|
350
|
-
if (triggerId) {
|
|
351
|
-
privateSubscriptions[graph.subscribes] = { [triggerId]: true };
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
if (graph.transitions) {
|
|
355
|
-
for (const fromActivity in graph.transitions) {
|
|
356
|
-
const toTransitions = graph.transitions[fromActivity];
|
|
357
|
-
const toValues = {};
|
|
358
|
-
for (const transition of toTransitions) {
|
|
359
|
-
const to = transition.to;
|
|
360
|
-
if (transition.conditions) {
|
|
361
|
-
toValues[to] = transition.conditions;
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
toValues[to] = true;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
if (Object.keys(toValues).length > 0) {
|
|
368
|
-
privateSubscriptions['.' + fromActivity] = toValues;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
await this.store.setTransitions(privateSubscriptions, this.getVID());
|
|
374
|
-
}
|
|
375
|
-
async deployHookPatterns() {
|
|
376
|
-
const graphs = this.manifest.app.graphs;
|
|
377
|
-
const hookRules = {};
|
|
378
|
-
for (const graph of graphs) {
|
|
379
|
-
if (graph.hooks) {
|
|
380
|
-
for (const topic in graph.hooks) {
|
|
381
|
-
hookRules[topic] = graph.hooks[topic];
|
|
382
|
-
const activityId = graph.hooks[topic][0].to;
|
|
383
|
-
const targetActivity = graph.activities[activityId];
|
|
384
|
-
if (targetActivity) {
|
|
385
|
-
if (!targetActivity.hook) {
|
|
386
|
-
targetActivity.hook = {};
|
|
387
|
-
}
|
|
388
|
-
//create back-reference to the hook topic
|
|
389
|
-
targetActivity.hook.topic = topic;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
await this.store.setHookRules(hookRules);
|
|
395
|
-
}
|
|
396
|
-
async deployConsumerGroups() {
|
|
397
|
-
//create one engine group
|
|
398
|
-
const params = { appId: this.manifest.app.id };
|
|
399
|
-
const key = this.store.mintKey(KeyType.STREAMS, params);
|
|
400
|
-
await this.deployConsumerGroup(key, 'ENGINE');
|
|
401
|
-
for (const graph of this.manifest.app.graphs) {
|
|
402
|
-
const activities = graph.activities;
|
|
403
|
-
for (const activityKey in activities) {
|
|
404
|
-
const activity = activities[activityKey];
|
|
405
|
-
if (activity.type === 'worker') {
|
|
406
|
-
params.topic = activity.subtype;
|
|
407
|
-
const key = this.store.mintKey(KeyType.STREAMS, params);
|
|
408
|
-
//create one worker group per unique activity subtype (the topic)
|
|
409
|
-
await this.deployConsumerGroup(key, 'WORKER');
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
async deployConsumerGroup(stream, group) {
|
|
415
|
-
try {
|
|
416
|
-
await this.store.xgroup('CREATE', stream, group, '$', 'MKSTREAM');
|
|
417
|
-
}
|
|
418
|
-
catch (err) {
|
|
419
|
-
this.store.logger.info('consumer-group-exists', { stream, group });
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
export { Deployer };
|