@onereach/state-machine-step-service 1.0.0-framework.11
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/README.md +3 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { NotFoundError, StateMachineInstanceDriver, StateMachineInstanceStore, StateTemplateDriver, StateTemplateStore } from "@onereach/state-machine-store";
|
|
2
|
+
import { BasicThreadService } from "@onereach/flow-sdk/services/basic.js";
|
|
3
|
+
import { JsonSchemaValidatorCompiler, SchemaValidationError, StateTemplateValidatorCompiler } from "@onereach/state-machine-core";
|
|
4
|
+
import { StateMachineRuntime } from "@onereach/state-machine-runtime";
|
|
5
|
+
import { StateMachineService } from "@onereach/state-machine-service";
|
|
6
|
+
import { CONFIG, ICacheFacade, IThread } from "@onereach/flow-sdk/types/index.js";
|
|
7
|
+
export * from "@onereach/state-machine-store";
|
|
8
|
+
export * from "@onereach/state-machine-core";
|
|
9
|
+
export * from "@onereach/state-machine-driver-or-flow-mf";
|
|
10
|
+
export * from "@onereach/state-machine-runtime";
|
|
11
|
+
export * from "@onereach/state-machine-service";
|
|
12
|
+
export * from "@onereach/state-machine-validation-ajv";
|
|
13
|
+
//#region src/services/types.d.ts
|
|
14
|
+
type InitializeStateMachineContext = Record<string, unknown>;
|
|
15
|
+
interface StateMachineProcessCache<TContext> {
|
|
16
|
+
jsonSchemaCompiler: JsonSchemaValidatorCompiler;
|
|
17
|
+
compiler: StateTemplateValidatorCompiler;
|
|
18
|
+
templateDriver: StateTemplateDriver;
|
|
19
|
+
instanceDriver: StateMachineInstanceDriver;
|
|
20
|
+
templates: StateTemplateStore;
|
|
21
|
+
instances: StateMachineInstanceStore;
|
|
22
|
+
runtime: StateMachineRuntime<TContext>;
|
|
23
|
+
service: StateMachineService<TContext>;
|
|
24
|
+
}
|
|
25
|
+
type InitializeStateMachineOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* The TTL for the state machine instance object.
|
|
28
|
+
*
|
|
29
|
+
* @default 604_800_000 // (1 week in milliseconds)
|
|
30
|
+
*/
|
|
31
|
+
instanceTtl?: number;
|
|
32
|
+
/**
|
|
33
|
+
This is used to override default cache for integration tests.
|
|
34
|
+
*/
|
|
35
|
+
cache?: ICacheFacade;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/services/state-machine.d.ts
|
|
39
|
+
declare class StateMachineThreadService<TConfig extends CONFIG, TContext> extends BasicThreadService<TConfig> {
|
|
40
|
+
readonly stateMachine: StateMachineService<TContext>;
|
|
41
|
+
/**
|
|
42
|
+
* Cache key for the state machine process cache.
|
|
43
|
+
* It represents the combination of used libraries and their versions.
|
|
44
|
+
*/
|
|
45
|
+
readonly cacheKey = "sm:or-mf:ajv:v1";
|
|
46
|
+
constructor(thread: IThread<TConfig>, options?: InitializeStateMachineOptions);
|
|
47
|
+
private initializeStateMachine;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { type InitializeStateMachineContext, type InitializeStateMachineOptions, NotFoundError, SchemaValidationError, type StateMachineProcessCache, StateMachineThreadService };
|
|
51
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/services/types.ts","../src/services/state-machine.ts"],"mappings":";;;;;;;;;;;;;KAWY,gCAAgC;UAE3B,yBAAyB;EACxC,oBAAoB;EACpB,UAAU;EACV,gBAAgB;EAChB,gBAAgB;EAChB,WAAW;EACX,WAAW;EACX,SAAS,oBAAoB;EAC7B,SAAS,oBAAoB;;KAGnB;;;;;;EAMV;;;;EAKA,QAAQ;;;;cCrBG,0BAA0B,gBAAgB,QAAQ,kBAAkB,mBAAmB;WAClF,cAAc,oBAAoB;;;;;WAMlC;EAEJ,YAAA,QAAQ,QAAQ,UAAU,UAAU;UAKxC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{NotFoundError as e,StateMachineInstanceStore as t,StateTemplateStore as n}from"@onereach/state-machine-store";import{BasicThreadService as r}from"@onereach/flow-sdk/services/basic.js";import{SchemaValidationError as i,StateTemplateValidatorCompiler as a}from"@onereach/state-machine-core";import{OrFlowStorageStateInstanceDriver as o,OrFlowStorageStateTemplateDriver as s}from"@onereach/state-machine-driver-or-flow-mf";import{StateMachineRuntime as c}from"@onereach/state-machine-runtime";import{StateMachineService as l}from"@onereach/state-machine-service";import{AjvJsonSchemaValidatorCompiler as u}from"@onereach/state-machine-validation-ajv";var d=class extends r{stateMachine;cacheKey=`sm:or-mf:ajv:v1`;constructor(e,t){super(e),this.stateMachine=this.initializeStateMachine(t)}initializeStateMachine(e){this.process.cache[this.cacheKey]??={};let r=this.process.cache[this.cacheKey];return r.jsonSchemaCompiler??=new u,r.compiler??=new a(r.jsonSchemaCompiler),r.templateDriver??=new s(this.thread.process,{cache:e?.cache}),r.instanceDriver??=new o(this.thread.process,{ttl:e?.instanceTtl,cache:e?.cache}),r.templates??=new n(r.templateDriver,r.compiler),r.instances??=new t(r.instanceDriver,r.templates),r.runtime??=new c,r.service??=new l(r.instances,r.runtime),r.service}};export{e as NotFoundError,i as SchemaValidationError,d as StateMachineThreadService};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/services/state-machine.ts"],"sourcesContent":["import { BasicThreadService } from '@onereach/flow-sdk/services/basic.js';\nimport type { IThread, CONFIG } from '@onereach/flow-sdk/types/index.js';\nimport { StateTemplateValidatorCompiler } from '@onereach/state-machine-core';\nimport {\n OrFlowStorageStateInstanceDriver,\n OrFlowStorageStateTemplateDriver,\n} from '@onereach/state-machine-driver-or-flow-mf';\nimport { StateMachineRuntime } from '@onereach/state-machine-runtime';\nimport { StateMachineService } from '@onereach/state-machine-service';\nimport { StateMachineInstanceStore, StateTemplateStore } from '@onereach/state-machine-store';\nimport { AjvJsonSchemaValidatorCompiler } from '@onereach/state-machine-validation-ajv';\n\nimport type { InitializeStateMachineOptions, StateMachineProcessCache } from './types.ts';\n\nexport class StateMachineThreadService<TConfig extends CONFIG, TContext> extends BasicThreadService<TConfig> {\n public readonly stateMachine: StateMachineService<TContext>;\n\n /**\n * Cache key for the state machine process cache.\n * It represents the combination of used libraries and their versions.\n */\n public readonly cacheKey = 'sm:or-mf:ajv:v1';\n\n constructor(thread: IThread<TConfig>, options?: InitializeStateMachineOptions) {\n super(thread);\n this.stateMachine = this.initializeStateMachine<TContext>(options);\n }\n\n private initializeStateMachine<TContext>(options?: InitializeStateMachineOptions): StateMachineService<TContext> {\n this.process.cache[this.cacheKey] ??= {};\n const processCache = this.process.cache[this.cacheKey] as Partial<StateMachineProcessCache<TContext>>;\n\n processCache.jsonSchemaCompiler ??= new AjvJsonSchemaValidatorCompiler();\n processCache.compiler ??= new StateTemplateValidatorCompiler(processCache.jsonSchemaCompiler);\n processCache.templateDriver ??= new OrFlowStorageStateTemplateDriver<TConfig>(this.thread.process, {\n cache: options?.cache,\n });\n processCache.instanceDriver ??= new OrFlowStorageStateInstanceDriver<TConfig>(this.thread.process, {\n ttl: options?.instanceTtl,\n cache: options?.cache,\n });\n processCache.templates ??= new StateTemplateStore(processCache.templateDriver, processCache.compiler);\n processCache.instances ??= new StateMachineInstanceStore(processCache.instanceDriver, processCache.templates);\n processCache.runtime ??= new StateMachineRuntime<TContext>();\n processCache.service ??= new StateMachineService(processCache.instances, processCache.runtime);\n\n return processCache.service;\n }\n}\n"],"mappings":"+oBAcA,IAAa,EAAb,cAAiF,CAA4B,CAC3G,aAMA,SAA2B,kBAE3B,YAAY,EAA0B,EAAyC,CAC7E,MAAM,CAAM,EACZ,KAAK,aAAe,KAAK,uBAAiC,CAAO,CACnE,CAEA,uBAAyC,EAAwE,CAC/G,KAAK,QAAQ,MAAM,KAAK,YAAc,CAAC,EACvC,IAAM,EAAe,KAAK,QAAQ,MAAM,KAAK,UAgB7C,MAdA,GAAa,qBAAuB,IAAI,EACxC,EAAa,WAAa,IAAI,EAA+B,EAAa,kBAAkB,EAC5F,EAAa,iBAAmB,IAAI,EAA0C,KAAK,OAAO,QAAS,CACjG,MAAO,GAAS,KAClB,CAAC,EACD,EAAa,iBAAmB,IAAI,EAA0C,KAAK,OAAO,QAAS,CACjG,IAAK,GAAS,YACd,MAAO,GAAS,KAClB,CAAC,EACD,EAAa,YAAc,IAAI,EAAmB,EAAa,eAAgB,EAAa,QAAQ,EACpG,EAAa,YAAc,IAAI,EAA0B,EAAa,eAAgB,EAAa,SAAS,EAC5G,EAAa,UAAY,IAAI,EAC7B,EAAa,UAAY,IAAI,EAAoB,EAAa,UAAW,EAAa,OAAO,EAEtF,EAAa,OACtB,CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onereach/state-machine-step-service",
|
|
3
|
+
"version": "1.0.0-framework.11",
|
|
4
|
+
"description": "Step thread service for State Machine",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"onereach",
|
|
7
|
+
"toolkit",
|
|
8
|
+
"state-machine"
|
|
9
|
+
],
|
|
10
|
+
"author": "OneReach Development Team <dev.team@onereach.ai>",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"!dist/metafile*.json"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@arethetypeswrong/core": "^0.18.5",
|
|
22
|
+
"@onereach/flow-sdk": "v9.0.0-monosplit.5",
|
|
23
|
+
"@types/source-map-support": "^0.5.10",
|
|
24
|
+
"publint": "^0.3.24",
|
|
25
|
+
"rollup-plugin-visualizer": "^7.1.1",
|
|
26
|
+
"tsdown": "^0.22.14",
|
|
27
|
+
"typescript": "^6.0.3"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@onereach/state-machine-core": "1.0.0-framework.10",
|
|
31
|
+
"@onereach/state-machine-driver-or-flow-mf": "1.0.0-framework.10",
|
|
32
|
+
"@onereach/state-machine-runtime": "1.0.0-framework.11",
|
|
33
|
+
"@onereach/state-machine-service": "1.0.0-framework.11",
|
|
34
|
+
"@onereach/state-machine-store": "1.0.0-framework.10",
|
|
35
|
+
"@onereach/state-machine-validation-ajv": "1.0.0-framework.10"
|
|
36
|
+
},
|
|
37
|
+
"exports": {
|
|
38
|
+
".": "./dist/index.mjs",
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown --config tsdown.config.mts",
|
|
43
|
+
"build:visualize": "VISUALIZE=1 pnpm build",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"preversion_": "pnpm build && pnpm test",
|
|
46
|
+
"publish:rc": "pnpm version prerelease --preid rc && pnpm publish --tag rc",
|
|
47
|
+
"test": "pnpm run unit",
|
|
48
|
+
"unit": "vitest run",
|
|
49
|
+
"preversion": "pnpm build"
|
|
50
|
+
}
|
|
51
|
+
}
|