@hotmeshio/hotmesh 0.3.10 → 0.3.12

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.
Files changed (107) hide show
  1. package/README.md +12 -14
  2. package/build/modules/key.d.ts +4 -0
  3. package/build/modules/key.js +1 -1
  4. package/build/modules/utils.js +1 -1
  5. package/build/package.json +22 -18
  6. package/build/services/activities/activity.js +1 -1
  7. package/build/services/activities/await.js +1 -1
  8. package/build/services/activities/cycle.js +1 -1
  9. package/build/services/activities/hook.js +1 -1
  10. package/build/services/activities/index.js +1 -1
  11. package/build/services/activities/interrupt.js +1 -1
  12. package/build/services/activities/signal.js +1 -1
  13. package/build/services/activities/trigger.js +1 -1
  14. package/build/services/activities/worker.js +1 -1
  15. package/build/services/collator/index.js +1 -1
  16. package/build/services/compiler/deployer.js +1 -1
  17. package/build/services/compiler/index.js +1 -1
  18. package/build/services/compiler/validator.js +1 -1
  19. package/build/services/connector/factory.js +29 -17
  20. package/build/services/connector/index.d.ts +2 -0
  21. package/build/services/connector/index.js +2 -0
  22. package/build/services/connector/providers/nats.js +8 -2
  23. package/build/services/connector/providers/postgres.js +7 -3
  24. package/build/services/engine/index.js +1 -1
  25. package/build/services/exporter/index.js +1 -1
  26. package/build/services/mapper/index.js +1 -1
  27. package/build/services/meshdata/index.d.ts +4 -3
  28. package/build/services/meshdata/index.js +3 -2
  29. package/build/services/meshflow/client.d.ts +1 -0
  30. package/build/services/meshflow/client.js +18 -6
  31. package/build/services/meshflow/connection.d.ts +2 -2
  32. package/build/services/meshflow/connection.js +1 -1
  33. package/build/services/meshflow/exporter.js +1 -1
  34. package/build/services/meshflow/worker.d.ts +2 -1
  35. package/build/services/meshflow/worker.js +27 -16
  36. package/build/services/meshos/index.d.ts +2 -1
  37. package/build/services/meshos/index.js +7 -4
  38. package/build/services/pipe/functions/array.js +1 -1
  39. package/build/services/pipe/functions/bitwise.js +1 -1
  40. package/build/services/pipe/functions/conditional.js +1 -1
  41. package/build/services/pipe/functions/cron.js +1 -1
  42. package/build/services/pipe/functions/date.js +1 -1
  43. package/build/services/pipe/functions/index.js +1 -1
  44. package/build/services/pipe/functions/json.js +1 -1
  45. package/build/services/pipe/functions/logical.js +1 -1
  46. package/build/services/pipe/functions/math.js +1 -1
  47. package/build/services/pipe/functions/number.js +1 -1
  48. package/build/services/pipe/functions/object.js +1 -1
  49. package/build/services/pipe/functions/string.js +1 -1
  50. package/build/services/pipe/functions/symbol.js +1 -1
  51. package/build/services/pipe/functions/unary.js +1 -1
  52. package/build/services/pipe/index.js +1 -1
  53. package/build/services/quorum/index.js +1 -1
  54. package/build/services/reporter/index.d.ts +3 -0
  55. package/build/services/reporter/index.js +1 -1
  56. package/build/services/router/index.js +1 -1
  57. package/build/services/search/factory.d.ts +2 -2
  58. package/build/services/search/factory.js +8 -4
  59. package/build/services/search/providers/postgres/postgres.d.ts +21 -0
  60. package/build/services/search/providers/postgres/postgres.js +1 -0
  61. package/build/services/search/providers/redis/ioredis.js +1 -1
  62. package/build/services/search/providers/redis/redis.js +1 -1
  63. package/build/services/serializer/index.js +1 -1
  64. package/build/services/store/factory.d.ts +1 -1
  65. package/build/services/store/factory.js +9 -5
  66. package/build/services/store/index.d.ts +2 -1
  67. package/build/services/store/providers/postgres/kvsql.d.ts +156 -0
  68. package/build/services/store/providers/postgres/kvsql.js +1 -0
  69. package/build/services/store/providers/postgres/postgres.d.ts +107 -0
  70. package/build/services/store/providers/postgres/postgres.js +1 -0
  71. package/build/services/store/providers/redis/_base.d.ts +0 -1
  72. package/build/services/store/providers/redis/_base.js +1 -1
  73. package/build/services/store/providers/redis/ioredis.js +1 -1
  74. package/build/services/store/providers/redis/redis.d.ts +0 -1
  75. package/build/services/store/providers/redis/redis.js +1 -1
  76. package/build/services/store/providers/store-initializable.js +1 -1
  77. package/build/services/stream/factory.js +5 -1
  78. package/build/services/stream/providers/nats/nats.js +1 -1
  79. package/build/services/stream/providers/postgres/postgres.d.ts +4 -0
  80. package/build/services/stream/providers/postgres/postgres.js +1 -1
  81. package/build/services/stream/providers/redis/ioredis.js +1 -1
  82. package/build/services/stream/providers/redis/redis.js +1 -1
  83. package/build/services/stream/providers/stream-initializable.js +1 -1
  84. package/build/services/sub/providers/redis/ioredis.js +1 -1
  85. package/build/services/sub/providers/redis/redis.js +1 -1
  86. package/build/services/task/index.js +1 -1
  87. package/build/services/telemetry/index.js +1 -1
  88. package/build/services/worker/index.js +1 -1
  89. package/build/types/hotmesh.d.ts +4 -0
  90. package/build/types/manifest.d.ts +12 -3
  91. package/build/types/meshflow.d.ts +2 -2
  92. package/build/types/postgres.d.ts +1 -0
  93. package/build/types/provider.d.ts +51 -1
  94. package/package.json +22 -18
  95. package/types/hotmesh.ts +15 -0
  96. package/types/manifest.ts +12 -3
  97. package/types/meshflow.ts +2 -2
  98. package/types/postgres.ts +2 -0
  99. package/types/provider.ts +81 -3
  100. package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
  101. package/build/services/store/providers/postgres/types/hash.js +0 -0
  102. package/build/services/store/providers/postgres/types/list.d.ts +0 -0
  103. package/build/services/store/providers/postgres/types/list.js +0 -0
  104. package/build/services/store/providers/postgres/types/string.d.ts +0 -0
  105. package/build/services/store/providers/postgres/types/string.js +0 -0
  106. package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
  107. package/build/services/store/providers/postgres/types/zset.js +0 -0
@@ -1,10 +1,19 @@
1
1
  import { MeshOS } from '../services/meshos';
2
- import * as Types from './index';
2
+ import { WorkflowSearchSchema } from './meshflow';
3
+ import * as Types from './provider';
4
+ import { ProviderConfig } from './provider';
3
5
  export type DB = {
4
6
  name: string;
5
7
  label: string;
6
8
  search: boolean;
7
- connection: Types.ProviderConfig;
9
+ connection?: Types.ProviderConfig;
10
+ connections?: {
11
+ store: ProviderConfig;
12
+ stream: ProviderConfig;
13
+ sub: ProviderConfig;
14
+ pub?: ProviderConfig;
15
+ search?: ProviderConfig;
16
+ };
8
17
  };
9
18
  export type SubClassInstance<T extends typeof MeshOS> = T extends abstract new (...args: any) => infer R ? R : never;
10
19
  export type AllSubclassInstances = SubClassInstance<(typeof MeshOS)['classes'][keyof (typeof MeshOS)['classes']]>;
@@ -13,7 +22,7 @@ export type SubclassType<T extends MeshOS = MeshOS> = new (...args: any[]) => T;
13
22
  export type Entity = {
14
23
  name: string;
15
24
  label: string;
16
- schema: Types.WorkflowSearchSchema;
25
+ schema: WorkflowSearchSchema;
17
26
  class: SubclassType;
18
27
  };
19
28
  export type Namespace = {
@@ -1,6 +1,6 @@
1
1
  import { WorkflowHandleService } from '../services/meshflow/handle';
2
2
  import { LogLevel } from './logger';
3
- import { ProviderConfig } from './provider';
3
+ import { ProviderConfig, ProvidersConfig } from './provider';
4
4
  import { StringAnyType, StringStringType } from './serializer';
5
5
  import { StreamData, StreamError } from './stream';
6
6
  type WorkflowConfig = {
@@ -106,7 +106,7 @@ type WorkflowDataType = {
106
106
  canRetry?: boolean;
107
107
  expire?: number;
108
108
  };
109
- type Connection = ProviderConfig;
109
+ type Connection = ProviderConfig | ProvidersConfig;
110
110
  type ClientConfig = {
111
111
  connection: Connection;
112
112
  };
@@ -7,6 +7,7 @@ export interface PostgresClientOptions {
7
7
  max?: number;
8
8
  idleTimeoutMillis?: number;
9
9
  }
10
+ export type PostgresJobEnumType = 'status' | 'jdata' | 'adata' | 'udata' | 'jmark' | 'hmark' | 'other';
10
11
  export type PostgresClassType = {
11
12
  new (options: PostgresClientOptions): PostgresClientType;
12
13
  connect: (options: PostgresClientOptions) => Promise<PostgresClientType>;
@@ -9,7 +9,7 @@ export interface ProviderOptions {
9
9
  export type Providers = 'redis' | 'nats' | 'postgres' | 'ioredis';
10
10
  export interface ProviderTransaction {
11
11
  exec(): Promise<any>;
12
- [key: string]: any;
12
+ [key: string]: ((...args: any[]) => Promise<any>) | undefined | any;
13
13
  }
14
14
  export interface ProviderNativeClient {
15
15
  [key: string]: any;
@@ -24,3 +24,53 @@ export type ProviderConfig = {
24
24
  class: any;
25
25
  options: StringAnyType;
26
26
  };
27
+ export type ProvidersConfig = {
28
+ sub: ProviderConfig;
29
+ store: ProviderConfig;
30
+ stream: ProviderConfig;
31
+ pub?: ProviderConfig;
32
+ search?: ProviderConfig;
33
+ };
34
+ export interface SetOptions {
35
+ nx?: boolean;
36
+ ex?: number;
37
+ }
38
+ export interface HSetOptions {
39
+ nx?: boolean;
40
+ ex?: number;
41
+ }
42
+ export interface ZAddOptions {
43
+ nx?: boolean;
44
+ }
45
+ export interface HScanResult {
46
+ cursor: string;
47
+ items: Record<string, string>;
48
+ }
49
+ export interface KVSQLProviderTransaction extends ProviderTransaction {
50
+ [key: string]: any;
51
+ exec(): Promise<any[]>;
52
+ set(key: string, value: string, options?: SetOptions): ProviderTransaction;
53
+ get(key: string): ProviderTransaction;
54
+ del(key: string): ProviderTransaction;
55
+ expire(key: string, seconds: number): ProviderTransaction;
56
+ hset(key: string, fields: Record<string, string>, options?: HSetOptions): ProviderTransaction;
57
+ hget(key: string, field: string): ProviderTransaction;
58
+ hdel(key: string, fields: string[]): ProviderTransaction;
59
+ hmget(key: string, fields: string[]): ProviderTransaction;
60
+ hgetall(key: string): ProviderTransaction;
61
+ hincrbyfloat(key: string, field: string, value: number): ProviderTransaction;
62
+ hscan(key: string, cursor: string, count?: number): ProviderTransaction;
63
+ lrange(key: string, start: number, end: number): ProviderTransaction;
64
+ rpush(key: string, value: string): ProviderTransaction;
65
+ lpush(key: string, value: string): ProviderTransaction;
66
+ lpop(key: string): ProviderTransaction;
67
+ lmove(source: string, destination: string, srcPosition: 'LEFT' | 'RIGHT', destPosition: 'LEFT' | 'RIGHT'): ProviderTransaction;
68
+ zadd(key: string, score: number, member: string, options?: ZAddOptions): ProviderTransaction;
69
+ zrange(key: string, start: number, stop: number): ProviderTransaction;
70
+ zrangebyscore(key: string, min: number, max: number): ProviderTransaction;
71
+ zrangebyscore_withscores(key: string, min: number, max: number): ProviderTransaction;
72
+ zrem(key: string, member: string): ProviderTransaction;
73
+ zrank(key: string, member: string): ProviderTransaction;
74
+ scan(cursor: number, count?: number): ProviderTransaction;
75
+ rename(oldKey: string, newKey: string): ProviderTransaction;
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -22,18 +22,20 @@
22
22
  "lint:fix": "eslint . --fix --ext .ts",
23
23
  "start": "ts-node src/index.ts",
24
24
  "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
25
- "test:await": "NODE_ENV=test jest ./tests/functional/awaiter/index.test.ts --detectOpenHandles --forceExit --verbose",
25
+ "test:await": "NODE_ENV=test jest ./tests/functional/awaiter/*.test.ts --detectOpenHandles --forceExit --verbose",
26
26
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
27
- "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
27
+ "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/* --detectOpenHandles --forceExit --verbose",
28
28
  "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/providers/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
29
+ "test:connect:postgres": "NODE_ENV=test jest ./tests/unit/services/connector/providers/postgres.test.ts --detectOpenHandles --forceExit --verbose",
29
30
  "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/providers/redis.test.ts --detectOpenHandles --forceExit --verbose",
30
- "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",
31
- "test:meshflow": "NODE_ENV=test jest ./tests/meshflow/*/index.test.ts --detectOpenHandles --forceExit --verbose",
31
+ "test:connect:nats": "NODE_ENV=test jest ./tests/unit/services/connector/providers/nats.test.ts --detectOpenHandles --forceExit --verbose",
32
+ "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/*.test.ts --detectOpenHandles --forceExit --verbose",
33
+ "test:meshflow": "NODE_ENV=test jest ./tests/meshflow/*/*.test.ts --detectOpenHandles --forceExit --verbose",
32
34
  "test:meshflow:basic": "NODE_ENV=test jest ./tests/meshflow/basic/index.test.ts --detectOpenHandles --forceExit --verbose",
33
35
  "test:meshflow:collision": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/meshflow/collision/index.test.ts --detectOpenHandles --forceExit --verbose",
34
36
  "test:meshflow:fatal": "NODE_ENV=test jest ./tests/meshflow/fatal/index.test.ts --detectOpenHandles --forceExit --verbose",
35
- "test:meshflow:goodbye": "NODE_ENV=test jest ./tests/meshflow/goodbye/index.test.ts --detectOpenHandles --forceExit --verbose",
36
- "test:meshflow:hello": "HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/meshflow/helloworld/index.test.ts --detectOpenHandles --forceExit --verbose",
37
+ "test:meshflow:goodbye": "NODE_ENV=test jest ./tests/meshflow/goodbye/*.test.ts --detectOpenHandles --forceExit --verbose",
38
+ "test:meshflow:hello": "HMSH_LOGLEVEL=debug HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/meshflow/helloworld/*.test.ts --detectOpenHandles --forceExit --verbose",
37
39
  "test:meshflow:hook": "NODE_ENV=test jest ./tests/meshflow/hook/index.test.ts --detectOpenHandles --forceExit --verbose",
38
40
  "test:meshflow:interrupt": "NODE_ENV=test jest ./tests/meshflow/interrupt/index.test.ts --detectOpenHandles --forceExit --verbose",
39
41
  "test:meshflow:loopactivity": "NODE_ENV=test jest ./tests/meshflow/loopactivity/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -44,23 +46,24 @@
44
46
  "test:meshflow:unknown": "NODE_ENV=test jest ./tests/meshflow/unknown/index.test.ts --detectOpenHandles --forceExit --verbose",
45
47
  "test:emit": "NODE_ENV=test jest ./tests/functional/emit/index.test.ts --detectOpenHandles --forceExit --verbose",
46
48
  "test:pending": "NODE_ENV=test jest ./tests/functional/pending/index.test.ts --detectOpenHandles --forceExit --verbose",
47
- "test:functional": "NODE_ENV=test jest ./tests/functional/*/index.test.ts --detectOpenHandles --forceExit --verbose",
48
- "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
49
+ "test:functional": "NODE_ENV=test jest ./tests/functional/* --detectOpenHandles --forceExit --verbose",
50
+ "test:hmsh": "NODE_ENV=test jest ./tests/functional/*.test.ts --detectOpenHandles --verbose --forceExit",
49
51
  "test:hook": "NODE_ENV=test jest ./tests/functional/hook/index.test.ts --detectOpenHandles --forceExit --verbose",
50
52
  "test:interrupt": "NODE_ENV=test jest ./tests/functional/interrupt/index.test.ts --detectOpenHandles --forceExit --verbose",
51
53
  "test:parallel": "NODE_ENV=test jest ./tests/functional/parallel/index.test.ts --detectOpenHandles --forceExit --verbose",
52
54
  "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
53
- "test:quorum": "HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
55
+ "test:quorum": "HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/functional/quorum/*.test.ts --detectOpenHandles --forceExit --verbose",
54
56
  "test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
55
- "test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/index.test.ts --detectOpenHandles --forceExit --verbose",
57
+ "test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/*.test.ts --detectOpenHandles --forceExit --verbose",
56
58
  "test:reporter": "NODE_ENV=test jest ./tests/unit/services/reporter/index.test.ts --detectOpenHandles --forceExit --verbose",
57
59
  "test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/index.test.ts --detectOpenHandles --forceExit --verbose",
58
60
  "test:retry": "NODE_ENV=test jest ./tests/functional/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
59
- "test:sequence": "NODE_ENV=test jest ./tests/functional/sequence/index.test.ts --detectOpenHandles --forceExit --verbose",
61
+ "test:sequence": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/functional/sequence/*.test.ts --detectOpenHandles --forceExit --verbose",
60
62
  "test:signal": "NODE_ENV=test jest ./tests/functional/signal/index.test.ts --detectOpenHandles --forceExit --verbose",
61
63
  "test:status": "NODE_ENV=test jest ./tests/functional/status/index.test.ts --detectOpenHandles --forceExit --verbose",
62
64
  "test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
63
65
  "test:store:redis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
66
+ "test:store:postgres": "NODE_ENV=test jest ./tests/functional/store/providers/postgres/postgres.test.ts --detectOpenHandles --forceExit --verbose",
64
67
  "test:stream:ioredis": "NODE_ENV=test jest ./tests/functional/stream/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
65
68
  "test:stream:redis": "NODE_ENV=test jest ./tests/functional/stream/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
66
69
  "test:stream:postgres": "NODE_ENV=test jest ./tests/functional/stream/providers/postgres/postgres.test.ts --detectOpenHandles --forceExit --verbose",
@@ -93,11 +96,13 @@
93
96
  "js-yaml": "^4.1.0",
94
97
  "ms": "^2.1.3",
95
98
  "nanoid": "^3.3.6",
99
+ "pg-format": "^1.0.4",
96
100
  "winston": "^3.8.2"
97
101
  },
98
102
  "devDependencies": {
99
103
  "@types/jest": "^29.5.0",
100
104
  "@types/node": "^18.15.11",
105
+ "@types/pg": "^8.10.0",
101
106
  "@typescript-eslint/eslint-plugin": "^5.62.0",
102
107
  "@typescript-eslint/parser": "^5.62.0",
103
108
  "eslint": "^8.57.0",
@@ -107,21 +112,20 @@
107
112
  "ioredis": "^5.3.2",
108
113
  "javascript-obfuscator": "^4.1.1",
109
114
  "jest": "^29.5.0",
115
+ "nats": "^2.28.0",
116
+ "pg": "^8.10.0",
110
117
  "redis": "^4.6.13",
111
118
  "rimraf": "^4.4.1",
112
119
  "ts-jest": "^29.0.5",
113
120
  "ts-node": "^10.9.1",
114
121
  "ts-node-dev": "^2.0.0",
115
122
  "typedoc": "^0.26.4",
116
- "typescript": "^5.0.4",
117
- "@types/pg": "^8.10.0",
118
- "nats": "^2.28.0",
119
- "pg": "^8.10.0"
123
+ "typescript": "^5.0.4"
120
124
  },
121
125
  "peerDependencies": {
122
126
  "ioredis": "^4.0.0 || ^5.0.0",
123
- "redis": "^4.0.0",
124
127
  "nats": "^2.0.0",
125
- "pg": "^8.0.0"
128
+ "pg": "^8.0.0",
129
+ "redis": "^4.0.0"
126
130
  }
127
131
  }
package/types/hotmesh.ts CHANGED
@@ -66,6 +66,12 @@ type HotMeshEngine = {
66
66
  * @private
67
67
  */
68
68
  sub?: ProviderClient;
69
+ /**
70
+ * set by hotmesh once the connnector service instances the provider
71
+ * AND if the provider requires a separate channel for publishing
72
+ * @private
73
+ */
74
+ pub?: ProviderClient;
69
75
  /**
70
76
  * set by hotmesh once the connnector service instances the provider
71
77
  * @private
@@ -92,6 +98,7 @@ type HotMeshEngine = {
92
98
  store: ProviderConfig;
93
99
  stream: ProviderConfig;
94
100
  sub: ProviderConfig;
101
+ pub?: ProviderConfig; //system injects if necessary (if store channel cannot be used for pub)
95
102
  search?: ProviderConfig; //inherits from store if not set
96
103
  };
97
104
 
@@ -126,6 +133,13 @@ type HotMeshWorker = {
126
133
  */
127
134
  topic: string;
128
135
 
136
+ /**
137
+ * set by hotmesh once the connnector service instances the provider
138
+ * AND if the provider requires a separate channel for publishing
139
+ * @private
140
+ */
141
+ pub?: ProviderClient;
142
+
129
143
  /**
130
144
  * set by hotmesh once the connnector service instances the provider
131
145
  * @private
@@ -167,6 +181,7 @@ type HotMeshWorker = {
167
181
  store: ProviderConfig;
168
182
  stream: ProviderConfig;
169
183
  sub: ProviderConfig;
184
+ pub?: ProviderConfig; //if store channel cannot be used for pub
170
185
  search?: ProviderConfig; //inherits from store if not set
171
186
  };
172
187
 
package/types/manifest.ts CHANGED
@@ -1,12 +1,21 @@
1
1
  import { MeshOS } from '../services/meshos';
2
+ import { WorkflowSearchSchema } from './meshflow';
2
3
 
3
- import * as Types from './index';
4
+ import * as Types from './provider';
5
+ import { ProviderConfig } from './provider';
4
6
 
5
7
  export type DB = {
6
8
  name: string;
7
9
  label: string;
8
10
  search: boolean;
9
- connection: Types.ProviderConfig;
11
+ connection?: Types.ProviderConfig;
12
+ connections?: {
13
+ store: ProviderConfig;
14
+ stream: ProviderConfig;
15
+ sub: ProviderConfig;
16
+ pub?: ProviderConfig; //system injects if necessary (if store channel cannot be used for pub)
17
+ search?: ProviderConfig; //inherits from store if not set
18
+ };
10
19
  };
11
20
 
12
21
  export type SubClassInstance<T extends typeof MeshOS> = T extends abstract new (
@@ -25,7 +34,7 @@ export type SubclassType<T extends MeshOS = MeshOS> = new (...args: any[]) => T;
25
34
  export type Entity = {
26
35
  name: string;
27
36
  label: string;
28
- schema: Types.WorkflowSearchSchema;
37
+ schema: WorkflowSearchSchema;
29
38
  class: SubclassType;
30
39
  };
31
40
 
package/types/meshflow.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { WorkflowHandleService } from '../services/meshflow/handle';
2
2
 
3
3
  import { LogLevel } from './logger';
4
- import { ProviderConfig } from './provider';
4
+ import { ProviderConfig, ProvidersConfig } from './provider';
5
5
  import { StringAnyType, StringStringType } from './serializer';
6
6
  import { StreamData, StreamError } from './stream';
7
7
 
@@ -435,7 +435,7 @@ type WorkflowDataType = {
435
435
  expire?: number;
436
436
  };
437
437
 
438
- type Connection = ProviderConfig;
438
+ type Connection = ProviderConfig | ProvidersConfig;
439
439
 
440
440
  type ClientConfig = {
441
441
  connection: Connection;
package/types/postgres.ts CHANGED
@@ -10,6 +10,8 @@ export interface PostgresClientOptions {
10
10
  // Add any other options you might need
11
11
  }
12
12
 
13
+ export type PostgresJobEnumType = 'status' | 'jdata' | 'adata' | 'udata' | 'jmark' | 'hmark' | 'other';
14
+
13
15
  export type PostgresClassType = {
14
16
  new (options: PostgresClientOptions): PostgresClientType;
15
17
  connect: (options: PostgresClientOptions) => Promise<PostgresClientType>;
package/types/provider.ts CHANGED
@@ -27,11 +27,10 @@ export type Providers = 'redis' | 'nats' | 'postgres' | 'ioredis';
27
27
  * execute as a single transaction.
28
28
  */
29
29
  export interface ProviderTransaction {
30
- //outside callers can execute the transaction, regardless of provider by calling this method
31
30
  exec(): Promise<any>;
32
31
 
33
- // All other transaction methods are provider specific
34
- [key: string]: any;
32
+ // Allows callable properties while avoiding conflicts with ProviderTransaction instances
33
+ [key: string]: ((...args: any[]) => Promise<any>) | undefined | any;
35
34
  }
36
35
 
37
36
  /**
@@ -69,3 +68,82 @@ export type ProviderConfig = {
69
68
  class: any;
70
69
  options: StringAnyType;
71
70
  };
71
+
72
+ export type ProvidersConfig = {
73
+ sub: ProviderConfig;
74
+ store: ProviderConfig;
75
+ stream: ProviderConfig;
76
+ pub?: ProviderConfig;
77
+ search?: ProviderConfig;
78
+ }
79
+
80
+ export interface SetOptions {
81
+ nx?: boolean;
82
+ ex?: number; // Expiry time in seconds
83
+ }
84
+
85
+ export interface HSetOptions {
86
+ nx?: boolean;
87
+ ex?: number; // Expiry time in seconds
88
+ }
89
+
90
+ export interface ZAddOptions {
91
+ nx?: boolean;
92
+ }
93
+
94
+ export interface HScanResult {
95
+ cursor: string;
96
+ items: Record<string, string>;
97
+ }
98
+
99
+ export interface KVSQLProviderTransaction extends ProviderTransaction {
100
+ [key: string]: any;
101
+ exec(): Promise<any[]>;
102
+ set(key: string, value: string, options?: SetOptions): ProviderTransaction;
103
+ get(key: string): ProviderTransaction;
104
+ del(key: string): ProviderTransaction;
105
+ expire(key: string, seconds: number): ProviderTransaction;
106
+ hset(
107
+ key: string,
108
+ fields: Record<string, string>,
109
+ options?: HSetOptions
110
+ ): ProviderTransaction;
111
+ hget(key: string, field: string): ProviderTransaction;
112
+ hdel(key: string, fields: string[]): ProviderTransaction;
113
+ hmget(key: string, fields: string[]): ProviderTransaction;
114
+ hgetall(key: string): ProviderTransaction;
115
+ hincrbyfloat(
116
+ key: string,
117
+ field: string,
118
+ value: number
119
+ ): ProviderTransaction;
120
+ hscan(key: string, cursor: string, count?: number): ProviderTransaction;
121
+ lrange(key: string, start: number, end: number): ProviderTransaction;
122
+ rpush(key: string, value: string): ProviderTransaction;
123
+ lpush(key: string, value: string): ProviderTransaction;
124
+ lpop(key: string): ProviderTransaction;
125
+ lmove(
126
+ source: string,
127
+ destination: string,
128
+ srcPosition: 'LEFT' | 'RIGHT',
129
+ destPosition: 'LEFT' | 'RIGHT'
130
+ ): ProviderTransaction;
131
+ zadd(
132
+ key: string,
133
+ score: number,
134
+ member: string,
135
+ options?: ZAddOptions
136
+ ): ProviderTransaction;
137
+ zrange(key: string, start: number, stop: number): ProviderTransaction;
138
+ zrangebyscore(key: string, min: number, max: number): ProviderTransaction;
139
+ zrangebyscore_withscores(
140
+ key: string,
141
+ min: number,
142
+ max: number
143
+ ): ProviderTransaction;
144
+ zrem(key: string, member: string): ProviderTransaction;
145
+ zrank(key: string, member: string): ProviderTransaction;
146
+ scan(cursor: number, count?: number): ProviderTransaction;
147
+ rename(oldKey: string, newKey: string): ProviderTransaction;
148
+ // Add other methods as needed
149
+ }