@hotmeshio/hotmesh 0.5.3 → 0.5.4

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 (38) hide show
  1. package/README.md +67 -134
  2. package/build/index.d.ts +1 -3
  3. package/build/index.js +1 -5
  4. package/build/modules/enums.d.ts +4 -0
  5. package/build/modules/enums.js +5 -1
  6. package/build/modules/utils.d.ts +1 -9
  7. package/build/modules/utils.js +0 -6
  8. package/build/package.json +3 -4
  9. package/build/services/connector/factory.d.ts +2 -2
  10. package/build/services/connector/factory.js +11 -8
  11. package/build/services/connector/providers/postgres.d.ts +47 -0
  12. package/build/services/connector/providers/postgres.js +107 -0
  13. package/build/services/hotmesh/index.d.ts +8 -0
  14. package/build/services/hotmesh/index.js +27 -0
  15. package/build/services/memflow/client.d.ts +1 -1
  16. package/build/services/memflow/client.js +8 -6
  17. package/build/services/memflow/worker.js +3 -0
  18. package/build/services/pipe/functions/cron.js +1 -1
  19. package/build/services/store/providers/postgres/kvtables.js +19 -6
  20. package/build/services/store/providers/postgres/postgres.js +13 -2
  21. package/build/services/stream/providers/postgres/postgres.d.ts +6 -3
  22. package/build/services/stream/providers/postgres/postgres.js +169 -59
  23. package/build/services/sub/providers/postgres/postgres.d.ts +9 -0
  24. package/build/services/sub/providers/postgres/postgres.js +109 -18
  25. package/build/services/worker/index.js +4 -0
  26. package/build/types/hotmesh.d.ts +19 -5
  27. package/build/types/index.d.ts +0 -2
  28. package/env.example +11 -0
  29. package/index.ts +0 -4
  30. package/package.json +3 -4
  31. package/build/services/meshdata/index.d.ts +0 -795
  32. package/build/services/meshdata/index.js +0 -1235
  33. package/build/services/meshos/index.d.ts +0 -293
  34. package/build/services/meshos/index.js +0 -547
  35. package/build/types/manifest.d.ts +0 -52
  36. package/build/types/manifest.js +0 -2
  37. package/build/types/meshdata.d.ts +0 -252
  38. package/build/types/meshdata.js +0 -2
@@ -1,293 +0,0 @@
1
- import { MeshData } from '../meshdata/index';
2
- import * as Types from '../../types';
3
- import { ProviderConfig, ProvidersConfig } from '../../types/provider';
4
- /**
5
- * MeshOS is an abstract base class for schema-driven entity management within the Mesh network.
6
- * It provides a foundation for defining custom entities.
7
- * By subclassing MeshOS, you can create entities with specific schemas and behaviors, enabling
8
- * structured data storage, retrieval, and transactional workflows.
9
- *
10
- * ### Subclassing MeshOS
11
- *
12
- * Standard CRUD methods are included and use your provided schema to
13
- * fields to return in the response: create, retrieve, update, delete.
14
- *
15
- * Search methods are included and use your provided schema to
16
- * fields to return in the response: count, find, aggregate.
17
- *
18
- * Implement other methods as needed for the entity's
19
- * functionality; For example, subclass/override methods like `create`
20
- * to also spawn a transactional workflow
21
- *
22
- * @example
23
- * ```typescript
24
- * import { MeshOS } from '@hotmeshio/hotmesh';
25
- * import { Types } from '@hotmeshio/hotmesh';
26
- * import { schema } from './schema'; // Import your schema
27
- * import * as workflows from './workflows';
28
- *
29
- * class Widget extends MeshOS {
30
- *
31
- * //Subclass the `connect` method to connect workers and
32
- * // hooks (optional) when the container starts
33
- * async connect() {
34
- * await this.meshData.connect({
35
- * entity: this.getEntity(),
36
- * //the `target widget workflow` runs as a transaction
37
- * target: function() {
38
- * return { hello: 'world' };
39
- * },
40
- * options: {
41
- * namespace: this.getNamespace(),
42
- * taskQueue: this.getTaskQueue(),
43
- * },
44
- * });
45
- * }
46
- *
47
- * // subclass the `create` method to start a transactional
48
- * // workflow; use the options/search field to set default
49
- * // record data `{ ...input}` and invoke the `target widget workflow`
50
- * async create(input: Types.StringAnyType): Promise<Types.StringStringType> {
51
- * return await this.meshData.exec<Types.StringStringType>({
52
- * entity: this.getEntity(),
53
- * args: [{ ...input }],
54
- * options: {
55
- * id: input.id,
56
- * ttl: '6 months',
57
- * taskQueue: this.getTaskQueue(),
58
- * namespace: this.getNamespace(),
59
- * search: { data: { ...input }},
60
- * },
61
- * });
62
- * }
63
- * }
64
- * ```
65
- *
66
- * ### Defining the Schema
67
- *
68
- * The schema defines the data model for your entity and is used for indexing and searching within the mesh network.
69
- * Each field in the schema specifies the data type, whether it's required, and other indexing options.
70
- *
71
- * Here's an example of a schema (`schema.ts`):
72
- *
73
- * ```typescript
74
- * import { Types } from '@hotmeshio/hotmesh';
75
- *
76
- * export const schema: Types.WorkflowSearchSchema = {
77
- * /**
78
- * * Unique identifier for the widget, including the entity prefix.
79
- * *\/
80
- * id: {
81
- * type: 'TAG',
82
- * primitive: 'string',
83
- * required: true,
84
- * examples: ['H56789'],
85
- * },
86
- * /**
87
- * * entity type
88
- * *\/
89
- * $entity: {
90
- * type: 'TAG',
91
- * primitive: 'string',
92
- * required: true,
93
- * examples: ['widget'],
94
- * },
95
- * /**
96
- * * Field indicating whether the widget is active ('y') or pruned ('n').
97
- * *\/
98
- * active: {
99
- * type: 'TAG',
100
- * primitive: 'string',
101
- * required: true,
102
- * examples: ['y', 'n'],
103
- * },
104
- * // ... other fields as needed
105
- * };
106
- * ```
107
- *
108
- * In your entity class (`Widget`), you use this schema in the
109
- * `getSearchOptions` method to define how your entity's data
110
- * is indexed and searched.
111
- */
112
- declare abstract class MeshOS {
113
- meshData: MeshData;
114
- connected: boolean;
115
- entity: string;
116
- namespace: string;
117
- schema: Types.WorkflowSearchSchema;
118
- taskQueue: string;
119
- static databases: Record<string, Types.DB>;
120
- static namespaces: Types.Namespaces;
121
- static entities: Record<string, Types.Entity>;
122
- static schemas: Record<string, Types.WorkflowSearchSchema>;
123
- static profiles: Types.Profiles;
124
- static classes: Record<string, typeof MeshOS>;
125
- static logger: Types.ILogger;
126
- /**
127
- * Instances of MeshOS are typically initialized as a set, using a manifest.json
128
- * file that describes statically the fully set names, passwords, entities, etc.
129
- * The static init method is invoked to start this process (typically at server
130
- * startup).
131
- */
132
- constructor(providerConfig: ProviderConfig | ProvidersConfig, namespace: string, entity: string, taskQueue: string, schema: Types.WorkflowSearchSchema);
133
- /**
134
- * Return entity (e.g, book, library, user)
135
- */
136
- getEntity(): string;
137
- /**
138
- * Get Search options (initializes the search index, specific to the backend provider)
139
- */
140
- getSearchOptions(): Types.WorkflowSearchOptions;
141
- /**
142
- * Speficy a more-specific task queue than the default queue (v1, v1priority, v2, acmecorp, etc)
143
- */
144
- getTaskQueue(): string;
145
- /**
146
- * Initialize MeshData instance (this backs/supports the class
147
- * --the true provider of functionality)
148
- */
149
- private initializeMeshData;
150
- /**
151
- * Default target function
152
- */
153
- protected defaultTargetFn(): Promise<string>;
154
- /**
155
- * Get namespace
156
- */
157
- getNamespace(): string;
158
- /**
159
- * Get schema
160
- */
161
- getSchema(): Types.WorkflowSearchSchema;
162
- /**
163
- * Connect to the database
164
- */
165
- connect(): Promise<void>;
166
- /**
167
- * Create the search index
168
- */
169
- index(): Promise<void>;
170
- /**
171
- * Shutdown all connections
172
- */
173
- static shutdown(): Promise<void>;
174
- /**
175
- * Get index name
176
- */
177
- getIndexName(): string;
178
- /**
179
- * Create the data record
180
- * NOTE: subclasses should override this method (or create
181
- * an alternate method) for invoking a workflow when
182
- * creating the record.
183
- */
184
- create(body: Record<string, any>): Promise<Types.StringStringType>;
185
- /**
186
- * Retrieve the record data
187
- */
188
- retrieve(id: string, sparse?: boolean): Promise<Types.StringStringType>;
189
- /**
190
- * Update the record data
191
- */
192
- update(id: string, body: Record<string, any>): Promise<Types.StringStringType>;
193
- /**
194
- * Delete the record/workflow
195
- */
196
- delete(id: string): Promise<boolean>;
197
- /**
198
- * Find matching records
199
- */
200
- find(query?: {
201
- field: string;
202
- is: '=' | '[]' | '>=' | '<=';
203
- value: string;
204
- }[], start?: number, size?: number): Promise<{
205
- count: number;
206
- query: string;
207
- data: Types.StringStringType[];
208
- }>;
209
- /**
210
- * Count matching entities
211
- */
212
- count(query: {
213
- field: string;
214
- is: '=' | '[]' | '>=' | '<=';
215
- value: string;
216
- }[]): Promise<number>;
217
- /**
218
- * Aggregate matching entities
219
- */
220
- aggregate(filter?: {
221
- field: string;
222
- is: '=' | '[]' | '>=' | '<=';
223
- value: string;
224
- }[], apply?: {
225
- expression: string;
226
- as: string;
227
- }[], rows?: string[], columns?: string[], reduce?: {
228
- operation: string;
229
- as: string;
230
- property?: string;
231
- }[], sort?: {
232
- field: string;
233
- order: 'ASC' | 'DESC';
234
- }[], start?: number, size?: number): Promise<{
235
- count: number;
236
- query: string;
237
- data: Types.StringStringType[];
238
- }>;
239
- /**
240
- * Build aggregate command
241
- */
242
- private buildAggregateCommand;
243
- /**
244
- * Build filter command
245
- */
246
- private buildFilterCommand;
247
- /**
248
- * Instance initializer
249
- */
250
- init(search?: boolean): Promise<void>;
251
- /**
252
- * Register a database
253
- */
254
- static registerDatabase(id: string, config: Types.DB): void;
255
- /**
256
- * Register a namespace
257
- */
258
- static registerNamespace(id: string, config: Types.Namespace): void;
259
- /**
260
- * Register an entity
261
- */
262
- static registerEntity(id: string, config: Types.Entity): void;
263
- /**
264
- * Register a schema
265
- */
266
- static registerSchema(id: string, schema: Types.WorkflowSearchSchema): void;
267
- /**
268
- * Register a profile
269
- */
270
- static registerProfile(id: string, config: Types.Profile): void;
271
- /**
272
- * Register a class
273
- */
274
- static registerClass(id: string, entityClass: typeof MeshOS): void;
275
- /**
276
- * Initialize profiles
277
- */
278
- static init(p?: Types.Profiles): Promise<void>;
279
- /**
280
- * Find entity instance
281
- */
282
- static findEntity(database: string, namespace: string, entity: string): Types.EntityInstanceTypes | undefined;
283
- /**
284
- * Find schemas
285
- */
286
- static findSchemas(database: string, ns: string): Record<string, Types.WorkflowSearchSchema>;
287
- /**
288
- * Serialize profiles to JSON
289
- */
290
- static toJSON(p?: Types.Profiles): any;
291
- workflow: {};
292
- }
293
- export { MeshOS };