anbaric-tsapi 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,12 +11,10 @@ synchronous.
|
|
|
11
11
|
|
|
12
12
|
## Value classes
|
|
13
13
|
|
|
14
|
-
**`Job`** — a unit of work moving through a workflow.
|
|
15
|
-
`new Job(id, properties = new Map(),
|
|
16
|
-
`
|
|
17
|
-
`
|
|
18
|
-
records `{from, to, actor}` into `transitions` and bumps `lastUpdated` when
|
|
19
|
-
the transition's predicate accepts the job.
|
|
14
|
+
**`Job`** — a unit of work moving through a workflow. Immutable.
|
|
15
|
+
`new Job(id, properties = new Map(), state, workflowId?, startedBy = "system", startedAt = new Date(), lastUpdated = startedAt)`.
|
|
16
|
+
`state` is a readonly string; a job never changes in place — `JobPersistence.save`
|
|
17
|
+
constructs a new `Job` at the target `state` and stamps `lastUpdated`.
|
|
20
18
|
|
|
21
19
|
**`State`** — `new State(id, actions = [], transitions = [])`, plus
|
|
22
20
|
`subscribe(action)` to add an action later.
|
|
@@ -27,7 +25,7 @@ accept) gates whether the action runs, and
|
|
|
27
25
|
`run : (job) => Promise<Map<string, any>>` (defaults to an empty map)
|
|
28
26
|
returns the property changes the action wants. `run` never mutates the job.
|
|
29
27
|
|
|
30
|
-
**`Actor`** — an interface, pure identity: `{ type : "HUMAN" | "CODE" | "AGENT", id : string, role : string }`.
|
|
28
|
+
**`Actor`** — an interface, pure identity: `{ type : "HUMAN" | "CODE" | "AGENT" | "SYSTEM", id : string, role : string }`.
|
|
31
29
|
Concrete `Human`, `Code`, `Agent` classes live in `anbaric-state-machine`.
|
|
32
30
|
|
|
33
31
|
**`Transition`** — `new Transition(to, predicate)`; the first accepting
|
|
@@ -37,18 +35,18 @@ transition in a state wins.
|
|
|
37
35
|
`required : boolean` (default false) and `validation : (value) => boolean`
|
|
38
36
|
(default accept).
|
|
39
37
|
|
|
40
|
-
**`JobTransition`** — `{ from : string, to : string, actor : string }`.
|
|
41
|
-
|
|
42
38
|
**Serialization** — `serializeJob(job) : SerializedJob` and
|
|
43
39
|
`deserializeJob(serialized) : Job` define the wire shape used by the cloud
|
|
44
40
|
clients and platform (dates as ISO strings, properties as a plain object).
|
|
45
41
|
|
|
46
42
|
## Contracts
|
|
47
43
|
|
|
48
|
-
**`JobPersistence`** —
|
|
49
|
-
|
|
50
|
-
`
|
|
51
|
-
`lastUpdated`)
|
|
44
|
+
**`JobPersistence`** — an abstract class taking an `Auditor`; every method takes
|
|
45
|
+
the acting `Actor` and audits before deferring to an abstract `…Internal`.
|
|
46
|
+
`create(actor, job)`, `save(actor, changeDescription, job, properties?, state?)`
|
|
47
|
+
(applies the property/state change and stamps `lastUpdated`),
|
|
48
|
+
`retrieve(id, actor)` (throws `No job found with id "x"`), `delete(id, actor)`,
|
|
49
|
+
`list(actor, pageSize?, page?)`.
|
|
52
50
|
|
|
53
51
|
**`Queue`** — `enqueue(jobId, workflowId)`, `schedule(jobId, workflowId, due)`.
|
|
54
52
|
**`Dequeue extends Queue`** adds `dequeueSome() : Promise<Array<QueueMessage>>`;
|
|
@@ -58,10 +56,15 @@ Delivery is at-least-once: consumers must tolerate redelivery.
|
|
|
58
56
|
**`Consumer`** — `subscribe(workflowId, processJob)` routes deliveries for
|
|
59
57
|
one workflow to a callback; `cleanUp()` releases resources.
|
|
60
58
|
|
|
61
|
-
**`JsonStore`** —
|
|
62
|
-
`
|
|
59
|
+
**`JsonStore`** — abstract, `Auditor`-backed and actor-audited like
|
|
60
|
+
`JobPersistence`: `create(actor, id, document)`,
|
|
61
|
+
`save(actor, changeDescription, id, document)`, `retrieve(id, actor)`,
|
|
62
|
+
`delete(id, actor)`, `list(actor, pageSize?, page?)` (returns the document
|
|
63
|
+
values, not ids); implementations validate against a `JsonSchema` when one is given.
|
|
63
64
|
|
|
64
|
-
**`SecretStore`** — `
|
|
65
|
+
**`SecretStore`** — abstract, `Auditor`-backed: `create(actor, name, value)`,
|
|
66
|
+
`save(actor, changeDescription, name, value)`, `retrieve(name, actor)`,
|
|
67
|
+
`delete(name, actor)`, `list(actor)`. Secret values never appear in audit details.
|
|
65
68
|
|
|
66
69
|
**`QueueMessage`** — `{ jobId, workflowId }`; part of the platform's private
|
|
67
70
|
wire protocol (in `api/cloud/`), exported because `Dequeue` returns it.
|
package/package.json
CHANGED