@medicine-wheel/events 0.18.0 → 0.19.0
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 +64 -4
- package/dist/catalog.d.ts +100 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +34 -1
- package/dist/catalog.js.map +1 -1
- package/dist/cli.d.ts +24 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +167 -0
- package/dist/cli.js.map +1 -0
- package/dist/decide.d.ts +9 -2
- package/dist/decide.d.ts.map +1 -1
- package/dist/decide.js +26 -8
- package/dist/decide.js.map +1 -1
- package/dist/envelope.d.ts.map +1 -1
- package/dist/envelope.js +4 -1
- package/dist/envelope.js.map +1 -1
- package/dist/git.d.ts +75 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +197 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/publish.d.ts +15 -7
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +26 -23
- package/dist/publish.js.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -1
- package/dist/schema.js.map +1 -1
- package/package.json +12 -3
- package/schema/asyncapi.json +470 -2
- package/schema/wheel-events.schema.json +389 -2
package/README.md
CHANGED
|
@@ -24,10 +24,16 @@ const schema = require('@medicine-wheel/events/schema/wheel-events.schema.json')
|
|
|
24
24
|
const { WHEEL_EVENT_CATALOG, filterEvents } = require('@medicine-wheel/events');
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
A payload carries references and labels
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
A payload carries references and labels: ids, a direction, a type. A cycle's
|
|
28
|
+
question, a beat's prose and a diary entry's text stay in the wheel. To read
|
|
29
|
+
one, fetch the record by `subject.id` from the wheel that wrote the event
|
|
30
|
+
(`source.instance`).
|
|
31
|
+
|
|
32
|
+
There is one exception. When two chronicle episodes are related, the
|
|
33
|
+
`chronicle.lineage.*` events carry the sentence that says why
|
|
34
|
+
(`payload.relation`). That sentence is already committed to the episode's
|
|
35
|
+
`episode.yaml`, so the event repeats it rather than releasing it. These
|
|
36
|
+
events say so with `privacy: { classification: "chronicle", content_included: true }`.
|
|
31
37
|
|
|
32
38
|
## The envelope
|
|
33
39
|
|
|
@@ -69,6 +75,7 @@ jgwill/Miadi's `MiadiEventEnvelope` 0.1.0
|
|
|
69
75
|
| chronicle episode | `chronicle.episode.registered`, `chronicle.episode.amended`, `chronicle.episode.removed` |
|
|
70
76
|
| memory conclusion | `memory.conclusion.recorded`, `memory.conclusion.judged`, `memory.conclusion.amended`, `memory.conclusion.removed` |
|
|
71
77
|
| node | `node.created`, `node.amended`, `node.removed` |
|
|
78
|
+
| chronicle lineage | `chronicle.lineage.made`, `chronicle.lineage.amended`, `chronicle.lineage.removed` — a relation between two chronicle episodes, with the why |
|
|
72
79
|
| relation | `relation.made`, `relation.amended`, `relation.removed` |
|
|
73
80
|
|
|
74
81
|
`WHEEL_EVENT_CATALOG` says, for each: what happened, which write produces it,
|
|
@@ -90,6 +97,51 @@ The deciders (`cycleWritten`, `beatWritten`, `beatWitnessed`, `ceremonyWritten`,
|
|
|
90
97
|
`*Removed` ones) are shared by the wheel's HTTP routes and the MCP server's
|
|
91
98
|
local store, so the same act leaves the same event whichever door it used.
|
|
92
99
|
|
|
100
|
+
## Carried by git
|
|
101
|
+
|
|
102
|
+
Before any broker exists, the log can travel through the data repository it
|
|
103
|
+
already lives in. This is not a publisher: nothing here sends one event and
|
|
104
|
+
waits for a receipt.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { commitEventLog, followEventLog } from '@medicine-wheel/events/git';
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**On the wheel's side,** `commitEventLog` commits `events.jsonl` and nothing
|
|
111
|
+
else. Anything else that is changed or staged stays exactly as it was. It then
|
|
112
|
+
pushes. It pushes only commits that touch the log alone. When the branch also
|
|
113
|
+
holds someone's own data commit, it holds the push and says why. A log the
|
|
114
|
+
repository ignores is reported as an error, not committed by force.
|
|
115
|
+
|
|
116
|
+
In the wheel, set `MW_EVENTS_GIT_SYNC=push` (or `commit`). The wheel then
|
|
117
|
+
commits:
|
|
118
|
+
|
|
119
|
+
- about 30 seconds after events are recorded, so a burst travels as one commit;
|
|
120
|
+
- on start;
|
|
121
|
+
- every 10 minutes.
|
|
122
|
+
|
|
123
|
+
`mw events sync` commits now. `GET /api/events/git` shows the last pass.
|
|
124
|
+
|
|
125
|
+
**Anywhere else,** clone the data repository, then follow it:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npx -p @medicine-wheel/events mw-events follow ~/mw-data --exec ./on-event.sh
|
|
129
|
+
npx -p @medicine-wheel/events mw-events follow ~/mw-data --every 60 # pull every minute, print new events
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`follow` pulls, then hands each event this follower has not handled yet to
|
|
133
|
+
`--exec`, oldest first:
|
|
134
|
+
|
|
135
|
+
- The event's JSON goes on stdin.
|
|
136
|
+
- `MW_EVENT_ID`, `MW_EVENT_TYPE`, `MW_EVENT_SUBJECT_KIND`, `MW_EVENT_SUBJECT_ID`,
|
|
137
|
+
`MW_EVENT_CORRELATION` and `MW_EVENT_OBSERVED_AT` go in the environment.
|
|
138
|
+
- Exit 0 and the follower moves past that event. Anything else and it stops,
|
|
139
|
+
and the same event comes first next time.
|
|
140
|
+
|
|
141
|
+
The cursor lives in `--state-dir`, which defaults to
|
|
142
|
+
`~/.local/state/medicine-wheel-events`, never in the clone. Use `--name` to give
|
|
143
|
+
two followers of one clone separate places.
|
|
144
|
+
|
|
93
145
|
## Publishing
|
|
94
146
|
|
|
95
147
|
```ts
|
|
@@ -120,3 +172,11 @@ hooks-gateway once it accepts this envelope. A broker client would be another
|
|
|
120
172
|
|
|
121
173
|
In the wheel, set `MW_EVENTS_PUBLISH_URL` (and `MW_EVENTS_PUBLISH_TOKEN`) to turn
|
|
122
174
|
publishing on. `GET /api/health` then reports how many events are still owed.
|
|
175
|
+
|
|
176
|
+
## Foundations
|
|
177
|
+
|
|
178
|
+
[docs/foundations/event-driven-architecture.md](../../docs/foundations/event-driven-architecture.md)
|
|
179
|
+
covers the literature behind this package and maps each idea to the code:
|
|
180
|
+
notification versus event-carried state, the log, the outbox, idempotent
|
|
181
|
+
receivers, dead letters and AsyncAPI. It also covers why the logic lives in the
|
|
182
|
+
wheel and Miadi consumes it.
|
package/dist/catalog.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* them reads the record back by the subject's id.
|
|
13
13
|
*/
|
|
14
14
|
/** Version of this catalog. It moves when an event or a payload field is added or changed. */
|
|
15
|
-
export declare const CATALOG_VERSION = "0.
|
|
15
|
+
export declare const CATALOG_VERSION = "0.3.0";
|
|
16
16
|
export type WheelSubjectKind = 'cycle' | 'beat' | 'ceremony' | 'diary' | 'node' | 'relation';
|
|
17
17
|
export interface PayloadField {
|
|
18
18
|
type: 'string' | 'number' | 'boolean' | 'string[]';
|
|
@@ -27,6 +27,14 @@ export interface EventDefinition {
|
|
|
27
27
|
writtenBy: string;
|
|
28
28
|
/** What `correlation_id` groups, when the event carries one. */
|
|
29
29
|
correlation?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The payload carries a person's words. Set only where those words are
|
|
32
|
+
* already published elsewhere — an episode manifest — so the event repeats
|
|
33
|
+
* them rather than releasing them.
|
|
34
|
+
*/
|
|
35
|
+
contentIncluded?: true;
|
|
36
|
+
/** `privacy.classification`; `internal` when absent. */
|
|
37
|
+
classification?: string;
|
|
30
38
|
payload: Record<string, PayloadField>;
|
|
31
39
|
}
|
|
32
40
|
export declare const WHEEL_EVENT_CATALOG: {
|
|
@@ -586,6 +594,97 @@ export declare const WHEEL_EVENT_CATALOG: {
|
|
|
586
594
|
};
|
|
587
595
|
};
|
|
588
596
|
};
|
|
597
|
+
readonly 'chronicle.lineage.made': {
|
|
598
|
+
readonly subject: "relation";
|
|
599
|
+
readonly summary: "One chronicle episode was related to another — it continues from it, or relates to it — with the words that say why.";
|
|
600
|
+
readonly writtenBy: "POST /api/edges between two chronicle_episode nodes; the Miadi lineage door (POST /api/chronicle/episodes/{ref}/lineage) writes there";
|
|
601
|
+
readonly correlation: "the episode the relation starts from";
|
|
602
|
+
readonly contentIncluded: true;
|
|
603
|
+
readonly classification: "chronicle";
|
|
604
|
+
readonly payload: {
|
|
605
|
+
readonly from_id: {
|
|
606
|
+
readonly type: "string";
|
|
607
|
+
readonly required: true;
|
|
608
|
+
readonly description: "The episode the relation starts from (`chronicle:<folder>`).";
|
|
609
|
+
};
|
|
610
|
+
readonly to_id: {
|
|
611
|
+
readonly type: "string";
|
|
612
|
+
readonly required: true;
|
|
613
|
+
readonly description: "The episode it relates to (`chronicle:<folder>`).";
|
|
614
|
+
};
|
|
615
|
+
readonly relationship_type: {
|
|
616
|
+
readonly type: "string";
|
|
617
|
+
readonly required: true;
|
|
618
|
+
readonly description: "`continues_from` or `relates_to`.";
|
|
619
|
+
};
|
|
620
|
+
readonly relation: {
|
|
621
|
+
readonly type: "string";
|
|
622
|
+
readonly description: "Why they are related — the sentence the episode manifest (episode.yaml) carries, already committed to the chronicle.";
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
readonly 'chronicle.lineage.amended': {
|
|
627
|
+
readonly subject: "relation";
|
|
628
|
+
readonly summary: "A relation between two chronicle episodes changed — most often, the words that say why were written.";
|
|
629
|
+
readonly writtenBy: "PATCH /api/edges between two chronicle_episode nodes; POST /api/edges over an existing pair";
|
|
630
|
+
readonly correlation: "the episode the relation starts from";
|
|
631
|
+
readonly contentIncluded: true;
|
|
632
|
+
readonly classification: "chronicle";
|
|
633
|
+
readonly payload: {
|
|
634
|
+
readonly changed: {
|
|
635
|
+
readonly type: "string[]";
|
|
636
|
+
readonly required: true;
|
|
637
|
+
readonly description: "The fields the write changed. Metadata keys appear as `metadata.<key>`.";
|
|
638
|
+
};
|
|
639
|
+
readonly from_id: {
|
|
640
|
+
readonly type: "string";
|
|
641
|
+
readonly required: true;
|
|
642
|
+
readonly description: "The episode the relation starts from (`chronicle:<folder>`).";
|
|
643
|
+
};
|
|
644
|
+
readonly to_id: {
|
|
645
|
+
readonly type: "string";
|
|
646
|
+
readonly required: true;
|
|
647
|
+
readonly description: "The episode it relates to (`chronicle:<folder>`).";
|
|
648
|
+
};
|
|
649
|
+
readonly relationship_type: {
|
|
650
|
+
readonly type: "string";
|
|
651
|
+
readonly required: true;
|
|
652
|
+
readonly description: "`continues_from` or `relates_to`.";
|
|
653
|
+
};
|
|
654
|
+
readonly relation: {
|
|
655
|
+
readonly type: "string";
|
|
656
|
+
readonly description: "Why they are related — the sentence the episode manifest (episode.yaml) carries, already committed to the chronicle.";
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
readonly 'chronicle.lineage.removed': {
|
|
661
|
+
readonly subject: "relation";
|
|
662
|
+
readonly summary: "A relation between two chronicle episodes was released.";
|
|
663
|
+
readonly writtenBy: "DELETE /api/edges between two chronicle_episode nodes";
|
|
664
|
+
readonly correlation: "the episode the relation starts from";
|
|
665
|
+
readonly contentIncluded: true;
|
|
666
|
+
readonly classification: "chronicle";
|
|
667
|
+
readonly payload: {
|
|
668
|
+
readonly relationship_type: {
|
|
669
|
+
readonly type: "string";
|
|
670
|
+
readonly description: "`continues_from` or `relates_to`.";
|
|
671
|
+
};
|
|
672
|
+
readonly from_id: {
|
|
673
|
+
readonly type: "string";
|
|
674
|
+
readonly required: true;
|
|
675
|
+
readonly description: "The episode the relation starts from (`chronicle:<folder>`).";
|
|
676
|
+
};
|
|
677
|
+
readonly to_id: {
|
|
678
|
+
readonly type: "string";
|
|
679
|
+
readonly required: true;
|
|
680
|
+
readonly description: "The episode it relates to (`chronicle:<folder>`).";
|
|
681
|
+
};
|
|
682
|
+
readonly relation: {
|
|
683
|
+
readonly type: "string";
|
|
684
|
+
readonly description: "Why they are related — the sentence the episode manifest (episode.yaml) carries, already committed to the chronicle.";
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
};
|
|
589
688
|
readonly 'node.created': {
|
|
590
689
|
readonly subject: "node";
|
|
591
690
|
readonly summary: "A relational node was created — a person, a place, a teaching, an agent.";
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAE7F,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;IACnD,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACvC;
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAE7F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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC3G;KAAG,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAC7G,CAAC"}
|
package/dist/catalog.js
CHANGED
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.WHEEL_EVENTS = exports.WHEEL_EVENT_CATALOG = exports.CATALOG_VERSION = void 0;
|
|
17
17
|
exports.familyOf = familyOf;
|
|
18
18
|
/** Version of this catalog. It moves when an event or a payload field is added or changed. */
|
|
19
|
-
exports.CATALOG_VERSION = '0.
|
|
19
|
+
exports.CATALOG_VERSION = '0.3.0';
|
|
20
20
|
// ── shared fields ───────────────────────────────────────────────────────────
|
|
21
21
|
const changed = { type: 'string[]', required: true, description: 'The fields the write changed. Metadata keys appear as `metadata.<key>`.' };
|
|
22
22
|
const beatFields = {
|
|
@@ -49,6 +49,12 @@ const nodeFields = {
|
|
|
49
49
|
};
|
|
50
50
|
const nodeKey = { type: { ...nodeFields.type }, kind: { ...nodeFields.kind } };
|
|
51
51
|
const about = { type: 'string', required: true, description: 'The node the conclusion is about.' };
|
|
52
|
+
const lineageFields = {
|
|
53
|
+
from_id: { type: 'string', required: true, description: 'The episode the relation starts from (`chronicle:<folder>`).' },
|
|
54
|
+
to_id: { type: 'string', required: true, description: 'The episode it relates to (`chronicle:<folder>`).' },
|
|
55
|
+
relationship_type: { type: 'string', required: true, description: '`continues_from` or `relates_to`.' },
|
|
56
|
+
relation: { type: 'string', description: 'Why they are related — the sentence the episode manifest (episode.yaml) carries, already committed to the chronicle.' },
|
|
57
|
+
};
|
|
52
58
|
const relationFields = {
|
|
53
59
|
from_id: { type: 'string', required: true, description: 'The node the relation starts from.' },
|
|
54
60
|
to_id: { type: 'string', required: true, description: 'The node the relation reaches.' },
|
|
@@ -229,6 +235,33 @@ exports.WHEEL_EVENT_CATALOG = {
|
|
|
229
235
|
correlation: 'the node the conclusion is about',
|
|
230
236
|
payload: { ...nodeKey, about: { ...about } },
|
|
231
237
|
},
|
|
238
|
+
'chronicle.lineage.made': {
|
|
239
|
+
subject: 'relation',
|
|
240
|
+
summary: 'One chronicle episode was related to another — it continues from it, or relates to it — with the words that say why.',
|
|
241
|
+
writtenBy: 'POST /api/edges between two chronicle_episode nodes; the Miadi lineage door (POST /api/chronicle/episodes/{ref}/lineage) writes there',
|
|
242
|
+
correlation: 'the episode the relation starts from',
|
|
243
|
+
contentIncluded: true,
|
|
244
|
+
classification: 'chronicle',
|
|
245
|
+
payload: { ...lineageFields },
|
|
246
|
+
},
|
|
247
|
+
'chronicle.lineage.amended': {
|
|
248
|
+
subject: 'relation',
|
|
249
|
+
summary: 'A relation between two chronicle episodes changed — most often, the words that say why were written.',
|
|
250
|
+
writtenBy: 'PATCH /api/edges between two chronicle_episode nodes; POST /api/edges over an existing pair',
|
|
251
|
+
correlation: 'the episode the relation starts from',
|
|
252
|
+
contentIncluded: true,
|
|
253
|
+
classification: 'chronicle',
|
|
254
|
+
payload: { ...lineageFields, changed },
|
|
255
|
+
},
|
|
256
|
+
'chronicle.lineage.removed': {
|
|
257
|
+
subject: 'relation',
|
|
258
|
+
summary: 'A relation between two chronicle episodes was released.',
|
|
259
|
+
writtenBy: 'DELETE /api/edges between two chronicle_episode nodes',
|
|
260
|
+
correlation: 'the episode the relation starts from',
|
|
261
|
+
contentIncluded: true,
|
|
262
|
+
classification: 'chronicle',
|
|
263
|
+
payload: { ...lineageFields, relationship_type: { type: 'string', description: '`continues_from` or `relates_to`.' } },
|
|
264
|
+
},
|
|
232
265
|
'node.created': {
|
|
233
266
|
subject: 'node',
|
|
234
267
|
summary: 'A relational node was created — a person, a place, a teaching, an agent.',
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AA+UH,4BAEC;AA/UD,8FAA8F;AACjF,QAAA,eAAe,GAAG,OAAO,CAAC;AA6BvC,+EAA+E;AAE/E,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,yEAAyE,EAAW,CAAC;AAEtJ,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mCAAmC,EAAE;IAC/F,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,sCAAsC,EAAE;IAC5F,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;IACpF,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0CAA0C,EAAE;IAC3F,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,oCAAoC,EAAE;IACnF,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8EAA8E,EAAE;CAC/G,CAAC;AAEX,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qDAAqD,EAAE;IAC5G,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE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AAO,EAAE,mFAAmF;QAC5F,SAAS,EAAE,yDAAyD;QACpE,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE;KACxC;IACD,kBAAkB,EAAE;QAClB,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,0BAA0B;QACnC,SAAS,EAAE,mBAAmB;QAC9B,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,EAAE,GAAG,cAAc,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE,EAAE;KACpH;CACiD,CAAC;AAIrD,0CAA0C;AAC7B,QAAA,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,2BAAmB,CAAqB,CAAC;AAEjF,8EAA8E;AAC9E,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mw-events — follow a Medicine Wheel's events from a clone of its data
|
|
4
|
+
* repository, anywhere git can reach.
|
|
5
|
+
*
|
|
6
|
+
* mw-events follow <clone> [--exec "<command>"] [--name <follower>]
|
|
7
|
+
* [--file <path in clone>] [--state-dir <dir>]
|
|
8
|
+
* [--no-pull] [--every <seconds>]
|
|
9
|
+
* mw-events schema [--asyncapi]
|
|
10
|
+
*
|
|
11
|
+
* `follow` pulls, then hands every event this follower has not handled yet to
|
|
12
|
+
* `--exec`, one at a time, oldest first: the event's JSON on stdin, and
|
|
13
|
+
* MW_EVENT_ID, MW_EVENT_TYPE, MW_EVENT_SUBJECT_KIND, MW_EVENT_SUBJECT_ID,
|
|
14
|
+
* MW_EVENT_CORRELATION and MW_EVENT_OBSERVED_AT in the environment. Exit 0
|
|
15
|
+
* and the follower moves past it; anything else and it stops, to try that
|
|
16
|
+
* event again on the next run. Without `--exec`, each event is printed as one
|
|
17
|
+
* JSON line. The cursor lives in --state-dir (default
|
|
18
|
+
* $XDG_STATE_HOME/medicine-wheel-events, else ~/.local/state/…), never in
|
|
19
|
+
* the clone.
|
|
20
|
+
*
|
|
21
|
+
* Exit codes: 0 done, 1 a pull or a handler failed, 2 usage error.
|
|
22
|
+
*/
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* mw-events — follow a Medicine Wheel's events from a clone of its data
|
|
5
|
+
* repository, anywhere git can reach.
|
|
6
|
+
*
|
|
7
|
+
* mw-events follow <clone> [--exec "<command>"] [--name <follower>]
|
|
8
|
+
* [--file <path in clone>] [--state-dir <dir>]
|
|
9
|
+
* [--no-pull] [--every <seconds>]
|
|
10
|
+
* mw-events schema [--asyncapi]
|
|
11
|
+
*
|
|
12
|
+
* `follow` pulls, then hands every event this follower has not handled yet to
|
|
13
|
+
* `--exec`, one at a time, oldest first: the event's JSON on stdin, and
|
|
14
|
+
* MW_EVENT_ID, MW_EVENT_TYPE, MW_EVENT_SUBJECT_KIND, MW_EVENT_SUBJECT_ID,
|
|
15
|
+
* MW_EVENT_CORRELATION and MW_EVENT_OBSERVED_AT in the environment. Exit 0
|
|
16
|
+
* and the follower moves past it; anything else and it stops, to try that
|
|
17
|
+
* event again on the next run. Without `--exec`, each event is printed as one
|
|
18
|
+
* JSON line. The cursor lives in --state-dir (default
|
|
19
|
+
* $XDG_STATE_HOME/medicine-wheel-events, else ~/.local/state/…), never in
|
|
20
|
+
* the clone.
|
|
21
|
+
*
|
|
22
|
+
* Exit codes: 0 done, 1 a pull or a handler failed, 2 usage error.
|
|
23
|
+
*/
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
36
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37
|
+
}) : function(o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
41
|
+
var ownKeys = function(o) {
|
|
42
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
43
|
+
var ar = [];
|
|
44
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
45
|
+
return ar;
|
|
46
|
+
};
|
|
47
|
+
return ownKeys(o);
|
|
48
|
+
};
|
|
49
|
+
return function (mod) {
|
|
50
|
+
if (mod && mod.__esModule) return mod;
|
|
51
|
+
var result = {};
|
|
52
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
53
|
+
__setModuleDefault(result, mod);
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
})();
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
const node_child_process_1 = require("node:child_process");
|
|
59
|
+
const os = __importStar(require("node:os"));
|
|
60
|
+
const path = __importStar(require("node:path"));
|
|
61
|
+
const git_1 = require("./git");
|
|
62
|
+
const schema_1 = require("./schema");
|
|
63
|
+
function usage(error) {
|
|
64
|
+
if (error)
|
|
65
|
+
console.error(`mw-events: ${error}`);
|
|
66
|
+
console.error('usage: mw-events follow <clone> [--exec "<command>"] [--name <follower>] [--file <path>] [--state-dir <dir>] [--no-pull] [--every <seconds>]');
|
|
67
|
+
console.error(' mw-events schema [--asyncapi]');
|
|
68
|
+
process.exit(2);
|
|
69
|
+
}
|
|
70
|
+
function parse(argv) {
|
|
71
|
+
const positional = [];
|
|
72
|
+
const flags = {};
|
|
73
|
+
for (let i = 0; i < argv.length; i++) {
|
|
74
|
+
const arg = argv[i];
|
|
75
|
+
if (!arg.startsWith('--')) {
|
|
76
|
+
positional.push(arg);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const key = arg.slice(2);
|
|
80
|
+
if (key === 'no-pull' || key === 'asyncapi') {
|
|
81
|
+
flags[key] = true;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const value = argv[++i];
|
|
85
|
+
if (value === undefined)
|
|
86
|
+
usage(`--${key} needs a value`);
|
|
87
|
+
flags[key] = value;
|
|
88
|
+
}
|
|
89
|
+
return { positional, flags };
|
|
90
|
+
}
|
|
91
|
+
function runHandler(command, event) {
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
const child = (0, node_child_process_1.spawn)(command, {
|
|
94
|
+
shell: true,
|
|
95
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
96
|
+
env: {
|
|
97
|
+
...process.env,
|
|
98
|
+
MW_EVENT_ID: event.id,
|
|
99
|
+
MW_EVENT_TYPE: event.event_type,
|
|
100
|
+
MW_EVENT_SUBJECT_KIND: event.subject.kind,
|
|
101
|
+
MW_EVENT_SUBJECT_ID: event.subject.id,
|
|
102
|
+
MW_EVENT_CORRELATION: event.correlation_id ?? '',
|
|
103
|
+
MW_EVENT_OBSERVED_AT: event.observed_at,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
child.on('error', () => resolve(false));
|
|
107
|
+
child.on('close', (code) => resolve(code === 0));
|
|
108
|
+
child.stdin.end(JSON.stringify(event) + '\n');
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async function follow(positional, flags) {
|
|
112
|
+
const repo = positional[1];
|
|
113
|
+
if (!repo)
|
|
114
|
+
usage('follow needs the clone to follow');
|
|
115
|
+
const stateDir = typeof flags['state-dir'] === 'string'
|
|
116
|
+
? flags['state-dir']
|
|
117
|
+
: path.join(process.env.XDG_STATE_HOME || path.join(os.homedir(), '.local', 'state'), 'medicine-wheel-events');
|
|
118
|
+
const exec = typeof flags.exec === 'string' ? flags.exec : undefined;
|
|
119
|
+
const every = typeof flags.every === 'string' ? Number(flags.every) : 0;
|
|
120
|
+
if (Number.isNaN(every) || every < 0)
|
|
121
|
+
usage('--every needs a number of seconds');
|
|
122
|
+
const once = async () => {
|
|
123
|
+
const result = await (0, git_1.followEventLog)({
|
|
124
|
+
repo: path.resolve(repo),
|
|
125
|
+
file: typeof flags.file === 'string' ? flags.file : undefined,
|
|
126
|
+
name: typeof flags.name === 'string' ? flags.name : 'follow',
|
|
127
|
+
stateDir,
|
|
128
|
+
pull: flags['no-pull'] !== true,
|
|
129
|
+
handle: async (event) => {
|
|
130
|
+
if (exec)
|
|
131
|
+
return runHandler(exec, event);
|
|
132
|
+
console.log(JSON.stringify(event));
|
|
133
|
+
return true;
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
if (result.pullError)
|
|
137
|
+
console.error(`mw-events: pull failed, read the clone as it is: ${result.pullError}`);
|
|
138
|
+
console.error(`mw-events: ${result.arrived} handled, ${result.pending} waiting${result.stopped ? ' — stopped on a handler that failed' : ''} (${result.file})`);
|
|
139
|
+
return result.pullError || result.stopped ? 1 : 0;
|
|
140
|
+
};
|
|
141
|
+
if (!every)
|
|
142
|
+
return once();
|
|
143
|
+
for (;;) {
|
|
144
|
+
await once().catch((error) => console.error(`mw-events: ${error.message}`));
|
|
145
|
+
await new Promise((r) => setTimeout(r, every * 1000));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function main() {
|
|
149
|
+
const { positional, flags } = parse(process.argv.slice(2));
|
|
150
|
+
switch (positional[0]) {
|
|
151
|
+
case 'follow':
|
|
152
|
+
return follow(positional, flags);
|
|
153
|
+
case 'schema':
|
|
154
|
+
console.log(JSON.stringify(flags.asyncapi ? (0, schema_1.asyncApiDocument)() : (0, schema_1.wheelEventsJsonSchema)(), null, 2));
|
|
155
|
+
return 0;
|
|
156
|
+
case undefined:
|
|
157
|
+
case 'help':
|
|
158
|
+
return usage();
|
|
159
|
+
default:
|
|
160
|
+
return usage(`unknown command: ${positional[0]}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
main().then((code) => { process.exitCode = code; }, (error) => {
|
|
164
|
+
console.error(`mw-events: ${error.message}`);
|
|
165
|
+
process.exitCode = 1;
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2DAA2C;AAC3C,4CAA8B;AAC9B,gDAAkC;AAClC,+BAAuC;AACvC,qCAAmE;AAGnE,SAAS,KAAK,CAAC,KAAc;IAC3B,IAAI,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,cAAc,KAAK,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,KAAK,CAAC,8IAA8I,CAAC,CAAC;IAC9J,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,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AI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;IAC5D,OAAO,CAAC,KAAK,CAAC,cAAe,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
package/dist/decide.d.ts
CHANGED
|
@@ -98,12 +98,19 @@ export interface RelationLike {
|
|
|
98
98
|
obligations?: string[];
|
|
99
99
|
description?: string;
|
|
100
100
|
}
|
|
101
|
+
/** The nodes at either end of a relation, when the writer holds them. */
|
|
102
|
+
export interface RelationEnds {
|
|
103
|
+
from?: NodeLike | null;
|
|
104
|
+
to?: NodeLike | null;
|
|
105
|
+
}
|
|
106
|
+
/** A relation between two chronicle episodes is lineage: one continues from, or relates to, the other. */
|
|
107
|
+
export declare function isLineage(ends?: RelationEnds): boolean;
|
|
101
108
|
/** A relation is named by its two ends. */
|
|
102
109
|
export declare function relationId(r: {
|
|
103
110
|
from_id: string;
|
|
104
111
|
to_id: string;
|
|
105
112
|
}): string;
|
|
106
|
-
export declare function relationWritten(before: RelationLike | undefined | null, after: RelationLike): WheelEventInput | null;
|
|
107
|
-
export declare function relationRemoved(r: RelationLike): WheelEventInput;
|
|
113
|
+
export declare function relationWritten(before: RelationLike | undefined | null, after: RelationLike, ends?: RelationEnds): WheelEventInput | null;
|
|
114
|
+
export declare function relationRemoved(r: RelationLike, ends?: RelationEnds): WheelEventInput;
|
|
108
115
|
export {};
|
|
109
116
|
//# sourceMappingURL=decide.d.ts.map
|
package/dist/decide.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decide.d.ts","sourceRoot":"","sources":["../src/decide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC;;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,eAAe,CAGrF"}
|
package/dist/decide.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.nodeChanges = nodeChanges;
|
|
|
26
26
|
exports.nodeWritten = nodeWritten;
|
|
27
27
|
exports.nodeRemoved = nodeRemoved;
|
|
28
28
|
exports.conclusionJudged = conclusionJudged;
|
|
29
|
+
exports.isLineage = isLineage;
|
|
29
30
|
exports.relationId = relationId;
|
|
30
31
|
exports.relationWritten = relationWritten;
|
|
31
32
|
exports.relationRemoved = relationRemoved;
|
|
@@ -249,27 +250,44 @@ function conclusionJudged(before, after) {
|
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
252
|
const RELATION_FIELDS = ['relationship_type', 'strength', 'ceremony_honored', 'ceremony_id', 'obligations', 'description'];
|
|
253
|
+
/** A relation between two chronicle episodes is lineage: one continues from, or relates to, the other. */
|
|
254
|
+
function isLineage(ends) {
|
|
255
|
+
return !!ends?.from && !!ends?.to
|
|
256
|
+
&& nodeFamily(ends.from) === 'chronicle.episode' && nodeFamily(ends.to) === 'chronicle.episode';
|
|
257
|
+
}
|
|
252
258
|
/** A relation is named by its two ends. */
|
|
253
259
|
function relationId(r) {
|
|
254
260
|
return `${r.from_id}->${r.to_id}`;
|
|
255
261
|
}
|
|
256
|
-
|
|
262
|
+
/**
|
|
263
|
+
* A relation's words (`description`) stay in the wheel — except between two
|
|
264
|
+
* chronicle episodes, where they are the lineage sentence the episode
|
|
265
|
+
* manifest already carries in the chronicle, and the event repeats them.
|
|
266
|
+
*/
|
|
267
|
+
function relationFrame(r, lineage) {
|
|
257
268
|
return {
|
|
258
269
|
subject: { kind: 'relation', id: relationId(r) },
|
|
259
270
|
correlation_id: r.from_id,
|
|
260
|
-
payload: {
|
|
271
|
+
payload: {
|
|
272
|
+
from_id: r.from_id,
|
|
273
|
+
to_id: r.to_id,
|
|
274
|
+
relationship_type: str(r.relationship_type),
|
|
275
|
+
...(lineage ? { relation: str(r.description) } : {}),
|
|
276
|
+
},
|
|
261
277
|
};
|
|
262
278
|
}
|
|
263
|
-
function relationWritten(before, after) {
|
|
264
|
-
const
|
|
279
|
+
function relationWritten(before, after, ends) {
|
|
280
|
+
const lineage = isLineage(ends);
|
|
281
|
+
const frame = relationFrame(after, lineage);
|
|
265
282
|
if (!before)
|
|
266
|
-
return { name: 'relation.made', ...frame };
|
|
283
|
+
return { name: lineage ? 'chronicle.lineage.made' : 'relation.made', ...frame };
|
|
267
284
|
const changed = changedFields(before, after, RELATION_FIELDS);
|
|
268
285
|
if (!changed.length)
|
|
269
286
|
return null;
|
|
270
|
-
return { name: 'relation.amended', ...frame, payload: { ...frame.payload, changed } };
|
|
287
|
+
return { name: lineage ? 'chronicle.lineage.amended' : 'relation.amended', ...frame, payload: { ...frame.payload, changed } };
|
|
271
288
|
}
|
|
272
|
-
function relationRemoved(r) {
|
|
273
|
-
|
|
289
|
+
function relationRemoved(r, ends) {
|
|
290
|
+
const lineage = isLineage(ends);
|
|
291
|
+
return { name: lineage ? 'chronicle.lineage.removed' : 'relation.removed', ...relationFrame(r, lineage) };
|
|
274
292
|
}
|
|
275
293
|
//# sourceMappingURL=decide.js.map
|